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.

code:

k=2^13::s::for a=0,k do n=0 for x=0,8 do n+=peek(k*3+a+x/3+x%3*64-65)end 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:

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 o,n=k*3+a,0 for x=0,8 do if(peek(o+x/3-1+(x%3-1)*64)>0)n+=1 end poke(a,(n==3 or n==4 and peek(o)>0) and 51 or 0)end memcpy(k*3,0,k)goto s |

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 n+=p(k*6+a+x/3+x%3*64-65) end poke(a,n==3 and 1 or n==2 and p(a))end memcpy(k*6,0,k)goto s |

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 n+=p(k*6+a+x/3+x%3*64-65) end 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?

[Please log in to post a comment]