Log In  

Cart #game_of_life_tweetcart-0 | 2023-08-25 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

Ok with a bunch of help from LRP I have an entry that works in 138 characters! I'm so happy I managed this. I didn't think I'd actually be able to compress it this small. It was a lot of fun to do.


k=2^13::s::for a=0,k do
n=0 for x=0,8 do
poke(a,n==12 and 4 or n==16 and peek(a))end
memcpy(k*3,0,k)goto s

Original post:
Was trying to make Conway's Game of Life into a #tweetjam entry but wasn't able to get it below 175 characters. It reads the screen to do the simulation so while it will always display the same simulation from the BBS you can do whatever input data you want if you download the cart by having whatever you like on screen when you hit run.

If anyone can spot a way to compress it more please share!

version 1:

version 2:

version 3:

P#39440 2017-04-09 05:30 ( Edited 2023-08-25 16:01)

This is really impressive! I spotted a couple small tweaks, but unfortunately nothing big enough to bring you under the limit.

  • peek() always returns a positive number. You can use > instead of !=.
  • 24576 is k*3, so it's shorter to just use k*3 instead of assigning it to a variable.
  • peek() will automatically convert its argument to an integer. You can skip flr() on x/3.
  • Dark green (color 3) is, in my opinion, a pretty good color for this, and happens to be two digits instead of 3.

161 chars:

k=8192::s::for a=0,k do
for x=0,8 do
poke(a,(n==3 or n==4 and peek(o)>0) and 51 or 0)end
memcpy(k*3,0,k)goto s
P#39451 2017-04-09 13:12 ( Edited 2017-04-09 17:18)

Thanks LRP! With those and a few optimisations I spotted myself I have it down to 158 characters.

P#39453 2017-04-09 13:43 ( Edited 2017-04-09 17:43)

It's so close. I technically get it down to 140, but it doesn't work from the startup screen, so it doesn't work as a tweetjam. You have to provide a starting seed by setting some screen memory to 1. For example, run memset(0x6110,1,40) before running the program. Also it only works in half the screen and only works with color 1.

k,p=4^6,peek::s::for a=0,k do
n=-p(a)for x=0,8 do
poke(a,n==3 and 1 or n==2 and p(a))end
memcpy(k*6,0,k)goto s
P#39468 2017-04-09 21:13 ( Edited 2017-04-10 01:13)

Ah LRP thank you so much! I could kick myself because some of the stuff you've contributed is so obvious in hindsight. Others are quirks I didn't know about. It's quite interesting that poking a value with false actually works, I would have thought it would throw an error!

With your help I've managed to get it over the line to 139 characters!

k,p=4^6,peek::s::for a=0,k do
n=0 for x=0,8 do
poke(a,n==12 and 4 or n==16 and p(a))end
memcpy(k*6,0,k)goto s

Do you have a twitter account so I can credit you when I tweet it out?

P#39483 2017-04-10 06:13 ( Edited 2017-04-10 10:13)

Wow! Great job! I'm glad you were able to figure out that last piece. This makes a really nice tweetjam entry.

I don't have a twitter account, so don't worry about crediting.

P#39523 2017-04-10 20:48 ( Edited 2017-04-11 00:48)

Congratulations- quite an achievement!

P#133715 2023-08-29 20:23

[Please log in to post a comment]