Game of Life sizecoding contest

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Dr beep
Manic Miner
Posts: 381
Joined: Mon Oct 01, 2018 8:53 pm

Game of Life sizecoding contest

Post by Dr beep »

I was asked to code a GAME OF LIFE in 1K on the ZX81.
This made we do a search for GAME OF LIFE on the ZX Spectrum.

I didn't find a version on the ZX Spectrum so I was thinking
of a sizecoding contest for GAME OF LIFE on the ZX Spectrum

The rules for the sizecoding contest
1) The rules of GAME OF LIFE must be followed:
a) Any live cell with fewer than two live neighbours dies, as if by underpopulation.
b) Any live cell with two or three live neighbours lives on to the next generation.
c) Any live cell with more than three live neighbours dies, as if by overpopulation.
d) Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
2) The size of the code counts. If your code uses ROM-routines only the CALL to the routine counts
Example : CALL #DAF = 3 bytes for CLS RST 16 = 1 byte for print
3) All tricks are allowed, like using the value of BC after the USR-command that holds the startaddress,
decompressing code etc...
4) The program must have some kind of editor to set/reset colonies.
5) After starting the game the game keeps running until a key is pressed to stop.
6) (symbol) shift can be skipped as a valid keypress to stop the game.
7) After stopping the game you return to the editor.
8) There is a keycombination to stop the game and clear the screen.
9) There is a keycombination to stop the game and NOT clear the screen.
10) The screen is at least 32x24 in size.
11) The screen goes around on same line/colom. A glider will keep moving and reappear on the opposite site
of the screen it went out.
12) Deadline is 2nd Easter 23:59 CET.
13) Sent your game (source and TAP/Z80) to [email protected]
14) DO NOT TELL OTHERS THE SIZE OF YOUR CODE!
15) You can always update your game when you made it shorter.
16) After the contest all contesters are mentioned in a rankinglist
17) All games will be published too.
User avatar
Mpk
Dynamite Dan
Posts: 1008
Joined: Tue Feb 09, 2021 8:10 am

Re: Game of Life sizecoding contest

Post by Mpk »

So, by sizecoding, you mean I've to make it as big as possible? I'm in!

I reckon about 20k just for the spinner.

Image
User avatar
Jbizzel
Dynamite Dan
Posts: 1537
Joined: Mon May 04, 2020 4:34 pm
Location: Hull
Contact:

Re: Game of Life sizecoding contest

Post by Jbizzel »

I made a version for the spectrum a long time ago, but I lost it!

It was in basic and used attributes - it was pretty slow. Could be a fun challenge.
User avatar
Stefan
Manic Miner
Posts: 809
Joined: Mon Nov 13, 2017 9:51 pm
Location: Belgium
Contact:

Re: Game of Life sizecoding contest

Post by Stefan »

While they will not be winning a size competition, Rosetta Code has versions of both in basic: And also a Z80 version for the MSX.
catmeows
Manic Miner
Posts: 718
Joined: Tue May 28, 2019 12:02 pm
Location: Prague

Re: Game of Life sizecoding contest

Post by catmeows »

I guess everybody is going for 32x24 attribute based version ? Ok, could be fun.
Proud owner of Didaktik M
User avatar
ketmar
Manic Miner
Posts: 713
Joined: Tue Jun 16, 2020 5:25 pm
Location: Ukraine

Re: Game of Life sizecoding contest

Post by ketmar »

why don't make the context slightly more… fun? harder? you-name-the-word ;-) by requiring field of at least 64x48? it will require slightly more efforts, but i believe that it also allows for more tricks to be used, and it also will be twice as fun to watch too! ;-)

or, to make the thing accessible for everybody, judge solutions with different fields sizes separately, each in its own category.
User avatar
ParadigmShifter
Manic Miner
Posts: 671
Joined: Sat Sep 09, 2023 4:55 am

Re: Game of Life sizecoding contest

Post by ParadigmShifter »

Michael Abrash (software rendering optimisation (ASM) on Quake) held a compo where the emphasis was on speed so this postmortem may give some ideas

https://www.phatcode.net/res/224/files/ ... 17-01.html

There should probably be a category for speed as well (number of generations/second) since that's probably of more practical use than reducing the size?

I'd probably do a variant on the lookup table technique outlined in that article (and following ones) but with 2 cells per entry in the table instead of the 3 the winning entry used (so that had to use a 64K lookup table). Obviously the table would have to be generated via code (running from the buffer where the celldata will be stored) to reduce code size.

Probably won't enter myself though ;)
Dr beep
Manic Miner
Posts: 381
Joined: Mon Oct 01, 2018 8:53 pm

Re: Game of Life sizecoding contest

