Closed Redpheonix024 closed 1 year ago
def convert_grid_to_64bit(grid): num_rows = len(grid) num_cols = len(grid[0]) result = 0
for row in range(num_rows):
for col in range(num_cols):
if grid[row][col]:
bit_position = row * num_cols + col
result |= 1 << bit_position
return result
@jishnu2000 The code is here: https://github.com/nneonneo/2048-ai/blob/f5797579369147248bec78cd6ae5f97ce6771c08/2048.py#L30
def to_c_board(m):
board = 0
i = 0
for row in m:
for c in row:
board |= int(c) << (4*i)
i += 1
return board
There are 16 grid cells, each of which occupy 4 bits in the 64-bit number.
thanks and how can we improve the ai highscorce i tested it every time it will get struck at 16000 tile with 4096 tile and the game will be over any way of improving the outcome and reach 32000 tiles consistently
That’s a bit of an open research problem :)
If you have any such ideas, feel free to submit an issue or pull request!
Sir, Can you please link the code for converting the grid into 64 bit varible