Gym 2048
This package implements the classic grid game 2048 for OpenAI gym environment.
Install
pip install gym-2048
Environment(s)
The package currently contains two environments
Tiny2048-v0: A 2 x 2 grid game.
2048-v0: The standard 4 x 4 grid game.
Attributes
Observation: All observations are n x n numpy arrays representing the grid. The array is 0 for empty locations and numbered 2, 4, 8, ... wherever the tiles are placed.
- Actions: There are four actions defined by integers.
LEFT = 0
UP = 1
RIGHT = 2
DOWN = 3
Reward: Reward is the total score obtained by merging any potential tiles for a given action. Score obtained by merging two tiles is simply the sum of values of those two tiles.
Rendering
Currently only basic print rendering (mode='human') is supported. Graphic rendering support is coming soon.
Usage
Here is a sample rollout of the game which follows the same API as OpenAI gym.Env.
import gym_2048
import gym
if __name__ == '__main__':
env = gym.make('2048-v0')
env.seed(42)
env.reset()
env.render()
done = False
moves = 0
while not done:
action = env.np_random.choice(range(4), 1).item()
next_state, reward, done, info = env.step(action)
moves += 1
print('Next Action: "{}"\n\nReward: {}'.format(
gym_2048.Base2048Env.ACTION_STRING[action], reward))
env.render()
print('\nTotal Moves: {}'.format(moves))
NOTE: Top level import gym_2048 is needed to ensure registration with Gym.
Metadata
Release files for gym-2048 0.2.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gym-2048-0.2.6.tar.gz | 4.6 kB | Without provenance | Details for gym-2048-0.2.6.tar.gz |
Release files / gym-2048-0.2.6.tar.gz
| Download URL | gym-2048-0.2.6.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
13b15d0cd5ee556df33eab6861bfa94ae88aeb063fc1fd6d3e7fee230a0fa662
|
|
BLAKE2b-256 checksum How to use checksums |
4747a1f06f3a6a05b78ffee842a7cd6f6734f97b0c3600f69df7654c232f0adc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3
|
Security for gym-2048 0.2.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.