Post by Dr beep »

BTW Easter 2nd is also 1st of april, I just looked up but it is not a joke.

Additional rule:
Machinecode counts, but no presetting in BASIC like PAPER , INK etc.
Only LOAD "" CODE and then
RANDOMIZE USR
PRINT USR
GOTO USR

whatever you like to start
(free tip: RUN USR clears the screen)
Dr beep
Manic Miner
Posts: 381
Joined: Mon Oct 01, 2018 8:53 pm

Re: Game of Life sizecoding contest

Post by Dr beep »

ketmar wrote: Tue Dec 05, 2023 12:43 am why don't make the context slightly more… fun? harder? you-name-the-word ;-) by requiring field of at least 64x48? it will require slightly more efforts, but i believe that it also allows for more tricks to be used, and it also will be twice as fun to watch too! ;-)

or, to make the thing accessible for everybody, judge solutions with different fields sizes separately, each in its own category.

Rules state at least, but adding own competition for other sized solutions is now added.
Dr beep
Manic Miner
Posts: 381
Joined: Mon Oct 01, 2018 8:53 pm

Re: Game of Life sizecoding contest

Post by Dr beep »

Mpk wrote: Mon Dec 04, 2023 10:40 pm So, by sizecoding, you mean I've to make it as big as possible? I'm in!

I reckon about 20k just for the spinner.

Image
Try again. Big is also allowed but it will give you first place bottomup.
Dr beep
Manic Miner
Posts: 381
Joined: Mon Oct 01, 2018 8:53 pm

Re: Game of Life sizecoding contest

Post by Dr beep »

Stefan wrote: Tue Dec 05, 2023 12:03 am While they will not be winning a size competition, Rosetta Code has versions of both in basic: And also a Z80 version for the MSX.
The ZX Spectrum entry mentions a machinecode version on Horizons tape. Never knew that.
User avatar
+3code
Manic Miner
Posts: 434
Joined: Sat Mar 19, 2022 7:40 am

Re: Game of Life sizecoding contest

Post by +3code »

Dr beep wrote: Mon Dec 04, 2023 10:30 pm I was asked to code a GAME OF LIFE in 1K on the ZX81.
This made we do a search for GAME OF LIFE on the ZX Spectrum.

I didn't find a version on the ZX Spectrum...
https://spectrumcomputing.co.uk/list?license_id=66
User avatar
R-Tape
Site Admin
Posts: 6409
Joined: Thu Nov 09, 2017 11:46 am

Re: Game of Life sizecoding contest

Post by R-Tape »

Dr beep wrote: Mon Dec 04, 2023 10:30 pm This made we do a search for GAME OF LIFE on the ZX Spectrum.

I didn't find a version on the ZX Spectrum
There's loads in the archive btw, titled "Life" rather than "Game of Life". E.g. this one.

But that doesn't change anything with this competition - it sounds a fun challenge.
Dr beep
Manic Miner
Posts: 381
Joined: Mon Oct 01, 2018 8:53 pm

Re: Game of Life sizecoding contest

Post by Dr beep »

I did a search on GAME OF LIFE.
Thanks.
Still the contest stays open.
User avatar
Pobulous
Dynamite Dan
Posts: 1366
Joined: Wed Nov 15, 2017 12:51 pm

Re: Game of Life sizecoding contest

Post by Pobulous »

There was a colour version included on another game - I seem to think it was a Pete Cooke game.
User avatar
TomD
Manic Miner
Posts: 379
Joined: Tue Nov 13, 2018 9:47 am
Location: Leeds UK
Contact:

Re: Game of Life sizecoding contest

Post by TomD »

Dr beep wrote: Mon Dec 04, 2023 10:30 pm I was asked to code a GAME OF LIFE in 1K on the ZX81.
This made we do a search for GAME OF LIFE on the ZX Spectrum.

I didn't find a version on the ZX Spectrum so I was thinking
of a sizecoding contest for GAME OF LIFE on the ZX Spectrum

