25 April 2025

Chess-Program

by Carson Kempf

Chess Program


Scope


Objectives

(to be used for future AI algorithms to solve)

Overview

Joueur

Joueur Class


Output

On Each Turn

  1. Print out in its own line: the number of moves available to your program
  2. Print out in a single line: all moves available to your player program in alphabetical order
  3. In the next line: print the randomly chosen move that the program returns to the chess server

Moves Printed

Examples:

e2e4

e7e5

e1g1 (white short castling)

e7e8q (for promotion)

Sample Output

Input FEN string:

3k4/8/5N2/3P3p/4K3/2p5/1B6/8 w - - 0 23

(Corresponds to the following board…)

Output Format:

18 
b2a1 b2a3 b2c1 b2c3 d5d6 e4d3 e4d4 e4e3 e4e5 e4f3 e4f4 e4f5 
f6d7 f6e8 f6g4 f6g8 f6h5 f6h7 
My move = b2c1

**Note: Remember the special move rules for pawns and kings **


Implementation Requirements

If other files are used:


Documentation

Classes

Scope


AI

class games.chess.ai.AI(game)

Functions

end(won: bool, reason: str)

returns:
Parameters:

won(bool)

reason(str)

game_updated()
returns:
get_name()
returns:
get_settings(key: str)
returns:
Flag:

Set

Not Set

Parameters:

key(str)

make_move()
returns:

string

start()
returns:

None

Properties

property game
Type:

games.chess.game.Game

property player
Type:

games.chess.player.Player


Game

class games.chess.game.Game

Functions

get_game_object(id: str)
Returns:

Optional[joueur.base_game_object.BaseGameObject]

Properties

property fen
Type:

string

property game_objects
Type:

dict[str, games.chess.game_object.GameObject]

property history
Type:

list[str]

property players
Type:

list[games.chess.player.Player]

property session
Type:

string


GameObject

class games.chess.game_object.GameObject

Functions

log(message:str)
Returns:

None

Parameters:

message(str)

Properties

property game_object_name
Type:

string

property id
Type:

string

property logs
Type:

list[str]


Player

class games.chess.player.Player

Functions

log(message: str)
Returns:

None

Parameters:

message(str)

Properties

property client_type
Type:

string

property color
Type:

“white”

“black”

property game_object_name
Type:

string

property id
Type:

string

property logs
Type:

list[str]

property lost
Type:

boolean

property name
Type:

string

property opponent
Type:

games.chess.player.Player

property reason_lost
Type:

string

property reason_won
Type:

string

property time_remaining
Type:

float

property won
Type:

boolean


Game Logic


Submission

ReadyToSubmit.txt

  1. Change to yes
  2. Change to py

Grading

Do NOT edit play.sh

Execution

./play.sh LANGUAGE_DIR SESSION_ID

./testRun MyOwnGameSession

LANGUAGE_DIR

./play.sh Joueur.py testing_id

The testRun Script

Server Software