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    /digego/extempore/tree/v0.8.9/examples/external/ulfius.xtm
  • callback_hello_world    xtlang    /digego/extempore/tree/v0.8.9/examples/external/ulfius.xtm
  • fluid-step-cube    xtlang    /digego/extempore/tree/v0.8.9/libs/external/fluid2d.xtm
  • fluid-step-cube    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/fluid_dynamics.xtm
  • fluid_step_cube    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/fluids_2d.xtm
  • get-scale-stepsize    scheme    /digego/extempore/tree/v0.8.9/libs/core/pattern-language.xtm
  • lilv_init_world    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/lilv.xtm
  • pc:from-steps    scheme    /digego/extempore/tree/v0.8.9/libs/core/pc_ivl.xtm
  • pc:melody-by-step    scheme    /digego/extempore/tree/v0.8.9/libs/core/pc_ivl.xtm
  • test_world_copy    xtlang    /digego/extempore/tree/v0.8.9/tests/core/game-of-life.xtm
  • test_world_foo    xtlang    /digego/extempore/tree/v0.8.9/tests/core/game-of-life.xtm
  • test_world_indexing    xtlang    /digego/extempore/tree/v0.8.9/tests/core/game-of-life.xtm
  • test_world_periodic_bc    xtlang    /digego/extempore/tree/v0.8.9/tests/core/game-of-life.xtm
  • world_add_blinker    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/game-of-life.xtm
  • world_ascii_print    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/game-of-life.xtm
  • world_basic_print    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/game-of-life.xtm
  • world_copy    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/game-of-life.xtm
  • world_create    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/game-of-life.xtm
  • world_data    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/game-of-life.xtm
  • world_data_index    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/game-of-life.xtm
  • world_data_size    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/game-of-life.xtm
  • world_equal    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/game-of-life.xtm
  • world_generation    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/game-of-life.xtm
  • world_height    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/game-of-life.xtm
  • world_increment_generation    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/game-of-life.xtm
  • world_init    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/game-of-life.xtm
  • world_reset    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/game-of-life.xtm
  • world_set_generation    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/game-of-life.xtm
  • world_set_to_checkerboard    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/game-of-life.xtm
  • world_set_to_inverse    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/game-of-life.xtm
  • world_texture_setup    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/game-of-life.xtm
  • world_width    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/game-of-life.xtm