POV-Ray : Newsgroups : povray.binaries.images : 2048 game rendered with POVRay Server Time
1 Nov 2024 00:25:06 EDT (-0400)
  2048 game rendered with POVRay (Message 1 to 10 of 13)  
Goto Latest 10 Messages Next 3 Messages >>>
From: David Buck
Subject: 2048 game rendered with POVRay
Date: 29 Jul 2014 21:06:29
Message: <53d84515@news.povray.org>
This picture is from a 2048 game I wrote in VisualWorks Smalltalk using 
POVRay to render the board and all the tiles.  POVRay rendered PNG files 
of the board and all tiles from 2 to 8196 which I then imported into the 
game as bitmaps.  The game is actually playable and the tiles slide into 
position with a small fireworks animation (using a 3D particle system) 
when they merge.  The text at the top for the score and messages like 
"You Won!" wasn't 3D rendered - it was just drawn as a standard text 
object.  The tile shadows are faked.  They are just a black shadow image 
rendered slightly below and to the right of a tile before the tile is 
drawn on top.  The Autoplay and Restart buttons were rendered directly 
onto the board using POVRay beveled text.  The values of the squares on 
this particular board were (obviously) manually constructed to show all 
tiles.  As you can imagine, it would be notoriously difficult to get 
this configuration with a real 2048 game.

The auto-play feature achieves the 2048 tile in about 50% of the games 
it plays and occasionally (once or twice every ten runs) achieves 4096. 
  I've never seen it get an 8192 tile.

I wrote this game as my entry in the Cincom Smalltalk 2048 contest but I 
plan to make a series of videos about how I wrote the game and rendered it.

For those interested in trying the program, you can get it from:

	http://www.simberon.com/downloads/Sim2048.exe

Note, this is a Windows executable file but you have my word that it 
doesn't contain any viruses or malware.

If you're interested in looking at the Smalltalk source code, drop me an 
e-mail and I can send you a link for it.

Questions and comments welcome
David (K) Buck


Post a reply to this message


Attachments:
Download 'alltiles.png' (1200 KB)

Preview of image 'alltiles.png'
alltiles.png


 

From: scott
Subject: Re: 2048 game rendered with POVRay
Date: 30 Jul 2014 03:34:57
Message: <53d8a021@news.povray.org>
> This picture is from a 2048 game I wrote in VisualWorks Smalltalk using
> POVRay to render the board and all the tiles.  POVRay rendered PNG files
> of the board and all tiles from 2 to 8196

What happens when you merge two 8192 tiles then? ;-)

> The auto-play feature achieves the 2048 tile in about 50% of the games
> it plays and occasionally (once or twice every ten runs) achieves 4096.
>   I've never seen it get an 8192 tile.
>
> I wrote this game as my entry in the Cincom Smalltalk 2048 contest but I
> plan to make a series of videos about how I wrote the game and rendered it.

I never considered writing an AI player for 2048, but it sounds fun.

What is the rule/algorithm for adding the new tile after each move? Is 
it just placed in a random empty cell? On my version (Android) most 
times I got a 2 but sometimes it gave me a 4.


Post a reply to this message

From: Bald Eagle
Subject: Re: 2048 game rendered with POVRay
Date: 30 Jul 2014 08:25:01
Message: <web.53d8e307b35468c85e7df57c0@news.povray.org>
http://en.wikipedia.org/wiki/2048_(video_game)


