flat assembler
Message board for the users of flat assembler.

flat assembler > Heap > 2048

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15870
Location: 162173 Ryugu
Tyler wrote:
Revolution, does a screenshot with a previous highscore (the number in the bottom right) count?
No. I saw posted the block value of 131072 (2^17).
Post 16 Aug 2014, 07:12
View user's profile Send private message Visit poster's website Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 7333
Location: ˛                              ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣ Posts: 6699
after a few months, i got 125620 score =)
i should get higher scores if not few stupid mistakes....


Description:
Filesize: 21.31 KB
Viewed: 1049 Time(s)

2048.png


Post 28 Mar 2015, 14:26
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 7333
Location: ˛                              ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣ Posts: 6699
updating my new score =)

Image
Post 21 Apr 2015, 20:48
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1240
Location: Icarian Sea
Nice puzzle. I have not yet managed to reach 2048 but I am close, i just need more practice Smile

Here is a console version of the 2048 game for my toy language. Translation of: C++.

Code:
rem 2048 Game rem Hobby Basic Sample rem Introducing user-defined functions (HB version 0.96) rem https://rosettacode.org/wiki/2048 title "2048 Game in Hobby Basic" screen 80,30 cursor 0,0 color 0,7 UP=38 DOWN=40 LEFT=37 RIGHT=39 dim board[4,4] dim blocked[4,4] path$="2048.txt" if SIZE(path$)=-1 then s$="0":file path$,s$,0 file path$,best$,1 best$=TRIM(best$) delay=10 start# done=0 score=0 moved=1 cls:at 0,0,"SCORE: BEST: " at 0,2,"Join the numbers and get to the 2048 tile!" at 0,22,"Use the arrow keys to move the tiles." at 0,23,"Press R to restart, Esc to quit." for y=0 to 3 for x=0 to 3 board[x,y]=0 blocked[x,y]=0 next x next y addTile() do if moved then addTile() drawBoard() if done then break waitKey() until done if score>VAL(best$) best$=STR(score) file path$,best$,0 endif if done=27 then end if done='R' then done=0:goto start locate 0,24:print "No more moves." if isWinner() then print "You''ve made it!" else print "You lose!" @@# inkey:k=V0&0x5F if k='R' then goto start if k<>27 then goto @b end sub drawBoard() local x,y at 7,0,score at 22,0,best$ for y=0 to 3 for x=0 to 3 v=board[x,y]:if ~v then i=1 else i=getColor(v) color i,0:paint 2+(x*7),5+(y*4),6,3,0x20,1 if i>1 then at 2+(x*7),6+(y*4),PAD(STR(v),' ',5) color 0,7 next x next y ends sub waitKey() local x,y,k moved=0 inkey:k=V0&0x5F if k=27 or k='R' then done=k:rets k=V2:if k>36 and k<41 then movDir(k) for y=0 to 3 for x=0 to 3 blocked[x,y]=0 next x next y ends sub addTile() local x,y,a,b for y=0 to 3 for x=0 to 3 if ~board[x,y] do:a=RND(4):b=RND(4):until ~board[a,b] if RND(100)>89 then board[a,b]=4 else board[a,b]=2 if canMove() then rets endif next x next y done=1 ends sub canMove() local x,y for y=0 to 3 for x=0 to 3 if ~board[x,y] then rets 1 next x next y for y=0 to 3 for x=0 to 3 if testAdd(x+1,y,board[x,y]) then rets 1 if testAdd(x-1,y,board[x,y]) then rets 1 if testAdd(x,y+1,board[x,y]) then rets 1 if testAdd(x,y-1,board[x,y]) then rets 1 next x next y rets 0 ends sub testAdd(x,y,v) if (x<0 or x>3 or y<0 or y>3) then rets 0 if board[x,y]=v then rets 1 rets 0 ends sub moveVert(x,y,d) if (board[x,y+d] and board[x,y+d]=board[x,y] and ~blocked[x,y] and ~blocked[x,y+d]) board[x,y]=0 board[x,y+d]=board[x,y+d]*2 score=score+board[x,y+d] blocked[x,y+d]=1 moved=1 elseif ~board[x,y+d] and board[x,y] board[x,y+d]=board[x,y] board[x,y]=0 moved=1 endif if d>0 if (y+d<3) then drawBoard():wait delay:moveVert(x,y+d,1) else if (y+d>0) then drawBoard():wait delay:moveVert(x,y+d,-1) endif ends sub moveHori(x,y,d) if (board[x+d,y] and board[x+d,y]=board[x,y] and ~blocked[x,y] and ~blocked[x+d,y]) board[x,y]=0 board[x+d,y]=board[x+d,y]*2 score=score+board[x+d,y] blocked[x+d,y]=1 moved=1 elseif ~board[x+d,y] and board[x,y] board[x+d,y]=board[x,y] board[x,y]=0 moved=1 endif if d>0 if (x+d<3) then drawBoard():wait delay:moveHori(x+d,y,1) else if (x+d>0) then drawBoard():wait delay:moveHori(x+d,y,-1) endif ends sub movDir(d) local x,y if d=UP for x=0 to 3 y=1 while y<4 if board[x,y] then moveVert(x,y,-1) y=y+1 endw next x elseif d=DOWN for x=0 to 3 y=2 while y>=0 if board[x,y] then moveVert(x,y,1) y=y-1 endw next x elseif d=LEFT for y=0 to 3 x=1 while x<4 if board[x,y] then moveHori(x,y,-1) x=x+1 endw next y elseif d=RIGHT for y=0 to 3 x=2 while x>=0 if board[x,y] then moveHori(x,y,1) x=x-1 endw next y endif ends sub isWinner() for y=0 to 3 for x=0 to 3 if board[x,y] >= 2048 then rets 1 next x next y rets 0 ends sub getColor(c) i=0 while c>2 c=c>>1 i=i+1:if i>6 then i=0 endw rets i+9 ends


Image


Last edited by Picnic on 15 May 2018, 18:50; edited 2 times in total
Post 06 Feb 2018, 19:52
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 7333
Location: ˛                              ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣ Posts: 6699
hi Picnic,
somehow this game doesnt made into my new phone,

nice syntax,
Post 08 Feb 2018, 18:59
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 2004-2018, Tomasz Grysztar.

Powered by rwasa.