WHOT

Whot is an Engine that implements the game of Whot! Using this engine, you can build your own Whot! game servers and connect it to any frontend technology of your choice.

Note

This project is under active development.

Installation

The Engine is implemented in python, so to install it, you can use pip:

pip install whot

Once installed, you can start using the engine in your Python projects.

Usage

The engine provides simple set of APIs that corresponds to the actual Whot! game.

To start the game, import the Whot class

from whot import Whot

Once it is imported, create an instance of the class and start the game:

game = Whot()

To view the state of the game, use the game_state method of the class:

game.game_state()

The game_state method returns a dictionary that contains the current state of the game:

{
 'current_player': 'player_1',
 'pile_top': 13 CIRCLE,
 'player_1': [3 CIRCLE, 2 STAR, 8 CIRCLE, 5 CIRCLE],
 'player_2': [7 CIRCLE, 3 SQUARE, 11 CROSS, 8 STAR]
}

To view the state of the game use from a player’s perspective, use the view method:

game.view('player_2')

The code above views the game state from the perspective of player_2:

{
 'current_player': 'player_1',
 'pile_top': 13 CIRCLE,
 'player_1': 4,
 'player_2': [7 CIRCLE, 3 SQUARE, 11 CROSS, 8 STAR]
}

To play a card, use the play method. This method allows you to select which of the current player’s cards to play.

Player one, who is the current player, can play any of their cards provided it matches the suit or face of the pile card.

game.play(0)

If they don’t have a playable card, they can use the market method to draw a new card:

game.market()