1. Cognitive Science: Lab02

For this lab, you will create a chess playing program.

First, read Programming a Chess Player.

Team:

  • team name:
  • team members:

First, we will import a program in the current directory (called tournament.py), getting the class ChessPlayer from it. You can see the details of that program in tournement.py

In [ ]:
from tournament import ChessPlayer
import random

To have a baseline program to practice against, let's define a random player:

In [ ]:
def random_player(board):
    move = random.choice(list(board.legal_moves))
    return move.uci()

To run a tournament, you need to create two teams:

In [ ]:
random_team = ChessPlayer(random_player, "Random Team")
In [ ]:
other_team = ChessPlayer(random_player, "Making Chess Great Again")

And then you are ready to play a gaim. Simply have one team play the other:

In [ ]:
%%time
random_team.play(other_team)

By default, the play happens without any graphics. The output is of the following form:

[RESULT, MESSAGE, FINAL_BOARD, WINNER(S)]

RESULT is:

  • None - draw
  • True - the current team won
  • False - the other team won

MESSAGE is a string representing the final outcome.

FINAL_BOARD is a Board object, showing a FEN representation

WINNER is the name(s) of the winning teams.

If you would like to watch a game, use "simple" or "svg" as a second argument to the team.play() method.

In [ ]:
random_team.play(other_team, "svg")

You might like to code a human player (see Programming a Chess Player).

2. Your Mission

Your team should write a chess-playing program. You must write the logic yourself and cannot use any other programs (such as opening move database). Each move must be made within 1 second.

Every member of the team should sumbit their own notebook, but the chess-playing program should be the same in each notebook. Put your team's chess program in the next cell.

In [ ]:
# YOUR CODE HERE
raise NotImplementedError()

3. Reflection

The reflection cell is the most import cell in this lab... in all labs. In your reflection, you should:

  • Reflect! Think and comment on what you have learned this lab, and this week. Connect the ideas onto your own life, and experiences.
  • Feel free to comment on what you found challenging, and what you found intuitive.

For this second lab, please also add reflections on meta-topics:

  • How does your program work?
  • Would you say that your program thinks?
  • Did you learn anything

YOUR ANSWER HERE