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:
Anonymous2013-04-21 0:50
langwage?
Name:
Anonymous2013-04-21 0:58
J to the a to the v to the a... Java.
Name:
Anonymous2013-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.
no, that's helpful, so thanks. what size should i set the height and width of the grid? the length of the array?
how would i program the ant to start in the center of the grid?
influx of questions, i am pretty clueless here.
>>5
He is getting stoned and drunk in a u party by now.
Name:
Anonymous2013-04-21 1:48
You can attack each part one by one. Also the idea for a put_ant(x,y) function is to be able to put the ant in any start position, not just the center. For the size of the grid... who cares, lets say 10x10.
And painting the grid all white is good for starting to code, but as the movement of the ant depends on the cell colors, you should be able to generate a random grid of black and white cells at some point, to make the life of the ant more interesting. Anyway the travesing function can be easily modified to do this.
Name:
Anonymous2013-04-21 1:58
hi every1 im new!!!!!!! *holds up spork* my name is katy but u can
call me t3h PeNgU1N oF d00m!!!!!!!! lol...as u can see im very random!!!!
thats why i came here, 2 meet random ppl like me ^_^... im 13 years old
(im mature 4 my age tho!!) i like 2 watch invader zim w/ my girlfreind
(im bi if u dont like it deal w/it) its our favorite tv show!!! bcuz its
SOOOO random!!!! shes random 2 of course but i want 2 meet more random
ppl =) like they say the more the merrier!!!! lol...neways i hope 2 make
alot of freinds here so give me lots of commentses!!!!
DOOOOOMMMM!!!!!!!!!!!!!!!! <--- me bein random again ^_^ hehe...toodles!!!!!
Name:
Anonymous2013-04-21 2:07
Thanks for the help so far.
My first step is trying to create the grid and make all of the cells in the array white.
This is what I have. I have an error at x.setColor as Graphics can not be used with an array of booleans?
public Grid(Graphics x, int height, int width) {
height = 10;
width = 10;
boolean[][] grid = new boolean[height][width];
for (int i = 0; i < grid.length; i++) {
for (int j = 0; j < grid[i].length; j++) {
x.setColor(grid[i][j] = Color.WHITE != null);
}
}
Thanks to those helping (and not posting extremely old memes??? weird)
Name:
Anonymous2013-04-21 2:16
Color.WHITE is not a boolean. Just populate it with TRUE or FALSE. If you really want to use colors, define your array of type Color.