Arc Forumnew | comments | leaders | submitlogin
4 points by bOR_ 6048 days ago | link | parent

Thanks! This now works, and I'm learning :)

  ; makes a world matrix
  (def makeworld (x)
    (= world (n-of x (n-of x nil))) ; world of nil
    (= merged (n-of x (n-of x nil))) ; layer of movers
    nil)


  ; print out the world, imposing a list of critters
  ; on top of it. The list itself assumes that its entries
  ; are tables which have a symbol and a position field
  (def show (lst)
    ; copy world into merged
    (for y 0 (- (len world) 1)
      (for x 0 (- (len world) 1)
        (= ((merged y) x) ((world y) x))))
    ; superimpose critters
    (each c lst
      (= ((merged (car (c "pos"))) (cadr (c "pos"))) (c "symbol")))
    ; plot world
    (each row merged
      (each pos row (if (is pos nil) (pr #\. #\space) (pr pos #\space)))
      (prn)))

  (= creature (table))
  (= creature2 (table))
  (= creature3 (table))
  (= (creature "pos") '(1 3))
  (= (creature2 "pos") '(10 3))
  (= (creature3 "pos") '(8 8))
  (= (creature "symbol") #\$)
  (= (creature2 "symbol") #\@)
  (= (creature3 "symbol") #\#)
  (makeworld 15)

  arc> (show (list creature creature2 creature3))
  . . . . . . . . . . . . . . . 
  . . . $ . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . . . . . . # . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . @ . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  . . . . . . . . . . . . . . . 
  nil


2 points by cchooper 6047 days ago | link

Nice! Is that going to be a game or something?

-----

1 point by bOR_ 6016 days ago | link

http://wwww.bagofsouls.com

It's the start of a new project for me (and hopefully later on a postdoc position on the topic). The idea is to build some kind of smart animals in an artificial world, without having to design them, or run through countless of iterations with genetic algorithms to get one.

With a good basic structure, they should be able to get smart on their own ;).

-----