Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

JAVA Langton Ant Sim

Name: Anonymous 2013-04-21 0:28

hey so I just started university and I'm taking an intro to programming course and SUCKING at it so far

my first assignment is to recreate the Langton Ant simulation on a grid of colored cells

RULES:

>>Move forward one space. If this movement would cause it to move off the grid, the simulation is completed

>>Rotate depending on the state of the cell the ant is occupying: if the cell is white, rotate left; otherwise, rotate right

>>Change the state of the cell the ant is currently occupying: if the cell is white, it becomes black, and if it is black, it becomes white.

I need help. can someone help?

thanks ~kickflips away from u~

Name: Anonymous 2013-04-21 1:06

you dont really have to use colors. for example, the grid can be a simple array which contains a number in each cell. 1 is a white cell, 0 is a black cell

* program a grid
* paint it white (like traversing the grid and set all cells to 1)
make a function to put an and on a coordinate like put_ant(10, 5)
* program a loop that start after puting an ant on the grid
* program 4 functions to move an ant : move_down(), move_up(), move_left(), move_right()
* program what to choose from above when the cell is white. the same when is black.
* program what happens after the ant moves. That is, change the color of the cell where the ant was. in the same function program what happens if the ant goes out the grid.

done

i know is not the BEST way to do it but fuck you

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List