Skip to content
Sign upLog in
← Back to Community

2048 Game and Bot

Profile icon
eco27Hacker

2048 Game and Bot

Hello!
I have made a working 2048 game and a bot to play 2048.

The game works like a normal 2048 game, except there are no fancy animations because the bot runs too fast for the animations to look cool.

Activate the bot in the bot config tab. There are three options:

  1. Random Moves: The bot chooses random moves until the game is over.

  2. Random Bot: Random move simluation strategy. That is, for every starting move it simulates 30 games up to 60 moves in which it plays random moves and uses the starting move that has the best result.

  3. Minimax search: For the current state, goes through every possible move and for those moves goes through every possible tile spawn location up to a max depth of 5 because the branching factor is very high. Uses heuristics for number of empty tiles, monotonicity (row either increasing or decreasing), large tiles near the edge, smoothness (similarities in tile values close together for merge potential), and tiles merged.

I spent a long time working on this project. Unfortunately, none of the bot methods work spectacularly. I might improve upon it in the future by adding better heuristics or using a better algorithm. Comment any suggestions you have!

Voters
Profile icon
Noobhacker70156
Profile icon
DesonMaquilang
Profile icon
DamienCochran1
Profile icon
PYer
Profile icon
leemlam
Profile icon
GaussInTheHauss
Profile icon
DinaMerali
Profile icon
BubbleNugget
Profile icon
ArthurWu
Profile icon
Fleqs
Comments
hotnewtop
Profile icon
[deleted]

image

Profile icon
[deleted]

@MrEconomical
delet the children.
yes.

Profile icon
ColleagueRiley

This reminds me of code bullet's AI https://www.youtube.com/watch?v=1g1HCYTX3Rg

Profile icon
DarshanRajpara

I think I've noticed a trend with his repls.....

They're always beautiful, better than I can do, even with python, my favorite language.

Profile icon
LittleNomster

Love it! Could be smoother movements though.

Profile icon
JohnStarrs

I wanna learn html css and js now if you can do cool stuff like this
absolutely amazing

Profile icon
LordoftheString

this is so cool! nice job on the graphics. just like the real game!

Profile icon
KellerWorthen

this is the best version of 2048 i have seen

Profile icon
eco27

@KellerWorthen
no fancy animations tho

Profile icon
ReubenBakas

i take that back
it took long but it did

Profile icon
ReubenBakas

doesnt work

Profile icon
TylerBernardo

This is amazing!

Profile icon
MrYeeter

cooool

Profile icon
mwilki7

what on earth is that lookup table

Profile icon
mwilki7

@MrEconomical

I see, that makes sense
im just shocked at the size because im a lazy programmer