The Daily Click ::. Forums ::. Klik Coding Help ::. The Game of Life
 

Post Reply  Post Oekaki 
 

Posted By Message

Aptennap



Registered
  23/04/2004
Points
  916
14th November, 2008 at 14:52:31 -

So I'm trying to create a simple Game of Life app, but I have no idea how I can get the amount of neighbours. I now have a grid of 16x16 actives (300), which you can turn black and white by clicking on them.

 
Oh sweet mary.

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
14th November, 2008 at 16:30:40 -

what is game of life?
I don't really understand what do u want. Could you explain it a bit better.

 
Code me a sausage!

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
14th November, 2008 at 16:41:30 -

What grid system are you using? You may have to use an array...

 

  		
  		

Aptennap



Registered
  23/04/2004
Points
  916
14th November, 2008 at 16:53:35 -

I'm not using an array right now. I'll try it with an array.

EDIT:I'm unable to do it using an array, does someone have any clue how to do it?

Image Edited by the Author.

 
Oh sweet mary.

Silveraura

God's God

Registered
  08/08/2002
Points
  6747

Game of the Week WinnerKlikCast StarAlien In Training!VIP Member360 OwnerWii OwnerSonic SpeedThe Cake is a LieComputerChristmas Tree!
I am an April Fool
14th November, 2008 at 19:36:32 -


Originally Posted by Don Luciano
what is game of life?
I don't really understand what do u want. Could you explain it a bit better.



It's a game that basically shows little dots growing off of each other and if any of them get singled out then they eventually die unless more come and reconnect them.

 
http://www.facebook.com/truediamondgame

-J-



Registered
  05/10/2008
Points
  228

VIP MemberThe Cake is a Lie
14th November, 2008 at 19:54:17 -

There'd have to be a really complicated way of doing this with the Advanced Game Board object

 
n/a ...

Aptennap



Registered
  23/04/2004
Points
  916
14th November, 2008 at 20:37:07 -

Yea I was thinking of that too, but you can't check for diagonal connected blocks with that one right?

 
Oh sweet mary.

-J-



Registered
  05/10/2008
Points
  228

VIP MemberThe Cake is a Lie
14th November, 2008 at 21:14:38 -

I think you can.. You can also check if a cell is "Occupied"

Here could be another way... Give each cell a detector on each side, and if the detector is overlapping another full cell, then the current cell must have a neighbour.

If that makes sense

 
n/a ...

Aptennap



Registered
  23/04/2004
Points
  916
14th November, 2008 at 23:13:07 -

I already have 300 actives, and I would need 8 detectors per object. So a total of 2400 objects Or you could have only 8 detectors and move those to the position of the cell you want to check.

 
Oh sweet mary.

-J-



Registered
  05/10/2008
Points
  228

VIP MemberThe Cake is a Lie
15th November, 2008 at 00:16:42 -

Or you could go even more complicated and have each live cell as an active object and create more active objects around it when needed, and destroying others when they die.

 
n/a ...

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
15th November, 2008 at 11:09:07 -

you can do this just with an array. But it's a lot of coding.

Julian said bout detectors, that's a good way. And you don't need 8 detectors for each cell you need only one. Since the cell dies only when having no neighboirs. So it's a bigger detector surronding the whole object.

Other way is to use alpha channel, and make the same object as the detector itself, just make it a pixel bigger in all directions. Make that border invisible, and check if it overlaps itself. if it doesn't well, u know the deal.




 
Code me a sausage!

Aptennap



Registered
  23/04/2004
Points
  916
15th November, 2008 at 13:54:40 -

There are actually more rules to the game of life, you can't just check for it having no neighbours you need to know the amount of neighbours. Thanks for all the comments guys, I'm not going to try creating this anymore I'm not ready for it .

 
Oh sweet mary.

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
15th November, 2008 at 23:49:06 -

I think it's possible, not too tough. Just compare all the adjacent arrays with a mathematical formula.

However, MMF's expression editor system would make this extremely annoying so I'm not going to do it

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image
   

Post Reply



 



Advertisement

Worth A Click