Threes
Moderator: Moderators
Threes
(Split out of 2048-thread)
Simple working version of Threes for unexpanded VIC, pure basic, now at least with some optimizations and eye candy
Should run with any memory configuration as it's only BASIC and PRINTs...
Move tiles with WASD or IJKM or cursor keys
Game in progress:
Final score (Scoreboard):
Final score (Playfield):
Program: http://www.stojalowski.de/files/Threes.prg
TODOs:
nothing - run out of space
As I could not find any "official" rules for playfield randomization and new tiles I simply invented my own rules. Seems to be a little bit harder than the original, but there are some nice scores possible.
Any comments are welcome
Edit: Finished work on this one, implemented a simple hiscore list and optimized stratup a little bit. After running 2 rounds there about 60 bytes free memory left...
Simple working version of Threes for unexpanded VIC, pure basic, now at least with some optimizations and eye candy
Should run with any memory configuration as it's only BASIC and PRINTs...
Move tiles with WASD or IJKM or cursor keys
Game in progress:
Final score (Scoreboard):
Final score (Playfield):
Program: http://www.stojalowski.de/files/Threes.prg
TODOs:
nothing - run out of space
As I could not find any "official" rules for playfield randomization and new tiles I simply invented my own rules. Seems to be a little bit harder than the original, but there are some nice scores possible.
Any comments are welcome
Edit: Finished work on this one, implemented a simple hiscore list and optimized stratup a little bit. After running 2 rounds there about 60 bytes free memory left...
Re: WIP: Threes
Working like a charm, after some rounds here's my best score so far:
At the beginning of this project I was a little bit worried about the more comfy speed of the VIC version, but now I'm quite used to the pacing. This leads to some more thinking before shifting the board mindlessly around
At the beginning of this project I was a little bit worried about the more comfy speed of the VIC version, but now I'm quite used to the pacing. This leads to some more thinking before shifting the board mindlessly around
-
- Vic 20 Devotee
- Posts: 247
- Joined: Sat Jun 30, 2007 5:48 am
Re: WIP: Threes
Hi,
what are the rules on this game ? (translate/say it also in german please )
what are the rules on this game ? (translate/say it also in german please )
eCC-Imagepack-Designer
Done: Vic20, N64, Philips VG-5000-G7000-G7400, SordM5, Amstrad GX4000
Progress: Atari 8bit, Enterprise 64/128, Dosbox
Done: Vic20, N64, Philips VG-5000-G7000-G7400, SordM5, Amstrad GX4000
Progress: Atari 8bit, Enterprise 64/128, Dosbox
Re: WIP: Threes
You can shift the playfield left/right/up/down. If numbers collide they combine if they are
a) a 1 and a 2 giving a 3 or
b) two identical numbers 3 and above resulting in the sum of them, e.g. 3 and 3 giving 6, 24 and 24 giving 48 etc.
Each move a new number will be shifted in.
There's more, but you will figure it out when playing, especially when which numbers combine and where and which numbers will be shifted in
German:
Du kannst das Spielfeld links/rechts/hoch/runter schieben. Wenn zwei Zahlen aufeinandertreffen werden sie kombiniert, wenn
a) es eine 1 und eine 2 ist, das wird dann eine 3 oder
b) wenn es zwei identische Zahlen größer gleich 3 sind, dann ergeben sie die Summe, d.h. 3 und 3 ergeben 6, 24 und 24 ergeben 48 usw.
Bei jedem Zug wird eine neue Zahl ins Spielfeld geschoben.
Es gibt noch mehr Regeln, aber die findest Du beim Spielen raus, besonders, wann welche Zahlen nun tatsächlich kombiniert werden und wo und welche Zahlen nachgeschoben werden
a) a 1 and a 2 giving a 3 or
b) two identical numbers 3 and above resulting in the sum of them, e.g. 3 and 3 giving 6, 24 and 24 giving 48 etc.
Each move a new number will be shifted in.
There's more, but you will figure it out when playing, especially when which numbers combine and where and which numbers will be shifted in
German:
Du kannst das Spielfeld links/rechts/hoch/runter schieben. Wenn zwei Zahlen aufeinandertreffen werden sie kombiniert, wenn
a) es eine 1 und eine 2 ist, das wird dann eine 3 oder
b) wenn es zwei identische Zahlen größer gleich 3 sind, dann ergeben sie die Summe, d.h. 3 und 3 ergeben 6, 24 und 24 ergeben 48 usw.
Bei jedem Zug wird eine neue Zahl ins Spielfeld geschoben.
Es gibt noch mehr Regeln, aber die findest Du beim Spielen raus, besonders, wann welche Zahlen nun tatsächlich kombiniert werden und wo und welche Zahlen nachgeschoben werden
-
- Vic 20 Devotee
- Posts: 247
- Joined: Sat Jun 30, 2007 5:48 am
Re: WIP: Threes
Thanks for the Info !
I'll give it a try.
Don't forget to post, when you have finished the developement.
So i can add this to TOSEC and FE3-Card Collection
I'll give it a try.
Don't forget to post, when you have finished the developement.
So i can add this to TOSEC and FE3-Card Collection
Re: Threes
Finished, added a simple hiscore list and made some final optimizations on the starting grid.
No more space left, had a lot of "out of memory" errors during implementation, hopefully now it's on the right edge of the memory cliff
After playing 2 rounds I had 61 bytes left which seems to be as low as it can go without the interpreter to complain about memory.
No more space left, had a lot of "out of memory" errors during implementation, hopefully now it's on the right edge of the memory cliff
After playing 2 rounds I had 61 bytes left which seems to be as low as it can go without the interpreter to complain about memory.
-
- Vic 20 Devotee
- Posts: 247
- Joined: Sat Jun 30, 2007 5:48 am
Re: Threes
O.K. Thank You
One question : For TOSEC-Naming. Should i use your Nick- or your Realname ?
If realname you can send me a PM here or over at Forum64.
One question : For TOSEC-Naming. Should i use your Nick- or your Realname ?
If realname you can send me a PM here or over at Forum64.
eCC-Imagepack-Designer
Done: Vic20, N64, Philips VG-5000-G7000-G7400, SordM5, Amstrad GX4000
Progress: Atari 8bit, Enterprise 64/128, Dosbox
Done: Vic20, N64, Philips VG-5000-G7000-G7400, SordM5, Amstrad GX4000
Progress: Atari 8bit, Enterprise 64/128, Dosbox
-
- Vic 20 Afficionado
- Posts: 352
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
Re: Threes
Hello Schlowski,
I have optimized the Threes game in WimBasic. I managed to bring it down to less than 2500 bytes (and less than 70 program lines), using not only the features that WimBasic offers (like SWAP and INSTR) but also some standard Basic memory saving techniques. Bringing all variables back to one letter instead of two is one of them.
A nice one that I found is your use of: int(3^(log(X)/log(2)). In this formula X and 3 are commutative, so that it can be written as int(X^(log(3)/log(2)).
You can isolate the constant factor of log(3)/log(2), so that it comes down to int(X^P). In this formula, when X is zero, the result is zero (your formula bounces on LOG(0)).
Hence you can take out the preceding IF X=0 condition to make the rest of the code generic .
Another one is where you check one cell for the value of 1 and the adjacent for the value of 2, while on the following line you check for the values 2 and 1 respectively, and the clauses in both lines are the same. Both lines can be taken together by multiplying both cells and compare the result to 2.
Regards,
Wim.
I have optimized the Threes game in WimBasic. I managed to bring it down to less than 2500 bytes (and less than 70 program lines), using not only the features that WimBasic offers (like SWAP and INSTR) but also some standard Basic memory saving techniques. Bringing all variables back to one letter instead of two is one of them.
A nice one that I found is your use of: int(3^(log(X)/log(2)). In this formula X and 3 are commutative, so that it can be written as int(X^(log(3)/log(2)).
You can isolate the constant factor of log(3)/log(2), so that it comes down to int(X^P). In this formula, when X is zero, the result is zero (your formula bounces on LOG(0)).
Hence you can take out the preceding IF X=0 condition to make the rest of the code generic .
Another one is where you check one cell for the value of 1 and the adjacent for the value of 2, while on the following line you check for the values 2 and 1 respectively, and the clauses in both lines are the same. Both lines can be taken together by multiplying both cells and compare the result to 2.
Regards,
Wim.
Last edited by wimoos on Mon Nov 24, 2014 8:08 am, edited 1 time in total.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
Re: Threes
Hi Wim,
nice work on math optimizing
Regards
Schlowski
nice work on math optimizing
That one is so obvious, thanks for pointing out, I don't know how I could have missed it.Another one is where you check one cell for the value of 1 and the adjacent for the value of 2, while on the following line you check for the values 2 and 1 respectively, and the clauses in both lines are the same. Both lines can be taken together by multiplying both cells and compare the result to 2.
Regards
Schlowski
-
- Vic 20 Afficionado
- Posts: 352
- Joined: Tue Apr 14, 2009 8:15 am
- Website: http://wimbasic.webs.com
- Location: Netherlands
- Occupation: farmer
Re: Threes
Hello Schlowski,
I brought it down further (in WimBasic of course ) to 53 lines and 2274 bytes.
An interesting technique I now used (that can also be done in CBM basic) is redefining functions. I applied that to the display routine, where during play the P% matrix is referenced, and variable colors.
During game result the W% matrix is referenced and one fixed color.
I also defined a function for calculating the next (random) value. For this you need an extension like WimBasic:
And I used PRINT USING to build up the field on the screen without the hassle of RIGHT$(STR$()),4) etcetera. It gives a more fluent result.
Regards,
Wimoos.
I brought it down further (in WimBasic of course ) to 53 lines and 2274 bytes.
An interesting technique I now used (that can also be done in CBM basic) is redefining functions. I applied that to the display routine, where during play the P% matrix is referenced, and variable colors.
Code: Select all
DEF FNC(X)=-3*(3<X)-X*(X<=3) (or =MIN(X,3))
DEF FNV(I)=P%(X,Y)
Code: Select all
DEF FNC(X)=1
DEF FNV(I)=W%(X,Y)
Code: Select all
DEF FNB(X)=B%(RND(MIN(X,MAX(X*ROUND(RND(1)),3))))
Regards,
Wimoos.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
Re: Threes
Hi Wimoos,
nice little additions, especially the trick with redefining functions. It never occurred to me that this was even possible, I think that is a result of years using compilers which are more static in that respect
I'm a little bit in hibbernation regarding the good old VIC right now, but when the time comes and my interest in VIC computing rises again I will definately have a closer look on WimBasic. You made a great enhancement to the basic (as in simple) interpreter!
Regards
Schlowski
nice little additions, especially the trick with redefining functions. It never occurred to me that this was even possible, I think that is a result of years using compilers which are more static in that respect
I'm a little bit in hibbernation regarding the good old VIC right now, but when the time comes and my interest in VIC computing rises again I will definately have a closer look on WimBasic. You made a great enhancement to the basic (as in simple) interpreter!
Regards
Schlowski