News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Game of Life

Started by zedd151, June 29, 2024, 08:11:25 AM

Previous topic - Next topic

zedd151

So far so good. I didn't record the starting sequence, but for some sets of cells, they reach a point where they don't 'move' anymore. Example:

Only the 3 cell line changes between vertical and horizontal, the other patterns do not change any further. I'll have to investigate further as I find this interesting.
Only one quibble. When setting cells 'on', the user should be able to turn it off again, if it was a mistake or accident for example.

Maybe we could ask Stewart to move this to Game Development... up to you, as its your game being developed here. Maybe split it off from the post with your first code attachment?
Ventanas diez es el mejor.  :azn:

NoCforMe

Sure, whatever.
I'll add setting cells back to "off", easy enough to do.

And what you're seeing with those patterns that either oscillate (a line of 3 cells on that flips from horizonal to vertical) or just sit there (a 2x2 square) are classic behaviors of the "game".
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: NoCforMe on July 04, 2024, 10:49:01 AMSure, whatever.
I'll add setting cells back to "off", easy enough to do.
okee.
QuoteAnd what you're seeing with those patterns that either oscillate (a line of 3 cells on that flips from horizonal to vertical) or just sit there (a 2x2 square) are classic behaviors of the "game".

I'll have to have a more 'in depth' look at the rulez. I only glossed over the rules before.
Ventanas diez es el mejor.  :azn:

NoCforMe

QuoteI'll have to have a more 'in depth' look at the rulez. I only glossed over the rules before.
The behavior isn't in the rules, it's just caused by them.
This is actually a quite complex little scheme, even though the rules are dead-simple.

The rulez:
  • If a cell is ON and has fewer than 2 neighbors that are ON, it gets turned OFF
  • If a cell is ON and has 2 or 3 neighbors that are ON, it stays ON
  • If a cell is ON and has more than 3 neighbors, it gets turned OFF
  • If a cell is OFF and has 3 neighbors that are ON, it gets turned ON
That's it. ("Neighbors" are adjacent or diagonal; each cell has 8 neighbors in a 3x3 array.)
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: NoCforMe on July 04, 2024, 11:40:50 AMIf a cell is OFF and has 3 neighbors that are ON, it gets turned ON

Thats the part I was not seeing anywhere, at least that I noticed. I only see 'death', no 'birth'...
I'll have more time later to play with this more. Maybe I was just missing that happening?...  :smiley:
Ventanas diez es el mejor.  :azn:

sinsi

Nice work. Size is small on a 4K monitor, makes it fiddly to click cells.

I made one change to the code
;MOV [EAX + GameArray], 1 ;Set cell to ON.
xor [EAX + GameArray], 1                ;toggle it instead

QuoteMaybe we could ask Stewart to move this to Game Development
Agreed.
🍺🍺🍺

NoCforMe

New version. Two added things:
  • Autoplay: click the button and watch the game play itself.
  • Save & load patterns: When setting starting patterns by clicking, you can save the pattern for later usage.

(Also fixed the grid drawing which had been wrong all this time ...)

Took me a while to figure out how to figure out when a game is over. The system I came up with seems reliable: if the # of ON cells goes to zero, obviously it's over. Checking whether the # of cells that change is the same as the previous move, AND the # of ON cells is the same proved not reliable, but it seems to work after I added a checksum (the sum of all ON cells plus their address in the array). There still may be some corner cases where this doesn't work, so if you see the game running on after it's obviously over, let me know.

Only thing I can see adding at this point would be some stats reporting at the end of a game.
Assembly language programming should be fun. That's why I do it.

sinsi

Wish list
 - adjust the delay for autoplay
 - pause
 - edge wrap
 - size the window according to screen resolution (hard with multi-monitors though)

It's simple but fascinating :cool:
🍺🍺🍺

NoCforMe

I get everything you listed except edge wrap: how exactly would that work?

Treat the left edge as an extension of the right edge and vice versa (& top & bottom)?

Resizing would be difficult but doable, necessary for a "real" game.

It could also stand a smarter paint handler instead of redrawing the whole damn thing every time.
Assembly language programming should be fun. That's why I do it.

sinsi

Quote from: NoCforMe on July 05, 2024, 03:27:45 PMTreat the left edge as an extension of the right edge and vice versa (& top & bottom)?
Yep, like a flat sphere instead of a square.
🍺🍺🍺

NoCforMe

So a Mobius square. Gotcha.
Assembly language programming should be fun. That's why I do it.

daydreamer

What happens if you start with random generated pattern ?
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

zedd151

@NoCforMe: I had a chance last night to tinker with the latest version. Kudos, it works pretty much as expected.   :thumbsup:
I am glad to see that I inspired you to write this program.  :smiley:

Now if I can just get motivated to start my own rendition of it.   :tongue:
Ventanas diez es el mejor.  :azn:

NoCforMe

Quote from: zedd151 on July 07, 2024, 12:52:41 AMNow if I can just get motivated to start my own rendition of it.   :tongue:
Please do. I'm probably going to add just one more thing to my version (stats reporting) and that should be it.

Fairly simple "game", so pretty simple data structures.
Assembly language programming should be fun. That's why I do it.

tenkey

After a while, you should look into gliders and glider guns. They were among the first interesting patterns to be discovered.
You cannot view this attachment.