1.3 Server
1.3.1 Sequence
1.3.2 Cargos
1.3.3 Grid
1.3.4 Engine
1.3.5 Setup
1.3.6 Agent
1.3.7 Interval
1.3.8 Dispatcher
1.3.9 TCP Server
8.14
1.3.5 Setup🔗

Source code at setup.rkt

Setup creates an engine and populates it with blocks, and creates bots for a player.

(define (setup-engine)
  (make-engine 50))
(define (add-random-location engine entity-type)
  (let ([new-entity (add-entity engine entity-type (location (random 50) (random 50)))])
    (if new-entity
        new-entity
        (add-random-location engine entity-type))))
(define (setup-blocks engine)
  (for ([i 25])
    (add-random-location engine type-block))
  #t)

To set up bots, a base is created in a random location. The bots are added at locations adjacent to the base.

(define (setup-bots engine)
  (let ([base (add-base-at-random engine)])
    (for/list ([location (all-directions (entity-location base))])
      (add-entity engine type-bot location))))