Skip to content
i-bot edited this page Jul 2, 2014 · 21 revisions

AI-Development:

Import the Interface:

Import the current version of the Checker Game

|

Import the necessary files:

import GameEngine.*;

> 
> |
> 
> > Implement the AI_Interface: 
> > ```java
public class YourAI implements AI_Interface {}

|

Add necessary methods:

@Override public Move computeNextMove(CheckerBoard arg0, Rule arg1, Color arg2) {}

> > Return the move which has been computed by the AI
> > 
> > If _null_ or an invalid Move is returned, the game will select a random Move
> > 
> > The Move must be computed within a maximal time, which can be set by Player, or the game will select a random Move

### Useful methods of the arguments:
> **`GameEngine.CheckerBoard.CheckerBoard arg0`**
> > > ```java
arg0.getPiece(int x, int y)
arg0.getPiece(Point p)

Returns the Piece on (x | y) or on p, starts at (0 | 0)

|

arg0.getPiecesOnBoard()

> > > Returns all non-captured Pieces
> > 
> > |
> > 
> > > ```java
arg0.getCapturedPieces(Color c_capturedPieces)

Returns all captured Pieces of the passed Color

|

arg0.executeMove(Move m, Rule currentRule)

> > > Checks the passed Move m and execute it if it is a valid Move, returns true if the move was executed successfully, before calling this method you should clone the CheckerBoard, executed Moves can't be undone
> > 
> > |
> > 
> > > ```java
arg0.executeMoves(ArrayList<Move> moves, Rule currentRule)

Executes Moves of moves, stops if one Move is invalid, returns true if all Moves has been executed successfully, starts at index 0, before calling this method you should clone the CheckerBoard, executed Moves can't be undone

|

arg0.clone()

> > > Returns a cloned version of the CheckerBoard
> 
> **`GameEngine.GameRules.Rule arg1`**
> > > ```java
arg1.getMovesWithJumps(Color color)

Returns an ArrayList<Move> of all possible jump-Moves which can be done by the Player with the passed Color

|

arg1.getMovesWithJumps(Piece piece)

> > > Returns an `ArrayList<Move>` of all possible jump-Moves which can be done by passed Piece
> > 
> > |
> > 
> > > ```java
arg1.getNormalMoves(Color color)

Returns an ArrayList<Move> of all possible non-jump-Moves which can be done by the Player with the passed Color

|

arg1.getNormalMoves(Piece piece)

> > > Returns an `ArrayList<Move>` of all possible non-jump-Moves which can be done by passed Piece
> > 
> > |
> > 
> > > ```java
arg1.checkMove(Move m)

Returns true if the passed Move is valid if not returns false

|

arg1.canJump(Piece piece)

> > > Returns _true_ if the passed Piece can make any jump-Move if not returns _false_
> > 
> > |
> > 
> > > ```java
arg1.isJump(Move m)

Returns true if the passed Move is a jump-Move if not returns false

|

arg1.isNormalMove(Move m)

> > > Returns _true_ if the passed Move is a non-jump-Move if not returns _false_
> > 
> > |
> > 
> > > ```java
arg1.canBeMadeToKing(Piece piece)

Returns true if the passed Piece can be made to a KING if not returns false

|

arg1.getOpponentsMovesForJumpingPiece(Piece piece)

> > > Returns an `ArrayList<Move>` of all possible Moves which can jump the passed Piece
> > 
> > |
> > 
> > > ```java
arg1.getDistanceToBorder(Border border, Piece piece)

Returns the distance between the passed Piece and the border

|

arg1.clone(Move m)

> > > Returns a new version of the Rule with the passed CheckerBoard which executed the passed _m_ with `checkerBoard.executeMove(Move m, Rule currentRule)`
> > 
> > |
> > 
> > > ```java
arg1.clone(ArrayList<Move> moves)

Returns a new version of the Rule with the passed CheckerBoard which executed the passed moves with checkerBoard.executeMoves(ArrayList<Move> moves, Rule currentRule)

|

arg1.clone(CheckerBoard changedCheckerBoard)

> > > Returns a new version of the Rule with the passed CheckerBoard
> > 
> > |
> > 
> > > ```java
arg1.clone()

Returns a cloned version of the Rule

|

Note: How the Rule behaves depends on the GameRule which was choosen by the Player for this Game, read the following page for further information

GameEngine.CheckerBoard.Color arg3

Color.getOppontentColor(Color color)

> > > Returns the Color of the opponent of the passed Color
> > 
> > |
> > 
> > > ```java
Color.LIGHT

first Player, at the top

|

Color.DARK

second Player, at the bottom

### Other usefule methods:
> **`GameEngine.CheckerBoard.Move m`**
> > > ```java
m.Move(Piece selectedPiece, Point destinationPoint)
m.Move(Piece selectedPiece, ArrayList<Point> destinationPoints)

Pass the Piece, which shall be moved and all destinationPoints, moves from index 0 to the last index

|

Move.addDestinationPoint(Point destinationPoint)

> > > Adds a Point to the end of the `ArrayList<Point>`
> > 
> > |
> > 
> > > ```java
m.getSelectedPiece()

Returns th Piece, which shall be moved

|

m.getDestinationPoints()

> > > Returns an `ArrayList<Point>`
> > 
> > |
> > 
> > > ```java
m.equals(Move move)

Compares move to m by value, Returns true if all values are equal if not returns false

|

m.clone()

> > > Returns a cloned version of the Move
> 
> **`GameEngine.CheckerBoard.Piece p`**
> > > ```java
p.getPosition()
p.getX()
p.getY()

Returns coordinate of p: (x | y) or position

|

p.getPieceColor

> > > Returns Color of `p`
> > 
> > |
> > 
> > > ```java
p.getPieceType

Returns PieceType of p

|

p.equals(Piece piece)

> > > Compares `piece` to `p` by value, Returns _true_ if all values are equal if not returns _false_
> > 
> > |
> > 
> > > ```java
p.clone()

Returns a cloned version of the Piece

GameEngine.CheckerBoard.Piece.PieceType

PieceType.Man

> > > initially Piece
> > 
> > |
> > 
> > > ```java
PieceType.King

Man becomes King if it reaches the baseline pf the opponenet

Clone this wiki locally