Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Game of Life - 8 Bit PIC programming problem...

Status
Not open for further replies.

Alptraum

New Member
Hi,
I want to build an 8 by 8 grid which has an input switch array and can play Conway's Game of Life. I am hoping to use a toroidal arrangement, which avoids the funny things which would happen when the chip tried to simulate a pattern outside of the grid. It also just makes the pattern last longer.
However, in order to do this (efficiently), I need to be able to change the values x and y in a coordinate (x,y) depending on what rules the cell follows, and this is made a lot easier by being able to do this.

At the moment, the basic outline for each pixel is:

1) Log pixel coordinate,
2) Sum number of 'live' (on) cells of the surrounding 8,
3) Output the final value of the cell based upon the rules of the game,
4) Store the result in a result register, separate to the current register, in order to prevent the system basing the results on the outputs of other cells.
5) Go to the next cell and repeat the procedure.

That should work fine, and I can program that, but only if I'm able to define x and y. I need to be able to set x=x+1 without creating an infinite loop and breaking maths, in order to progress through the grid.

Also, in order to do the toroidal arrangement effectively, I need to be able to say that 0 is the successor to 9, so that it reads the 8 surrounding cell states and doesn't read the edge as an edge.

Has anyone got any ideas how to do the above 2 paragraphs? Keep in mind that I have to do this in ASM.


Thanks.
 
What language?
Which chip?
What is a toroidal arrangement? A toroid is a donut.

If it's an 8x8 grid then you simply number them 0 to 7. Then ANDing the number with 7 will make it wrap around.

Mike.
 
ASM, I'm not sure which chip yet, but it will be a PIC, toroidal as in if you were to stretch it out and connect the edges, they would connect as in a torus, i.e. something that goes off the right wall will reappear on the left wall and likewise with the top wall to the bottom wall.

What do you mean, ANDing the number? I mean that if I have something on an 8x8 grid with the coordinate (1,1), then I need to sample the 8 surrounding cells:


000
0x0
000

Where the x is the cell (1,1) and the rest of the cells are those which need to be sampled.

However, if the cell is at (0,1), the surrounding cells are not all 'visible' directly, so the program wraps:


YY00000Y
CY00000Y
YY00000Y

Where C is the selected cell, Y is what needs to be sampled, and 0 is not relevant.

However, I plan to do this by having it read which pins are high of the surrounding 8, and it will work out which are the surrounding 8 and which to sample by:

1) reading the coordinates of the point, (x,y), where x and y are numbered pin outputs corresponding to which power and ground rails are high.
2) read:
(x-1,y-1)
(x-1,y)
(x-1,y+1)
(x,y-1)
(x,y+1)
(x+1,y-1)
(x+1,y)
(x+1,y+1)

by using MOVLW PORTB, (x-1)
MOVWF whatever

Now, my 2 questions were, how do I/can I use "PORTB, (x-1)" if I have previously defined x as being the x coordinate,
and can I make the pic think that the number which comes after 7 is 0?

Thanks
 
Anyone? I've asked someone who told me what what I'm asking is called and he said it is an array... The only thing is still making the thing reset after bit whatever.
 
Status
Not open for further replies.

Latest threads

Back
Top