Github repository: https://github.com/NicholasRui/chessbattle
31 January 2021 28 February 2021 (see extension email image below), 11:59 pm.
Build a chess robot in python. Compete with other chess robots. Win the title of best chessed.
- You can either design a chess-playing bot by yourself or with one partner. Send an email to the above address declaring your intent to participate, and cc your partner if you have one.
- At some point, send me the name of your chess bot, together with a 300×300 pix “logo” representing your bot (please use attribution if you use pictures from the internet in any way).
- Near the deadline, email me a file containing the player class for your chess bot. Please name it “Competitor______” [the class] where ______ is some name that starts with a capital letter. There are no hard restrictions on the self.name attribute (but you need to have one). If you want to be anonymized, let me know explicitly.
- Feel free to ask questions either to the email or to me directly, but I will share any questions you ask with the rest of the competitors via the mailing list. If you want to be anonymized, please say so, otherwise I will use my best judgment. If your question is related to something specific you did, I will use my best judgment in figuring out what to and not to disclose.
- This is the first time I am doing this, so if I make a rule change or make an update to the repository that may affect the functionality of your chess bot, I will say so. Please let me know if you find any bugs.
- The default packages allowed are time, chess, copy, numpy, and func_timeout. If you want to use another package, you should let me know. If I think it’s fine, I will let all of the competitors know it is fair game (new packages may entail new rules).
- The easiest way to get this working is to download Anaconda, Stockfish, python-chess, and func-timeout.
- Git clone into the repository above, and navigate to the repository folder to run the code.
- Match will be decided by ten games played using one second time limit per move. Sides are randomized at first and then alternate. If this ends in a perfect draw, play up to ten games at 1:2 time control until one player wins. If ten games pass and all end in draws, a coin toss will determine the winner.
- Five seconds to decide whether or not to offer/accept a draw. If you time out or throw an error here, the default assumption is that there is no draw. You may only offer a draw after your own move, not before.
- Draw occurs without request by either the fifty-move rule or threefold repetition (in addition to, e.g., stalemate).
- One second to trash talk/receive trash talk. If you time out or throw an error here, the default assumption is that there is no trash talk.
- If you attempt an illegal/invalid move, you lose the game immediately (even if your opponent has insufficient material).
- For each game, I will pass a random seed (so that the games are different, if players are relying on randomness).
- Be sure to leave some extra time padding in your computation, since random noise may cause you to run out of time if you cut it too close (you can play with this yourself).
- In the Github, you will find four sample “player” classes. The first one simply implements the Stockfish engine. The second implements a chess bot called “Mr. Bean,” who will simply make random moves. The third implements a Human class which allows manual control over the player (for testing purposes). The fourth is a non-functional empty template called “CompetitorExamplePlayer” which you should build off of.
- Your bot should have the attribute name (str, name of bot).
- Your bot should have the following attributes and arguments: side (“white” or “black”), board (python-chess board object), max_time_per_move (time per move, in case you need to know this), and time_control (2-tuple where first number is total time in minutes, second number is increment in seconds).
- Your bot should have the make_move, receive_move, request_draw, respond_draw, receive_trash_talk, and solicit_trash_talk methods (see comments in CompetitorExamplePlayer for what these are supposed to do).
- All moves should be notated in the UCI convention.
- Your bot is allowed to trash talk via the solicit_trash_talk method. If this method returns a str instead of None during any solictation, your bot’s trash talk will be recorded and sent to the other bot for rebuttal.
- Basically, if you use the CompetitorExamplePlayer, all of these requirements should be naturally fulfilled.
- If you have any extra files outside of the python script that you want read in, please store them into the relative path “userfiles/____” where ____ is the name of your bot in self.name with any spaces replaced with underlines (please ignore your code training and use a relative path for consistency).
- Do not make your bot (class plus extra files) more than 5 Mb. This is not an encouragement to saturate this bound; it is perfectly fine to steer well below this.
Things to not do:
- Do not use np.seed() or any other functions which globally modify the random seed. This is because you should not be able to deterministically alter the RNG state of your opponent’s algorithm. You may, however, pre-compute the random numbers ahead of time, if desired, if for some reason you want to do this (you are always welcome to generate random numbers using NumPy).
- You may not directly use the evaluations or move suggestions from external engines such as Stockfish. You may, however, use any commands from the python-chess package (which are not engine related), test your AI against existing engines, or train them on engines (i.e., with machine learning). You may also use opening books, endgame tablebases, and chess game databases, but you have to implement this functionality yourself (you cannot call a python package to do this for you). If you do this, you should let me know if you do this for attribution purposes).
- Do not do chess-related computations in your trash talk methods. Your trash talk is allowed to be related to the chess (i.e., you can reference the chess board to figure out what to say), but you cannot, e.g., decide what move to do in the trash talk-related functions. I will use my best judgment here in deciding whether something violates this rule. (also do not do any calculations in the receive_move() method that do not involve reading the opponent’s move into your format of choice… there is no time constraint on this function but you should be reasonable here)
- Do not make a bot that tries to crash the game. You will be disqualified.
- Don’t be evil. Don’t be mean/offensive, etc., when picking names, designing logos, or trash talking.
- Aaron Elersich
- Shishir Dholakia
- Shashank Dholakia
- Richard Udall and Kate Blake
- Gaurav Rao
Below are answers to questions that I receive about this competition, made public for fairness. I’ve redacted any personal information and any specific chess bot ideas that are not sufficiently generic, so that I am not publicizing someone’s idea.
I will not myself be making a submission in this competition. That would probably be unfair, since I’m also deciding what the rules are.
For the time being, use of the Python package “os” (commonly used for calling Unix commands within Python) is prohibited. There are way too many ways to abuse it, and the practical value is not clear.
Since endgame tablebases are, in their entirety, much larger than the Mb limit, there is a de facto limitation on how much of the tablebase can be used (the subset of the endgame tablebase is, of course, free for the competitor to choose). The file size limit is still in place.
Although endgame tablebases are very large on their own, they can be called from the python-chess module. However, it has come to my attention that the python-chess module also contains a submodule chess.engine which allows you to call Stockfish… I will retroactively ban the use of this particular submodule.
The deadline is still January 31st, 2021, 11:59 pm.
You are permitted to use a totally random strategy, but (1) this is already implemented as a test chess bot, and (2) probably won’t win.
Connecting to the Internet for the purposes of getting an Internet engine move recommendation (or doing substantial engine calculations with the Internet) is not permitted. However, querying online endgame tablebases using the python-chess module is still allowed.
The inclusion of the userfiles/ directory was primarily for reading-in external files that you did not want to include in the bot class. However, I will accommodate setting the pythonpath so that you can call python scripts in userfiles/. If you do this, you should let me know (1) explicitly that you want the pythonpath set, and (2) what import statement I need to include, since having separate python scripts in userfiles/ will not be the default.
Trash talk is a “fun” optional feature in this competition where your bot is prompted to make a short statement after each move. That statement is passed onto the opponent, who may formulate their next trash talk message with the previous one in mind.
You’re definitely allowed to use python-chess to query online opening books. If you want to use a different package, this may be allowed, but you need to clear it with me first.
The “strong” fifty-move rule is enforced, in the sense that if fifty moves which are not captures or pawn moves take place, then there is a mandatory draw (players cannot “opt out” of claiming a draw).
There are no limits on what algorithms/methods you can look up, but if you use some idea which is “sufficiently creative” from someone else, you should disclose it for credit.