If you run the app, you will see a ludi board with 4 A.I. players
This code controls them
The first dice is used alone, as the code above suggests. Dices are displayed as numbers in top left.Code://move what was rolled if ((dicevals[0] == 6) || (dicevals[1] == 6)) { //If unborn piecses, born them if (players[turn].HasUnborn()) { //born piece(s) players[turn].BornFirstUnbornPiece(); } else { //else just move players[turn].BeginMovePieceAtBack(dicevals[0]); } //Roll again turn--; } else { //move last piece if (players[turn].HasBorn()) players[turn].BeginMovePieceAtBack(dicevals[0]);//(diceval, 0); } turn++; if (turn == nPlayers) turn = 0;
Bugs.
-first two dispays are ignored
-Program crashes when a peice reaches the end.
If someone wants to suggest an AI pattern then they are welcome
Just use straight psedo code
You can even make up new player functions eg Player.CanMove(int space), bool Player.KillsOtherPlayer(int space), and so on
Here is the app
http://www.megaupload.com/?d=FBGB3NPZ
Thanks