world_step   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/contrib/game-of-life.xtm

Implementation

(bind-func world_step
  (lambda (w)
    (letz ((cv 0)
           (n 0)
           (pending_updates:List* null))
      (doloop (i (world_height w))
        (doloop (j (world_width w))
          (set! cv (cell_value w i j))
          (set! n (cell_count_neighbors w i j))
          (if (= cv 0:i8)
              ;; birth
              (if (= n 3:i8)
                  (set! pending_updates (cons (CellUpdate i j 1) pending_updates)))
              ;; cell is dead
              (if (not (or (= n 2:i8)
                           (= n 3:i8)))
                  (set! pending_updates (cons (CellUpdate i j 0) pending_updates))))))
      ;; do all the updates
      (for-each (lambda (cu)
                  ;; (println "performing update: x =" (tref cu 0)
                  ;;          "y =" (tref cu 1)
                  ;;          "newvalue =" (tref cu 2))
                  (cell_set_value w (tref cu 0) (tref cu 1) (tref cu 2)))
                pending_updates)
      (world_increment_generation w))))


Back to Index

Similar Entries

  • callback_goodbye_world    xtlang
  • callback_hello_world    xtlang
  • fluid-step-cube    xtlang
  • fluid-step-cube    xtlang
  • fluid_step_cube    xtlang
  • get-scale-stepsize    scheme
  • lilv_init_world    xtlang
  • pc:from-steps    scheme
  • pc:melody-by-step    scheme
  • test_world_copy    xtlang
  • test_world_foo    xtlang
  • test_world_indexing    xtlang
  • test_world_periodic_bc    xtlang
  • world_add_blinker    xtlang
  • world_ascii_print    xtlang
  • world_basic_print    xtlang
  • world_copy    xtlang
  • world_create    xtlang
  • world_data    xtlang
  • world_data_index    xtlang
  • world_data_size    xtlang
  • world_equal    xtlang
  • world_generation    xtlang
  • world_height    xtlang
  • world_increment_generation    xtlang
  • world_init    xtlang
  • world_reset    xtlang
  • world_set_generation    xtlang
  • world_set_to_checkerboard    xtlang
  • world_set_to_inverse    xtlang
  • world_texture_setup    xtlang
  • world_width    xtlang