Arduboy gets a Life (Conway's Game of Life)


(Scott) #1

Probably not what would be considered a typical game for the Arduboy but…

I’ve adapted my implementation of Conway’s Game of Life, that I wrote for the Sparkfun MicroView, to run on the Arduboy.

Sound is enabled in the video at time 1:42

Code and information is available on GitHub.

Since the Arduboy has a speaker, I came up with a way to add sound to the game. The number of live cells for a generation is counted to determine the frequency of the tone played. The more cells, the higher the pitch. The frequency in Hz will be live cells * 3 + 20. This gives an interesting (or maybe somewhat annoying) sound pattern :grimacing:

NOTE: This sketch double buffers the display image and therefore uses a large amount of RAM. It’s likely to be affected by a bootloader conflict problem. If you have trouble loading new sketches after uploading ArduboyLife, see this post further down in this topic:
http://community.arduboy.com/t/arduboy-gets-a-life-conways-game-of-life/578/10


Game of Life (Celluar Automaton) for Arduboy
How to Reset the Dev Kit
"Semi-Official" Game List for the Arduboy
"Semi-Official" Game List for the Arduboy
Chicken Launcher - A Bird Flinging Game
Arduboy2 - The now recommended alternative to the Arduboy Library
(Ross) #2

The game of life is the greatest game ever conceived. Really awesome transition from the title screen.


(Kevin) #3

Ah man, and I thought this post was about me having relevant and meaningful social interactions. Nice work though was waiting for someone to get this! :smiley:


#4

The sound sounds like the music in 2001 a space odyssey, when Bowman enters the monolith. :stuck_out_tongue_winking_eye:


(Andrew Dent) #5

Looks great. Love how the opening titles become the seed!
Any chance when paused, that the direction pad + ‘Run’ button let you draw / push pixels to the screen? Alternatively I guess, you could interact with the running game and then adjust settings when paused?


(Scott) #6

I thought about doing a grid editor but don’t really have the time right now. Anyone else is welcome to take a shot at it.

The way I would do it would be to change the Up and Down buttons to not just simply toggle the sound but bring up a menu instead. The menu would allow you to toggle sound, as before, but also have options for starting an editor, perhaps saving games, etc.

My idea for an editor would be to have the D-pad move a cursor. An auto-repeat when the movement buttons were held down would be nice. The A button would toggle pixels to their opposite state and could be held down and used with the D-pad to draw lines. The B button would exit the editor.

The only problem I see is that the screen is so tiny that some may have difficulty drawing specific patterns.

I’ve also thought about being able to upload grids using USB serial (although if you have a computer that can edit grids for upload, you could probably play the game on it, making the Arduboy redundant). For upload I would have the main loop check for serial data when in pause mode. If a 0xFF was received it would signal start of data. The grid data would just be pairs of bytes containing the X and Y coordinates of each pixel, in binary. Another 0xFF would signal the end of data. The grid would be cleared and the uploaded pixels would be set. If a timeout occurred before the ending 0xFF was received, all data would be discarded. If you wanted to get fancy, you could include some kind of a checksum with the data and have the Arduboy send an ACK or NAK.

Note that because of the way the restart function is currently implemented, it couldn’t be used with the edit or upload functions.

About saving games: There obviously wouldn’t be space to save actual grid patterns, but the pseudo-random starting pattern for a game is determined by the seed passed to the genGrid() function. You could save a desired game, for retrieval and replay, by just saving the 4 byte seed, which is stored in the randSeed variable.


(Colin Seaman) #7

This has installed in a folder and I can’t install any new games. How do I remove games so I can start fresh installs. Sorry but I’m new to this

Thanks


(Scott) #8

I’m not sure exactly what your problems is. Can you be more specific and give some details?


(Colin Seaman) #9

When I complied the game it asked me if I wanted to create a folder which I replied yes. Now every time I compile a game it finishes and restarts the unit but its always the Life demo. I complied several games before this and they all worked. So I was just wondering what I need to do to remove the life demo and install new games.

Sorry hope that makes it clearer, and thanks for any help you can offer

Col


(Scott) #10

Life uses a large amount of RAM so you may be running into the bootloader conflict problem.

Try holding down the UP button when powering up and plugging in your Arduboy. This will enter “flashlight” mode and the RGB LED will light up white and the display will remain blank. (If you have one of the later Kickstarter Arduboys, with the RGB LED installation problem then the RGB LED will not turn on, but if the display remains blank then you’re probably in “flashlight” mode.) See if you can then load a new sketch.


[WIP] Arduventure (RPG)
HELP(Cannot upload a sketch)
(Colin Seaman) #11

Thanks that worked. I really appreciate the response my son is 10 and he loves the Arduboy, nice to see him enjoy something other than Minecraft. I got this as a project so we can both learn code together

Thanks again

Col


(Scott) #12

I’ve updated ArduboyLife to use the Arduboy2 and ArduboyTones libraries instead of the original Arduboy library.

It plays the same as before but you now get the extra boot up features that the Arduboy2 library provides.