annapolar.blogg.se

Coding conways game of life sfml
Coding conways game of life sfml








coding conways game of life sfml

V turn_right = grid != :color_BLACKĭirection_index = (direction_index + 1) % 4ĭirection_index = (direction_index + 4 - 1) % 4

coding conways game of life sfml

‘Compute next direction according to current position and direction.’ ‘Invert the color of grid at x, y coordinate.’ The problem has received some analysis for more details, please take a look at the Wikipedia article (a link is below). Start the ant near the center of a 100 x100 field of cells, which is about big enough to contain the initial chaotic part of the movement.įollow the movement rules for the ant, terminate when it moves out of the region, and show the cell colors it leaves behind. This rather simple ruleset leads to an initially chaotic movement pattern, and after about 10000 steps, a cycle appears where the ant moves steadily away from the starting location in a diagonal corridor about 10 cells wide.Ĭonceptually the ant can then walk infinitely far away. The ant then moves forward to the next cell, and repeat from step 1.If the cell is white, it changes to black and the ant turns right.If the cell is black, it changes to white and the ant turns left.The ant moves according to the color of the cell it is currently sitting in, with the following rules: Langton's ant is a cellular automaton that models an ant sitting on a plane of cells, all of which are white initially, the ant facing in one of four directions. You are encouraged to solve this task according to the task description, using any language you may know.










Coding conways game of life sfml