Skip to main content

C library for Othello game

Project description

OthelloC

Python library of C implementation of Othello

Usage

from othelloc import Othello
game = Othello()
game.print_board()
cur_player = game.cur_player()
game.make_move(cur_player, game.get_possible_moves(cur_player)[0])
game.print_board()

Installation

pip install othelloc

Classes

Othello()

The base game class, which contains the board and the current player.

Methods

get_starting_board()

Returns the starting board position.

copy()

Returns a deep copy of the current game.

make_move(player, move)

Makes a move for the player. The move is a tuple of (row, col).

is_game_over()

Returns 1 if the game is over, otherwise 0.

get_winner()

Returns the winner of the game, or 0 if the game is not over.

get_possible_moves(player)

Returns a list of possible moves for the player. The moves are tuples of (row, col).

get_score()

Returns the score of the game. The score is a tuple of (black, white).

tiles_to_flip(player, move)

Returns a list of tiles that will be flipped if the player makes the move. The move is a tuple of (row, col).

print_board()

Prints the board, the current player and the score.

print_moves(player)

Prints the possible moves for the player.

get_fen()

Returns the FEN string of the current game.

Attributes

board

The board of the game. 0 is empty, -1 is black, 1 is white.

cur_player

The current player. -1 is black, 1 is white.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

othelloc-0.2.3-py3-none-any.whl (34.5 kB view details)

Uploaded Python 3

File details

Details for the file othelloc-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: othelloc-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 34.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for othelloc-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cee3ff2a442387b0dcb90f04e37a178dfc1ae574e9e3aa32248fbed673efc6cc
MD5 2b49d5e708b1325fe2157686d45d8edb
BLAKE2b-256 74df01426b38eb74ea8e87bf1be21a3f04c1dbfb81d321b9fe9689af235f6552

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page