public ChessAgent RegisterAgent(string name, Color color) { ChessAgent ca = new ChessAgent(name, color, this); chessAgents.Add(ca); return(ca); }
public ChessBoard(ChessGameManager chessGameManager) { this.chessGameManager = chessGameManager; sizex = 8; sizey = 8; // creates the standardchessboardwith all pieces; chessFields = new ChessField[8, 8]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { chessFields[i, j] = new ChessField(i, j); } } ChessAgent playerAgent = RegisterAgent("Player", Color.white); ChessAgent computerAgent = RegisterAgent("Computergegner", Color.black); // register pawns: for (int i = 0; i < 8; i++) { playerAgent.RegisterPiece(ChessPiece.PieceType.PAWN, new Pos2D(i, 1)); computerAgent.RegisterPiece(ChessPiece.PieceType.PAWN, new Pos2D(i, 6)); } playerAgent.RegisterPiece(ChessPiece.PieceType.ROOK, new Pos2D(0, 0)); playerAgent.RegisterPiece(ChessPiece.PieceType.ROOK, new Pos2D(7, 0)); playerAgent.RegisterPiece(ChessPiece.PieceType.KNIGHT, new Pos2D(1, 0)); playerAgent.RegisterPiece(ChessPiece.PieceType.KNIGHT, new Pos2D(6, 0)); playerAgent.RegisterPiece(ChessPiece.PieceType.BISHOP, new Pos2D(2, 0)); playerAgent.RegisterPiece(ChessPiece.PieceType.BISHOP, new Pos2D(5, 0)); playerAgent.RegisterPiece(ChessPiece.PieceType.QUEEN, new Pos2D(3, 0)); playerAgent.RegisterPiece(ChessPiece.PieceType.KING, new Pos2D(4, 0)); computerAgent.RegisterPiece(ChessPiece.PieceType.ROOK, new Pos2D(0, 7)); computerAgent.RegisterPiece(ChessPiece.PieceType.ROOK, new Pos2D(7, 7)); computerAgent.RegisterPiece(ChessPiece.PieceType.KNIGHT, new Pos2D(1, 7)); computerAgent.RegisterPiece(ChessPiece.PieceType.KNIGHT, new Pos2D(6, 7)); computerAgent.RegisterPiece(ChessPiece.PieceType.BISHOP, new Pos2D(2, 7)); computerAgent.RegisterPiece(ChessPiece.PieceType.BISHOP, new Pos2D(5, 7)); computerAgent.RegisterPiece(ChessPiece.PieceType.QUEEN, new Pos2D(3, 7)); computerAgent.RegisterPiece(ChessPiece.PieceType.KING, new Pos2D(4, 7)); }
public ChessPiece(PieceType type_, Pos2D pos_, ChessAgent agent_) { agent = agent_; pos = pos_; Type = type_; Lives = 1; MaxLives = 1; switch (type_) { case PieceType.PAWN: moveAbilities.Add(new ChessMoveAbility(1, 0, new ChessMoveAbility.Tags[] { ChessMoveAbility.Tags.FORWARDONLY, ChessMoveAbility.Tags.NOSTRIKE })); moveAbilities.Add(new ChessMoveAbility(1, 1, new ChessMoveAbility.Tags[] { ChessMoveAbility.Tags.FORWARDONLY, ChessMoveAbility.Tags.STRIKEONLY })); break; case PieceType.QUEEN: moveAbilities.Add(new ChessMoveAbility(1, 0, new ChessMoveAbility.Tags[] { ChessMoveAbility.Tags.RIDE })); moveAbilities.Add(new ChessMoveAbility(1, 1, new ChessMoveAbility.Tags[] { ChessMoveAbility.Tags.RIDE })); break; } }