Skip to content

shuymst/gym-2048

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gym-2048

Gymnasium environment for the game 2048.

Installation

git clone [email protected]:shuymst/gym-2048.git
poetry add ./gym-2048 --without test

API

import gymnasium as gym
import gym_2048
import random

random.seed(42)

env = gym.make("TwentyFortyEight-v0")
observation, info = env.reset(seed=42)
while True:
    action = random.choice(info['legal actions'])
    observation, reward, terminated, truncated, info = env.step(action)

    if terminated or truncated:
        env.render()
        break
env.close()

"""
-----------------------------
|     2|    32|    16|     2|
-----------------------------
|    16|     2|   128|     4|
-----------------------------
|     8|    32|     4|     2|
-----------------------------
|     2|     8|    16|     4|
-----------------------------
score: 1168
"""

About

Gymnasium environment for the game 2048

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages