POV-Ray : Newsgroups : povray.binaries.images : 2048 game rendered with POVRay Server Time
8 Jul 2024 06:08:11 EDT (-0400)
  2048 game rendered with POVRay (Message 4 to 13 of 13)  
<<< Previous 3 Messages Goto Initial 10 Messages
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

From: David Buck
Subject: Re: 2048 game rendered with POVRay
Date: 31 Jul 2014 17:15:38
Message: <53dab1fa$1@news.povray.org>
On 2014-07-31 9:04 AM, scott wrote:
>> 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" :-)

Indeed.  I hang my head in shame.  :-(

(I did get it right on the second occurrence of the number though)

A hex version of 2048 would be delightfully geeky - especially of the 
tiles were labeled 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, 0x100, etc.

David


Post a reply to this message

From: Jim Henderson
Subject: Re: 2048 game rendered with POVRay
Date: 3 Aug 2014 18:13:49
Message: <53deb41d$1@news.povray.org>
On Wed, 30 Jul 2014 08:34:57 +0100, scott wrote:

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

16384, naturally. :)

I found an Android version that let me fiddle around until I had filled 
the grid to the maximum possible value - and the top end title showed a 
value of 131072.  I forget what the score was, but it isn't possible to 
go higher. :)

Jim



-- 
"I learned long ago, never to wrestle with a pig. You get dirty, and 
besides, the pig likes it." - George Bernard Shaw


Post a reply to this message

From: JPeak
Subject: Re: 2048 game rendered with POVRay
Date: 17 Apr 2015 20:50:03
Message: <web.5531a980b35468c8aa32923b0@news.povray.org>
David Buck <dav### [at] simberoncom> 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 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
Hi John I am interested in looking at the source code for this.  I really want
to learn how to do this.  My email is jpe### [at] gmailcom Thanks!


Post a reply to this message

<<< Previous 3 Messages Goto Initial 10 Messages

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