Skip to main content

The English chekers game simulation package

Project description

The package realizes English chekers game simulation.

Basic usage

Let’s create a game with RandomAI:

from checkers.game import Game, GameState, Color
from checkers.move import Move
from checkers.ai.random_ai import RandomAI

def main():
    size = 8
    game = Game(size)
    ai_color = Color.WHITE
    ai = RandomAI(size, ai_color)
    if ai_color == Color.BLACK:
        move = None
    while game.state == GameState.UNFINISHED:
        print(game.board)
        print('b:', game.black_count, 'w:', game.white_count)
        print(game.turn)

        if game.turn == ai_color:
            move = ai.make_move(move)
        else:
            moves = game.get_all_moves()
            for i, move in enumerate(moves):
                print(i + 1, ':', move)
            print('Input number of the move for move:')
            try:
                move_number = int(input().strip())
            except ValueError:
                print('Wrong input. Number of the move must be int')
            try:
                move = moves[move_number - 1]
            except IndexError:
                print('Wrong move')
                continue
        game.make_move(move)
    else:
        print(game.board)
        print(game.state)


if __name__ == '__main__':
    main()

Project details


Download files

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

Source Distribution

english_checkers-0.0.2.tar.gz (14.7 kB view hashes)

Uploaded Source

Built Distribution

english_checkers-0.0.2-py3-none-any.whl (11.8 kB view hashes)

Uploaded Python 3

Supported by

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