https://en.wikipedia.org/wiki/Losing_chess
This is basically Chess Tournament, but for antichess ;)
Antichess is one of the many chess variants that have been invented. The goal is to lose all your pieces (this may seem a little odd, but it's called antichess for a reason).
The rules
The rules of antichess are very similar to standard chess - but with a few fairly minor differences. The goal as I mentioned above is to lose all your pieces. To make this happen, if your opponent has an opportunity to capture one of your pieces, that is the only move he can make. If you give him multiple chances in one turn, the other player may choose his turn. Another thing that is changed is that the king has no special powers - as in you cannot checkmate your opponent, and you can't force him into check.
The following changes to the standard game will also apply (they help simplify the game):
- En passant will be ignored.
- Castling isn't possible.
- The Fifty-move rule applies automatically (meaning the game ends in a draw).
- Pawns will be able to choose what they promote to.
- If a player needs longer than 2 seconds to move, he will lose the game.
- Returning an invalid move will result in losing the game.
- To win, your opponents must capture all your pieces.
- White begins the game.
- White is placed "at the bottom" of the field (y=0), black is located at the top (y=7).
- Accessing other resources than your bot (internet, files, other bots, ...) is prohibited.
Scoring
- Winning grants you 3 points, a draw 1 point and losing 0 points.
- Each submission will play against each other submission 10 times (5 times as white, 5 as black).
Writing your bot
Controller code is here: https://github.com/JJ-Atkinson/SimpleAntichessKOTH
You can write your bot in either Java or Groovy. To write a bot you must extend the Player
class. The player class has one abstract method Move getMove(Board board, Player enemy, Set<Move> validMoves)
.
Here is a quick rundown on useful methods:
Player
:
List<Piece> getPieces(Board board)
: Return all your pieces that are on the board.PieceUpgradeType pieceUpgradeType
: If/when one of your pawns reaches the end of the board, you will need to define this to the type of piece you want to upgrade to. You have the choice ofROOK
,KNIGHT
,QUEEN
,BISHOP
, andKING
.
Board
:
Field getFieldAtLoc(Location loc)
: Return theField
at the location. This has a matchinggetAt
method so that if you are using groovy you can writeboard[loc]
.Field getFieldAtLoc(int x, int y)
: Return theField
at the location. This has a matchinggetAt
method so that if you are using groovy you can writeboard[x, y]
.Board movePiece(Player player, Move move)
: Make a move on the board so you can see how it would play out. It returns the new board.
If you want to see your opponents pieces, just write enemy.getPieces(board)
. To add your bot to the lineup add the following line to PlayerFactory
:
put(YourBot.class, { new YourBot() } )
Debugging your bot:
I have included a couple of tools to aid in debugging your bots. To see your game played out live you can set the Game#DEBUG
flag to true. You will get an output something like this:
Game started. Players: [OnePlayBot(WHITE), SacrificeBot(BLACK)]
...
BLACKs turn.
validMoves: [Move(Piece(BLACK, PAWN, Loc(0, 6)), Loc(0, 5)), ...]
board:
RKBQIBKR
PPPPPPPP
--------
--------
--------
p-------
-ppppppp
rkbqibkr
captureless turns: 1
chosen move: Move(Piece(BLACK, PAWN, Loc(7, 6)), Loc(7, 4))
Game over? false
==============================
WHITEs turn.
validMoves: [Move(Piece(WHITE, ROOK, Loc(0, 0)), Loc(0, 1)), ...]
board:
RKBQIBKR
PPPPPPP-
--------
-------P
--------
p-------
-ppppppp
rkbqibkr
...
(White is upper case, the king is shown with i
)
If your console supports utf-8 special chars, you can even show the board with the chess chars by using Board#USE_UTF8_TO_STRING
:
♜♞♝♛♚♝—♜
♟—♟♟♟♟♟♟
————————
—♟——————
————————
♙———————
—♙♙♙♙♔♙♙
♖♘♗♕—♗♘♖
(it looks better with a mono spaced font)
To prevent a flood of unwanted output, you should change the Main#main
function to something like this:
new Game(new MyBot(), new SacrificeBot()).run()
Put your bot on the left to play as white, put it on the right to play as black.
Building the controller:
The controller is written in groovy, so you must have java and groovy installed. If you don't want to install groovy you can use the gradle build file that comes with the controller (this has not been tested). If you don't want to use groovy or gradle you can use the latest release jar (https://github.com/JJ-Atkinson/SimpleAntichessKOTH/releases). If you do this you need to make your own main
method and add your bot manually to the player factory. Example:
PlayerFactory.players.put(YourBot.class, { new YourBot() } )
new Runner().runGames();
(Note that you can still set the debug flags and stuff)
Any and all bug finding is appreciated!
Scores:
SearchBot -> 101
SacrificeBot -> 81
MeasureBot -> 37
RandomBot -> 28
OnePlayBot -> 24
Please note that I'm always willing to have new submissions!