Skip to content

BogdanCln/2048-monte-carlo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

2048 game - Monte Carlo simulations

Live - https://bogdancln.github.io/share/fmi/2048-monte-carlo/

won

1.

  • Get the current game state(4x4 array of values that are powers of 2)
  • IF game is not over(eg.: there is a null value in the array)
      THEN GO TO 2
    ELSE STOP EXECUTION
    

2.

  • Copy the current game state 4 times

  • On copy #1 execute move left

    FOR N times (N = iterations per move, variable that can be controller from the web page)
        Execute random moves until the game is over
    
  • Get the average final score of the N iterations for copy #1

  • On copy #2 execute move right

    FOR N times (N = iterations per move, variable that can be controller from the web page)
        Execute random moves until the game is over
    
  • Get the average final score of the N iterations for copy #2

  • On copy #3 execute move up

    FOR N times (N = iterations per move, variable that can be controller from the web page)
        Execute random moves until the game is over
    
  • Get the average final score of the N iterations for copy #3

  • On copy #4 execute move down

    FOR N times (N = iterations per move, variable that can be controller from the web page)
      Execute random moves until the game is over
    
  • Get the average final score of the N iterations for copy #4

  • Choose the move equivalent to the copy that made the highest average score

  • Execute that move on the actual game

  • Jump to 1

About

2048 game - Monte Carlo simulations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 51.5%
  • CSS 27.4%
  • SCSS 14.9%
  • HTML 5.8%
  • Ruby 0.4%