The rules for the sizecoding contest
1) The rules of GAME OF LIFE must be followed:
a) Any live cell with fewer than two live neighbours dies, as if by underpopulation.
b) Any live cell with two or three live neighbours lives on to the next generation.
c) Any live cell with more than three live neighbours dies, as if by overpopulation.
d) Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
2) The size of the code counts. If your code uses ROM-routines only the CALL to the routine counts
Example : CALL #DAF = 3 bytes for CLS RST 16 = 1 byte for print
3) All tricks are allowed, like using the value of BC after the USR-command that holds the startaddress,
decompressing code etc...
4) The program must have some kind of editor to set/reset colonies.
5) After starting the game the game keeps running until a key is pressed to stop.
6) (symbol) shift can be skipped as a valid keypress to stop the game.
7) After stopping the game you return to the editor.
8) There is a keycombination to stop the game and clear the screen.
9) There is a keycombination to stop the game and NOT clear the screen.
10) The screen is at least 32x24 in size.
11) The screen goes around on same line/colom. A glider will keep moving and reappear on the opposite site
of the screen it went out.
12) Deadline is 2nd Easter 23:59 CET.
13) Sent your game (source and TAP/Z80) to [email protected]
14) DO NOT TELL OTHERS THE SIZE OF YOUR CODE!
15) You can always update your game when you made it shorter.
16) After the contest all contesters are mentioned in a rankinglist
17) All games will be published too.
Quick question, when starting the game do you need have a preset pattern or can it load straight into an editor so you can create a pattern?
Retro enthusiast and author of Flynn's Adventure in Bombland, The Order of Mazes & Maze Death Rally-X. Check them out at http://tomdalby.com
Dr beep
Manic Miner
Posts: 381
Joined: Mon Oct 01, 2018 8:53 pm

Re: Game of Life sizecoding contest

Post by Dr beep »

You can even start with an empty screen running if that is shorter code.

There is no rule for a startpattern nor a start in the editor.
User avatar
Morkin
Bugaboo
Posts: 3277
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

Re: Game of Life sizecoding contest

Post by Morkin »

Mpk wrote: Mon Dec 04, 2023 10:40 pm I reckon about 20k just for the spinner.

Image
This was basically my exposure to 'Game of Life' as a kid. Even after the Horizons tape surfaced.

I found it confusing because I'm sure the concept appeared multiple times in Speccy programs (e.g. BASIC type-ins) - people used to talk about it like it was something that everyone would've heard of, but I hadn't a clue what it was. Did they used to teach this sort of thing in school in the 60s or something?
My Speccy site: thirdharmoniser.com
User avatar
Mpk
Dynamite Dan
Posts: 1008
Joined: Tue Feb 09, 2021 8:10 am

Re: Game of Life sizecoding contest

Post by Mpk »

Morkin wrote: Wed Dec 06, 2023 11:03 am people used to talk about it like it was something that everyone would've heard of, but I hadn't a clue what it was. Did they used to teach this sort of thing in school in the 60s or something?
It's a geek/programmer thing, which I think would come up as college assignments and the like. It's an open-ended project with as many possible implementations as there are programmers ( this was before they were called engineers ), so popular with a certain set. See also Tower of Hanoi.
User avatar
TomD
Manic Miner
Posts: 379
Joined: Tue Nov 13, 2018 9:47 am
Location: Leeds UK
Contact:

Re: Game of Life sizecoding contest

Post by TomD »

Just sent my first entry, hopefully figured out the rules ok :-)
Retro enthusiast and author of Flynn's Adventure in Bombland, The Order of Mazes & Maze Death Rally-X. Check them out at http://tomdalby.com
Dr beep
Manic Miner
Posts: 381
Joined: Mon Oct 01, 2018 8:53 pm

Re: Game of Life sizecoding contest

Post by Dr beep »

I will try to take a look. I am on a roadtrip to Ireland but this evening I have some time on the ferry to check mail.
User avatar
+3code
Manic Miner
Posts: 434
Joined: Sat Mar 19, 2022 7:40 am

Re: Game of Life sizecoding contest

Post by +3code »

Have you thought about making a website or blog or something where we can see/test/play the participants?
User avatar
Bubu
Manic Miner
Posts: 542
Joined: Fri Apr 02, 2021 8:24 pm
Location: Spain

Re: Game of Life sizecoding contest

Post by Bubu »

I don't know if you already have had a look to this:

https://spectrumcomputing.co.uk/entry/2 ... Macro-Life

Image
If something works, don't touch it !!!! at all !!!
User avatar
Einar Saukas
Bugaboo
Posts: 3145
Joined: Wed Nov 15, 2017 2:48 pm

Re: Game of Life sizecoding contest

Post by Einar Saukas »

Dr beep wrote: Wed Dec 06, 2023 6:11 am You can even start with an empty screen running if that is shorter code.
This program perfectly implements all Game of Life rules when starting with an empty screen:

Code: Select all

10 CLS: PAUSE 0
User avatar
TomD
Manic Miner
Posts: 379
Joined: Tue Nov 13, 2018 9:47 am
Location: Leeds UK
Contact:

Re: Game of Life sizecoding contest

Post by TomD »

My current attempt running...

Image
Retro enthusiast and author of Flynn's Adventure in Bombland, The Order of Mazes & Maze Death Rally-X. Check them out at http://tomdalby.com
Post Reply