Looks very good - nice work!
I'd be interested to see how it was written, and what the AI logic is.
How does the game determine what direction to slide the tiles?  Generating the
highest value tile, or combining the most tiles? (I'm leaning toward the latter)

{Oh, how I wish people with your talent would write (or at least fix) some
worthwhile apps for MS's Surface RT.  That Windows Store is mostly a collection
of shamelessly plagiarized junk that doesn't work.  Heck, the Store app itself
doesn't even work right...}

Keep up the good work!  :)


Post a reply to this message

From: scott
Subject: Re: 2048 game rendered with POVRay
Date: 30 Jul 2014 11:54:30
Message: <53d91536$1@news.povray.org>
> http://en.wikipedia.org/wiki/2048_(video_game)

It's open source, so I can answer my own question, the value of the new 
tile that is randomly generated is chosen thus:

var value = Math.random() < 0.9 ? 2 : 4;

So it's a 90% chance of a 2, 10% chance of a 4. Interesting.

> Looks very good - nice work!
> I'd be interested to see how it was written, and what the AI logic is.
> How does the game determine what direction to slide the tiles?  Generating the
> highest value tile, or combining the most tiles? (I'm leaning toward the latter)

Yes I wondered that too, it looks like the answer lies in the "move" 
function of "game_manager.js", but I don't have time to try and 
understand it right now.


Post a reply to this message

From: David Buck
Subject: Re: 2048 game rendered with POVRay
Date: 30 Jul 2014 13:30:52
Message: <53d92bcc$1@news.povray.org>
On 2014-07-30 11:54 AM, scott wrote:>> 
http://en.wikipedia.org/wiki/2048_(video_game)
 >
 > It's open source, so I can answer my own question, the value of the new
 > tile that is randomly generated is chosen thus:
 >
 > var value = Math.random() < 0.9 ? 2 : 4;
 >
 > So it's a 90% chance of a 2, 10% chance of a 4. Interesting.

Yes, interesting indeed.  My implementation makes it a 50-50 chance of 
getting either a 2 or a 4.  Perhaps I should change my game to match.

 >
 >> Looks very good - nice work!
 >> I'd be interested to see how it was written, and what the AI logic is.
 >> How does the game determine what direction to slide the tiles?
 >> Generating the
 >> highest value tile, or combining the most tiles? (I'm leaning toward
 >> the latter)
 >
 > Yes I wondered that too, it looks like the answer lies in the "move"
 > function of "game_manager.js", but I don't have time to try and
 > understand it right now.
 >

I don't believe the open source implementation above includes a solver.

My algorithm is based on the one here:

http://2048strategy.com/2048-strategy/

This web page, however, doesn't include details on how to calculate 
monotonicity and smoothness.  In my implementation, monotonicity is 
weighted by the values of the cells and the smoothness uses a different 
algorithm.  It's pretty effective, though.

David Buck


Post a reply to this message

From: David Buck
Subject: Re: 2048 game rendered with POVRay
Date: 30 Jul 2014 13:31:26
Message: <53d92bee$1@news.povray.org>
On 2014-07-30 3:34 AM, scott wrote:
 >> This picture is from a 2048 game I wrote in VisualWorks Smalltalk using
 >> POVRay to render the board and all the tiles.  POVRay rendered PNG files
 >> of the board and all tiles from 2 to 8196
 >
 > What happens when you merge two 8192 tiles then?

Right now, the new square turns black .  I suppose I should fix that but 
it's not a big priority for me.

 >
 >> The auto-play feature achieves the 2048 tile in about 50% of the games
 >> it plays and occasionally (once or twice every ten runs) achieves 4096.
 >>   I've never seen it get an 8192 tile.
 >>
 >> I wrote this game as my entry in the Cincom Smalltalk 2048 contest but I
 >> plan to make a series of videos about how I wrote the game and
 >> rendered it.
 >
 > I never considered writing an AI player for 2048, but it sounds fun.
 >
 > What is the rule/algorithm for adding the new tile after each move? Is
 > it just placed in a random empty cell? On my version (Android) most
 > times I got a 2 but sometimes it gave me a 4.
 >

The game just picks a random empty cell and randomly puts a 2 or 4 there.

David


Post a reply to this message

From: Bald Eagle
Subject: Re: 2048 game rendered with POVRay
Date: 30 Jul 2014 16:05:01
Message: <web.53d94fd5b35468c85e7df57c0@news.povray.org>
It's weird how the binary summation seems so natural.  Maybe I just do WAY too
much computer stuff.

It would be interesting to see it redone in Hex...  :D


Post a reply to this message

From: David Buck
Subject: Re: 2048 game rendered with POVRay
Date: 30 Jul 2014 16:47:45
Message: <53d959f1@news.povray.org>
On 2014-07-30 11:54 AM, scott wrote:
>> http://en.wikipedia.org/wiki/2048_(video_game)
>
> It's open source, so I can answer my own question, the value of the new
> tile that is randomly generated is chosen thus:
>
> var value = Math.random() < 0.9 ? 2 : 4;
>
> So it's a 90% chance of a 2, 10% chance of a 4. Interesting.
>

Wow, that makes a huge difference to the game.  My solver now has an 80% 
success rate at reaching 2048.

David Buck


Post a reply to this message

From: scott
Subject: Re: 2048 game rendered with POVRay
Date: 31 Jul 2014 09:00:45
Message: <53da3dfd$1@news.povray.org>
>  >> Looks very good - nice work!
>  >> I'd be interested to see how it was written, and what the AI logic is.
>  >> How does the game determine what direction to slide the tiles?
>  >> Generating the
>  >> highest value tile, or combining the most tiles? (I'm leaning toward
>  >> the latter)
>  >
>  > Yes I wondered that too, it looks like the answer lies in the "move"
>  > function of "game_manager.js", but I don't have time to try and
>  > understand it right now.
>  >
>
> I don't believe the open source implementation above includes a solver.

Oh I misread Bald Eagle's comment - I thought he meant how does the game 
itself decide how to combine tile sequences like "2228" when you slide, 
do you end up with "_428" or "_248"? What if you swipe left instead?

> My algorithm is based on the one here:
>
> http://2048strategy.com/2048-strategy/

I think I would like to have a go at writing a solver based on my 
personal strategy for playing first, before being corrupted by superior 
methods that I would have never have though of ;-)


Post a reply to this message

From: scott
Subject: Re: 2048 game rendered with POVRay
Date: 31 Jul 2014 09:04:08
Message: <53da3ec8$1@news.povray.org>
> It's weird how the binary summation seems so natural.  Maybe I just do WAY too
> much computer stuff.

Indeed, or immediately I saw the "8196" in the OP and thought "that's a 
typo" :-)

> It would be interesting to see it redone in Hex...  :D

It would be quite boring though, more interesting would be base-9 or 
something...


Post a reply to this message

Goto Latest 10 Messages Next 3 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.