Log In  

3

Cart [#39505#] | Copy | Code | 2017-04-10 | Link
3

Ok with a bunch of help from LRP I have an entry that works in 139 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:

Cart [#39438#] | Copy | Code | 2017-04-09 | Link
3

version 2:
Cart [#39452#] | Copy | Code | 2017-04-09 | Link
3

version 3:
Cart [#39484#] | Copy | Code | 2017-04-10 | Link
3

game-of-life cellular-automaton tweetjam
P#39440 2017-04-09 05:30

::

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
P#39451 2017-04-09 13:12

::

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

::

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
P#39468 2017-04-09 21: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
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?

P#39483 2017-04-10 06: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

Log in to post a comment

user:
password:

New User | Account Help
:: New User
X
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2017-05-28 08:40 | 0.242s | 1835k | Q:34