Author |
Topic: Chimaera : An Arimaa engine written in C# (Read 3878 times) |
|
chimaera
Forum Full Member
Arimaa player #4560
Gender:
Posts: 16
|
|
Chimaera : An Arimaa engine written in C#
« on: Nov 10th, 2009, 6:10pm » |
Quote Modify
|
http://www.wwddfd.com/arimaa/ I have been working on an Arimaa game-playing engine in C#. The engine is pretty much feature-complete, and I've moved on to the API and GUI. I've already implemented a basic GUI. I've just obtained a license from Omar Syed, so I'm releasing it to the world for the first time today. This project is provided with the written authorization of Arimaa.com and in compliance with Section III of the Arimaa Public License. Here's a screenshot of my (primitive) GUI. Notice how it depicts frozen pieces and shows legal moves for the selected piece. And here's a list of all the "illegal move" reasons (the game can tell you exactly why a move is illegal - see the screenshot above - notice how it doesn't even offer Eg3n as a valid move). Code: msExplanations[(int)ae.InvalidMove.Null] = ""; msExplanations[(int)ae.InvalidMove.GameStateInvalid] = "The Game state is invalid."; msExplanations[(int)ae.InvalidMove.MoveObjectInvalid] = "The Move object is invalid."; msExplanations[(int)ae.InvalidMove.OutOfTurn] = "It is not your turn to move."; msExplanations[(int)ae.InvalidMove.CannotMoveEnemyPiece] = "You cannot move this enemy piece."; msExplanations[(int)ae.InvalidMove.InvalidStartPosition] = "The intended start position of this piece is invalid."; msExplanations[(int)ae.InvalidMove.PieceNotFound] = "The indicated piece was null or not found."; msExplanations[(int)ae.InvalidMove.OriginSquareNotFound] = "The origin square of the move was null or not found."; msExplanations[(int)ae.InvalidMove.DestinationSquareNotFound] = "The destination square of the move was null or not found."; msExplanations[(int)ae.InvalidMove.OriginSquareIncorrect] = "The residing square of the piece did not agree with the origin square of the move."; msExplanations[(int)ae.InvalidMove.SquaresNotAdjacent] = "The origin and destination squares are not adjacent."; msExplanations[(int)ae.InvalidMove.DestinationSquareOccupied] = "The destination square is currently occupied."; msExplanations[(int)ae.InvalidMove.InsufficientMovesRemaining] = "Not enough moves remaining in turn to complete this move."; msExplanations[(int)ae.InvalidMove.MustFollowThroughOnPush] = "You must follow through on the in-progress push by moving into the square vacated by the enemy piece."; msExplanations[(int)ae.InvalidMove.PieceFrozen] = "The piece you are attempting to move is frozen in place by an adjacent enemy piece."; msExplanations[(int)ae.InvalidMove.PieceTypeMovementRestricted] = "The piece you are attempting to move is not allowed to move in that direction."; msExplanations[(int)ae.InvalidMove.CannotPushEnemyPieceWithThisPiece] = "You cannot follow through on the push with this piece, because it is too weak."; msExplanations[(int)ae.InvalidMove.NoAdjacentPiecesCanPushThisPiece] = "There are no adjacent pieces capable of pushing the enemy piece that you are trying to move."; msExplanations[(int)ae.InvalidMove.AllAdjacentPiecesForPushingAreFrozen] = "All adjacent pieces capable of pushing this piece are currently frozen."; msExplanations[(int)ae.InvalidMove.CannotRepeatPreviousBoardPosition] = "You cannot make this move because it would repeat a previous board position an illegal number of times."; msExplanations[(int)ae.InvalidMove.MustChangeBoardPosition] = "You cannot make this move because it would duplicate the board position from the beginning of your turn."; |
| The engine was written in C# and runs under version 2.0 of the .NET framework. I have tested it under the latest Mono runtime and it works (although it's ugly when running in Mono under Linux due to bad drawing of the PNG's alpha channels). It looks a lot better in Windows at the moment. The GUI is very rough, anyway (and probably very inefficient); it's intended only to demonstrate the features of the game-playing engine. I didn't implement bitboards or anything like that; the engine is designed to be very easy to understand and use, and anyone with a bit of know-how should be able to radically alter many of the rules with minimal effort. Keep in mind that this is alpha-quality and I have a lot of work left to do. The GUI "game" is at "Chimaera/Chimaera/bin/Release/Chimaera.exe" Extract all files from the zip archive to test it out (it needs to load some settings and graphics). The project ZeroGravitas is the actual game engine. The project NUnitZeroGravitas is a series of NUnit test cases to test the game engine's respect for the rules of Arimaa. The "TestZeroGravitas" project crashes when you run it, but it's designed to do that. It's what I use to step through my NUnit test cases as I'm writing them. The particular test case it runs at the moment is the 3-move repeat rule. The engine throws an exception when the test tries to make an illegal move.
|
|
IP Logged |
|
|
|
Fritzlein
Forum Guru
Arimaa player #706
Gender:
Posts: 5928
|
|
Re: Chimaera : An Arimaa engine written in C#
« Reply #1 on: Nov 10th, 2009, 6:30pm » |
Quote Modify
|
Awesome. Thank you for contributing your GUI to the community. How does the Arimaa Public License work if someone wishes to improve/extend what you have done?
|
|
IP Logged |
|
|
|
chimaera
Forum Full Member
Arimaa player #4560
Gender:
Posts: 16
|
|
Re: Chimaera : An Arimaa engine written in C#
« Reply #2 on: Nov 10th, 2009, 6:39pm » |
Quote Modify
|
My project is open source within the limits of the Arimaa Public License. If someone wishes to extend the project and distribute their changes, they will have to either submit their changes to me or obtain a separate written license from Omar Syed. It may be legally possible for you to diff your source files against my base files and distribute the diff (much as the LAME mp3 encoder started out as a diff against the ISO mp3 encoder's source).
|
|
IP Logged |
|
|
|
chimaera
Forum Full Member
Arimaa player #4560
Gender:
Posts: 16
|
|
Re: Chimaera : An Arimaa engine written in C#
« Reply #3 on: Nov 10th, 2009, 7:05pm » |
Quote Modify
|
Oh, and I just noticed that one of the NUnit test cases fails because I recently implemented a new check when attempting to end a turn early. I think the engine is actually correct and the moves I am making in the test case are wrong.
|
|
IP Logged |
|
|
|
omar
Forum Guru
Arimaa player #2
Gender:
Posts: 1003
|
|
Re: Chimaera : An Arimaa engine written in C#
« Reply #4 on: Nov 10th, 2009, 10:11pm » |
Quote Modify
|
Wow, the GUI looks very nice. Are you using the AEI to communicate between the GUI and the game engine?
|
|
IP Logged |
|
|
|
chimaera
Forum Full Member
Arimaa player #4560
Gender:
Posts: 16
|
|
Re: Chimaera : An Arimaa engine written in C#
« Reply #5 on: Nov 11th, 2009, 2:49pm » |
Quote Modify
|
I haven't implemented an API for communication yet. The GUI is just loading the game engine's DLL, creating a "Game" object, and calling functions on it directly. I've been busy lately and haven't made many improvements in the past few weeks, but I'll try to do some more work on it now that I can distribute it.
|
|
IP Logged |
|
|
|
Janzert
Forum Guru
Arimaa player #247
Gender:
Posts: 1016
|
|
Re: Chimaera : An Arimaa engine written in C#
« Reply #6 on: Nov 11th, 2009, 9:41pm » |
Quote Modify
|
I'd be glad to give any help you need with understanding AEI. A GUI that can use AEI is something I would really like to see. I've actually started a writing one a few times, but the combination of a) I do this for fun and b) I really can't stand GUI programming means I've never completed anything. Janzert
|
|
IP Logged |
|
|
|
omar
Forum Guru
Arimaa player #2
Gender:
Posts: 1003
|
|
Re: Chimaera : An Arimaa engine written in C#
« Reply #7 on: Nov 12th, 2009, 12:30pm » |
Quote Modify
|
If you have the GUI use the AEI then other developers will also be able to use it to control their engines.
|
|
IP Logged |
|
|
|
chimaera
Forum Full Member
Arimaa player #4560
Gender:
Posts: 16
|
|
Re: Chimaera : An Arimaa engine written in C#
« Reply #8 on: Nov 12th, 2009, 3:02pm » |
Quote Modify
|
My main concern up to this point has been tweaking the game-playing engine. I'll start looking into AEI this weekend.
|
|
IP Logged |
|
|
|
FireBorn
Forum Guru
Arimaa player #1832
Gender:
Posts: 123
|
|
Re: Chimaera : An Arimaa engine written in C#
« Reply #9 on: Nov 12th, 2009, 5:20pm » |
Quote Modify
|
I like this engine because it checks for illegal moves and stuff. I couldn't figure out if the gameroom does that, but I think it just forfeits the game when it receives an illegal move. This engine will be helpful for evolving my bots. Do other bot developers write their own representation of the game and its rules in order to generate and play legal moves? That seems like a lot of unnecessarily repeated work. If so, this engine could save a lot of time and effort for new developers. Thanks, Chimaera!
|
|
IP Logged |
|
|
|
omar
Forum Guru
Arimaa player #2
Gender:
Posts: 1003
|
|
Re: Chimaera : An Arimaa engine written in C#
« Reply #10 on: Nov 12th, 2009, 7:44pm » |
Quote Modify
|
on Nov 12th, 2009, 5:20pm, FireBorn wrote:Do other bot developers write their own representation of the game and its rules in order to generate and play legal moves? That seems like a lot of unnecessarily repeated work. If so, this engine could save a lot of time and effort for new developers. Thanks, Chimaera! |
| Developers often write their own bots from scratch. There are several sample bots available on the downloads page and some developers have used these also. I just added Chimaera to the downloads page. Scott, have you tried compiling Chimaera under linux yet?
|
|
IP Logged |
|
|
|
chimaera
Forum Full Member
Arimaa player #4560
Gender:
Posts: 16
|
|
Re: Chimaera : An Arimaa engine written in C#
« Reply #11 on: Nov 12th, 2009, 7:47pm » |
Quote Modify
|
on Nov 12th, 2009, 7:44pm, omar wrote: Scott, have you tried compiling Chimaera under linux yet? |
| Yes, and it works great aside from the lack of alpha blending on the PNG images I'm using (probably due to the retarded way I'm drawing the screen - using a grid of PictureBox objects). It's targeting the .NET 2.0 platform, which is almost perfectly supported by Mono.
|
|
IP Logged |
|
|
|
chimaera
Forum Full Member
Arimaa player #4560
Gender:
Posts: 16
|
|
Re: Chimaera : An Arimaa engine written in C#
« Reply #12 on: Nov 12th, 2009, 9:27pm » |
Quote Modify
|
I have updated the zip on my site with a few fixes to the repeat-rule checking and game initialization. I'll be spending the next few days trying to improve the GUI (so you can start with a blank board and place pieces) and looking into the AEI protocol.
|
|
IP Logged |
|
|
|
camelback
Forum Guru
Arimaa perl monger
Gender:
Posts: 144
|
|
Re: Chimaera : An Arimaa engine written in C#
« Reply #13 on: Nov 16th, 2009, 8:47pm » |
Quote Modify
|
Very nice GUI, thanks chimaera
|
|
IP Logged |
|
|
|
omar
Forum Guru
Arimaa player #2
Gender:
Posts: 1003
|
|
Re: Chimaera : An Arimaa engine written in C#
« Reply #14 on: Nov 24th, 2009, 1:00pm » |
Quote Modify
|
on Nov 12th, 2009, 7:47pm, chimaera wrote: It's targeting the .NET 2.0 platform, which is almost perfectly supported by Mono. |
| Cool. I'll try compiling it on Aamir's ubuntu system.
|
|
IP Logged |
|
|
|
|