{ "cells": [ { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "# 1. Cognitive Science: Lab02" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For this lab, you will create a chess playing program.\n", "\n", "First, read [Programming a Chess Player](Programming a Chess Player.ipynb)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Team**:\n", "\n", "* team name:\n", "* team members:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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](tournament.py)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from tournament import ChessPlayer\n", "import random" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To have a baseline program to practice against, let's define a random player:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "def random_player(board):\n", " move = random.choice(list(board.legal_moves))\n", " return move.uci()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To run a tournament, you need to create two teams:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "random_team = ChessPlayer(random_player, \"Random Team\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "other_team = ChessPlayer(random_player, \"Making Chess Great Again\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And then you are ready to play a gaim. Simply have one team play the other:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%%time\n", "random_team.play(other_team)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "By default, the play happens without any graphics. The output is of the following form:\n", "\n", " [RESULT, MESSAGE, FINAL_BOARD, WINNER(S)]\n", " \n", "RESULT is:\n", "\n", "* None - draw\n", "* True - the current team won\n", "* False - the other team won\n", "\n", "MESSAGE is a string representing the final outcome.\n", "\n", "FINAL_BOARD is a Board object, showing a FEN representation\n", "\n", "WINNER is the name(s) of the winning teams.\n", "\n", "If you would like to watch a game, use \"simple\" or \"svg\" as a second argument to the team.play() method." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "random_team.play(other_team, \"svg\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You might like to code a human player (see [Programming a Chess Player](Programming a Chess Player.ipynb))." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 2. Your Mission" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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.\n", "\n", "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." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true, "deletable": false, "nbgrader": { "checksum": "f53ad125e36e9e753836c8f3642f5099", "grade": true, "grade_id": "chess-program", "locked": false, "points": 50, "solution": true } }, "outputs": [], "source": [ "# YOUR CODE HERE\n", "raise NotImplementedError()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 3. Reflection\n", "\n", "The reflection cell is the most import cell in this lab... in all labs. In your reflection, you should:\n", "\n", "* Reflect! Think and comment on what you have learned this lab, and this week. Connect the ideas onto your own life, and experiences.\n", "* Feel free to comment on what you found challenging, and what you found intuitive.\n", "\n", "For this second lab, please also add reflections on meta-topics:\n", "\n", "* How does your program work?\n", "* Would you say that your program thinks?\n", "* Did you learn anything" ] }, { "cell_type": "markdown", "metadata": { "deletable": false, "nbgrader": { "checksum": "fb5a1fdd7fbc9cd9dd47331cfbd26d67", "grade": true, "grade_id": "reflection", "locked": false, "points": 50, "solution": true } }, "source": [ "YOUR ANSWER HERE" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.2" } }, "nbformat": 4, "nbformat_minor": 1 }