Questions tagged [2048]

2048 is an open source tile-based puzzle game. Questions with this tag should be either about implementing the game or implementing solving strategies. Ask on https://gamedev.stackexchange.com/ if it's a specific game development issue. Ask on https://gaming.stackexchange.com/ if it is about playing the game.

2048 is an open-source app created by Gabriele Cirulli, an Italian developer, as a clone of 1024. The game is a 4x4 grid that starts out with two tiles. Each tile is either a 2 or a 4. When the player swipes either up, down, left, or right, all of the tiles move in that direction and a new tile appears in a random spot. When two tiles of the same number are pushed together, they merge and form a new tile with twice the value. The object of the game is to form at least one tile with a value of 2048.

Questions with this tag should be either about implementing the game or implementing solving strategies. Ask on https://gamedev.stackexchange.com/ if it's a specific game development issue. Ask on https://gaming.stackexchange.com/ if it is about playing the game.

62 questions
1
vote
1 answer

UCB formula for monte carlo tree search when score is between 0 and n

I'm implementing an AI that plays 2048 using monte carlo tree search. According to wikipedia https://en.wikipedia.org/wiki/Monte_Carlo_tree_search and all other sources that I have checked in the expansion step you should use the UCB formula in…
1
vote
0 answers

2048 merge methods assistance

I'm trying to figure out how to work the shift right,up,down,left methods. I feel like my solution should work so idk if I'm calling it wrong or something. Main import java.util.Random; import java.util.Scanner; import java.util.*; public class…
scuttles
  • 11
  • 1
1
vote
1 answer

Making a java 2048 game, upon sliding it goes through the loop more times than it should and hits tests/alters numbers already altered

So I have a solid slide function, the problem is (which is very hard to explain!) it goes through all the possibilities including spaces in the 2d array that have already been added together: say there is a setup like this: 4,4,8,2 ---after one…
1
vote
2 answers

Issue assigning two self variables to each other in python

I'm working on building a 2048 game and trying to build a stopping condition. But facing some issues with two variables. The idea I tried was simple - stop the execution when two matrix values (one that holds the current 4x4 board values and another…
codegooner
  • 23
  • 4
1
vote
0 answers

python 2048 implementation

I was reading a code of 2048 game and came across the following snippet def up(game): print("up") # return matrix after shifting up game=transpose(game) game,done=cover_up(game) temp=merge(game) game=temp[0] done=done or…
Sagar Moghe
  • 67
  • 1
  • 7
1
vote
2 answers

undo operation implementation in 2048 game

I've implemented 2048 game in C++, github link : 2048 For implementing undo operation, i.e. going back to previous state of game, I'm maintaining a matrix for previous board configuration, but if I'm allowing many undo operations consecutively, I…
Mandeep Singh
  • 308
  • 2
  • 5
  • 18
1
vote
0 answers

2048 AI: Expectimax better than Minimax?

I am building a 2048 AI, and it is leading to a rather peculiar observation (peculiar enough to me). The optimizations are not up to the mark right now (coupled with the fact that the code is written in python), which is letting me reach till only a…
Tanmay Garg
  • 801
  • 11
  • 20
1
vote
1 answer

How to applied alpha-beta pruning in implementing 2048 AI agent with minimax algorithm?

I'm developing an AI for 2048, and am about to apply minimax algorithm. However, the search tree of 2048 is actually like a Expectiminimax tree without Min role. I wonder if I don't have Min role, how could I apply alpha-beta pruning in practice? If…
1
vote
2 answers

Creating an array of objects in javascript, then fetching properties

so I'm trying to recreate 2048 in javascript right now and having some trouble. Basically, my idea was to create the grid as an array of 16 objects that take coordinates and a boolean variable of whether it is filled with a tile or not. var…
tag00
  • 13
  • 2
0
votes
0 answers

The up/down keys are triggering an "unrefined" error

I am tring to make an ai to complete the 2048 game. I have the game made, but I'm on the first step of adding the ai in JavaScript and I've run into a problem. The game looks OK before anything is clicked, the left, and right keys work fine but the…
0
votes
1 answer

How to structure a non-periodic task in pyRTOS?

I am working on a Realtime Computing project using pyRTOS to create the tasks and applying the RTOS concepts. My project is a version of the game 2048 to run on a physical touchboard. As part of the project requirements, we need to create tasks to…
0
votes
2 answers

2048 game on 1d list - why it works for some tests and not others?

Trying to implement the 2048 game in python, starting with a function that merges a 1d list . My code works for all but one test see below. I believe this is due to the code not processing consecutive duplicates but not sure of the best way to…
JoeP
  • 45
  • 8
0
votes
1 answer

Making a "2048 solitaire game" with F#: creating the functions for the implementation file (.fs file)

I am tasked with creating a version of the 2048 game. This version is on a 3x3 field, and uses colors (instead of numbers). The functions that I will need have already been given to me. Among these, I have to make a filter function, which I am…
0
votes
1 answer

Making a "2048 solitaire game" with F#: Creating a fsi file, fs file and fsx file

In your solution, you are to represent a board with its pieces as a list of pieces, where each piece has a color and a position. This is captured by the following type abbreviations: type pos = int * int // A 2-dimensional vector in board -…
0
votes
1 answer

How do I resolve this? TypeError: main..() missing 1 required positional argument: 'gamepanel'

I'm using tkinter to make 2048 game gui, I created this function control_game I want to have it such that anytime I click these keys (up, down, left, right) on my keyboard the control_game function should be called from my main function. But anytime…