mirror of
https://github.com/richardharrington/robotwar.git
synced 2024-06-07 10:29:31 +00:00
9b46900f9b
them constants because technically, the robot ranges are the maximum ranges for the centers of the robots' bodies, so the actual extent of the arena when displayed must be slightly larger
30 lines
1.0 KiB
Clojure
30 lines
1.0 KiB
Clojure
(ns robotwar.world
|
|
(:use [clojure.string :only [join]]
|
|
[robotwar.constants])
|
|
(:require [clj-time.core :as time]
|
|
[clj-time.periodic :as periodic]
|
|
[robotwar.robot :as robot]))
|
|
|
|
(defn init-world
|
|
"initialize all the variables for a robot world."
|
|
[programs]
|
|
{:shells []
|
|
:robots (vec (map-indexed (fn [idx program]
|
|
(robot/init-robot
|
|
idx
|
|
program
|
|
{:pos-x (rand ROBOT-RANGE-X)
|
|
:pos-y (rand ROBOT-RANGE-Y)
|
|
:aim 0.0
|
|
:damage 100.0}))
|
|
programs))})
|
|
|
|
(defn tick-combined-world
|
|
[starting-world]
|
|
(reduce (fn [{robots :robots :as world} robot-idx]
|
|
(robot/step-robot (robots robot-idx) world))
|
|
starting-world
|
|
(range (count (:robots starting-world)))))
|
|
|
|
(def build-combined-worlds (partial iterate tick-combined-world))
|