semvec/pypi-packages huggingface dataset:
gym-2048 0.2.6
OpenAI Gym Environment for 2048
License: MIT

Gym 2048
=========

.. image:: https://travis-ci.com/activatedgeek/gym-2048.svg?branch=master
    :target: https://travis-ci.com/activatedgeek/gym-2048

.. image:: https://badge.fury.io/py/gym-2048.svg
    :target: https://pypi.org/project/gym-2048/

This package implements the classic grid game 2048
for OpenAI gym environment.

Install
--------

.. code:: shell

    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``.

.. code:: python

    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``.
mew 0.1.4
Python dataclass serializer/deserializer
License: MIT
Requires Python: >=3.6

Mew: python dataclass serializer/deserializer
=============================================
[![Build Status](https://travis-ci.org/cliffxuan/mew.svg?branch=master)](https://travis-ci.org/cliffxuan/mew)
[![Python Version Support](https://img.shields.io/pypi/pyversions/mew.svg)](https://img.shields.io/pypi/pyversions/mew.svg)
[![PyPI Version](https://badge.fury.io/py/mew.svg)](https://badge.fury.io/py/mew)
[![Coverage](https://img.shields.io/codeclimate/coverage/cliffxuan/mew.svg?style=flat)](https://codeclimate.com/github/cliffxuan/mew)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
![image](https://raw.githubusercontent.com/cliffxuan/mew/master/mew.jpg)

``` {.sourceCode .python}
from dataclasses import dataclass
from enum import Enum
from typing import List

import mew


class Type(Enum):
    normal = 'normal'
    electric = 'electric'
    fire = 'fire'
    fighting = 'fighting'
    water = 'water'
    psychic = 'psychic'


@mew.serializable
@dataclass
class Pokemon:
    name: str
    pokedex: int
    type: Type
    abilities: List[str]


>>> pikachu = Pokemon('Pikachu', 25, Type.electric, ['static', 'lightning rod'])

>>> pikachu
Pokemon(name='Pikachu', pokedex=25, type=<Type.electric: 'electric'>, abilities=['static', 'lightning rod'])

>>> pikachu.dumps()
'{"name": "Pikachu", "pokedex": 25, "type": "electric", "abilities": ["static", "lightning rod"]}'

>>> assert pikachu == Pokemon.loads(pikachu.dumps())
```