.. _f-cp2048: module ``td_1a.cp2048`` ======================= .. inheritance-diagram:: ensae_teaching_cs.td_1a.cp2048 Short summary +++++++++++++ module ``ensae_teaching_cs.td_1a.cp2048`` Simple strategy for :epkg:`2048`. :githublink:`%|py|5` Classes +++++++ +-------------------------------------------------------------------------------+---------------------------------------------------------------+ | class | truncated documentation | +===============================================================================+===============================================================+ | :class:`Game2048 ` | Implements the logic of the game :epkg:`2048`. | +-------------------------------------------------------------------------------+---------------------------------------------------------------+ | :class:`Game2048State ` | To store additional information while guessing the best move. | +-------------------------------------------------------------------------------+---------------------------------------------------------------+ | :class:`GameOverException ` | Raised when the game is over. | +-------------------------------------------------------------------------------+---------------------------------------------------------------+ Functions +++++++++ +------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+ | function | truncated documentation | +==============================================================================+==========================================================================================================================+ | :func:`evaluate_strategy ` | Applies method *best_move* until gameover starting from the current position. Repeats *ntries* times and the maximum ... | +------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+ Static Methods ++++++++++++++ +-----------------------------------------------------------------------------+---------------------------------------------------------------------------------+ | staticmethod | truncated documentation | +=============================================================================+=================================================================================+ | :meth:`process_line ` | Moves numbers inside a vector whether this vector represents a row or a column. | +-----------------------------------------------------------------------------+---------------------------------------------------------------------------------+ Methods +++++++ +-----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | method | truncated documentation | +=============================================================================+================================================================================================================+ | :py:meth:`__init__ ` | | +-----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :py:meth:`__init__ ` | | +-----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :py:meth:`__str__ ` | Displays the game as a string. | +-----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`best_move ` | Selects the best move knowing the current game. By default, selects a random direction. This function must ... | +-----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`copy ` | Makes a copy of the game. | +-----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`gameover ` | Checks the game is over or not. Returns True in that case. | +-----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`next_turn ` | Adds a number in the game. | +-----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`play ` | Updates the game after a direction was chosen. | +-----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ | :meth:`score ` | Returns the maximum values. | +-----------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------+ Documentation +++++++++++++ .. automodule:: ensae_teaching_cs.td_1a.cp2048 :members: :special-members: __init__ :show-inheritance: