private static void SetMovesWhitePawn() { for (byte index = 8; index <= 55; index++) { byte x = (byte)(index % 8); byte y = (byte)((index / 8)); var moveset = new PieceMoveSet(new List<byte>()); //Diagonal Kill if (x < 7 && y > 0) { moveset.Moves.Add((byte)(index - 8 + 1)); MoveArrays.WhitePawnTotalMoves[index]++; } if (x > 0 && y > 0) { moveset.Moves.Add((byte)(index - 8 - 1)); MoveArrays.WhitePawnTotalMoves[index]++; } //One Forward moveset.Moves.Add((byte)(index - 8)); MoveArrays.WhitePawnTotalMoves[index]++; //Starting Position we can jump 2 if (y == 6) { moveset.Moves.Add((byte)(index - 16)); MoveArrays.WhitePawnTotalMoves[index]++; } MoveArrays.WhitePawnMoves[index] = moveset; } }
private static void SetMovesKnight() { for (byte y = 0; y < 8; y++) { for (byte x = 0; x < 8; x++) { byte index = (byte)(y + (x * 8)); var moveset = new PieceMoveSet(new List<byte>()); byte move; if (y < 6 && x > 0) { move = Position((byte)(y + 2), (byte)(x - 1)); if (move < 64) { moveset.Moves.Add(move); MoveArrays.KnightTotalMoves[index]++; } } if (y > 1 && x < 7) { move = Position((byte)(y - 2), (byte)(x + 1)); if (move < 64) { moveset.Moves.Add(move); MoveArrays.KnightTotalMoves[index]++; } } if (y > 1 && x > 0) { move = Position((byte)(y - 2), (byte)(x - 1)); if (move < 64) { moveset.Moves.Add(move); MoveArrays.KnightTotalMoves[index]++; } } if (y < 6 && x < 7) { move = Position((byte)(y + 2), (byte)(x + 1)); if (move < 64) { moveset.Moves.Add(move); MoveArrays.KnightTotalMoves[index]++; } } if (y > 0 && x < 6) { move = Position((byte)(y - 1), (byte)(x + 2)); if (move < 64) { moveset.Moves.Add(move); MoveArrays.KnightTotalMoves[index]++; } } if (y < 7 && x > 1) { move = Position((byte)(y + 1), (byte)(x - 2)); if (move < 64) { moveset.Moves.Add(move); MoveArrays.KnightTotalMoves[index]++; } } if (y > 0 && x > 1) { move = Position((byte)(y - 1), (byte)(x - 2)); if (move < 64) { moveset.Moves.Add(move); MoveArrays.KnightTotalMoves[index]++; } } if (y < 7 && x < 6) { move = Position((byte)(y + 1), (byte)(x + 2)); if (move < 64) { moveset.Moves.Add(move); MoveArrays.KnightTotalMoves[index]++; } } MoveArrays.KnightMoves[index] = moveset; } } }
private static void SetMovesRook() { for (byte y = 0; y < 8; y++) { for (byte x = 0; x < 8; x++) { byte index = (byte)(y + (x * 8)); var moveset = new PieceMoveSet(new List<byte>()); byte move; byte row = x; byte col = y; while (row < 7) { row++; move = Position(col, row); moveset.Moves.Add(move); MoveArrays.RookTotalMoves1[index]++; } MoveArrays.RookMoves1[index] = moveset; moveset = new PieceMoveSet(new List<byte>()); row = x; col = y; while (row > 0) { row--; move = Position(col, row); moveset.Moves.Add(move); MoveArrays.RookTotalMoves2[index]++; } MoveArrays.RookMoves2[index] = moveset; moveset = new PieceMoveSet(new List<byte>()); row = x; col = y; while (col > 0) { col--; move = Position(col, row); moveset.Moves.Add(move); MoveArrays.RookTotalMoves3[index]++; } MoveArrays.RookMoves3[index] = moveset; moveset = new PieceMoveSet(new List<byte>()); row = x; col = y; while (col < 7) { col++; move = Position(col, row); moveset.Moves.Add(move); MoveArrays.RookTotalMoves4[index]++; } MoveArrays.RookMoves4[index] = moveset; } } }
private static void SetMovesKing() { for (byte y = 0; y < 8; y++) { for (byte x = 0; x < 8; x++) { byte index = (byte)(y + (x * 8)); var moveset = new PieceMoveSet(new List<byte>()); byte move; byte row = x; byte col = y; if (row < 7) { row++; move = Position(col, row); moveset.Moves.Add(move); MoveArrays.KingTotalMoves[index]++; } row = x; col = y; if (row > 0) { row--; move = Position(col, row); moveset.Moves.Add(move); MoveArrays.KingTotalMoves[index]++; } row = x; col = y; if (col > 0) { col--; move = Position(col, row); moveset.Moves.Add(move); MoveArrays.KingTotalMoves[index]++; } row = x; col = y; if (col < 7) { col++; move = Position(col, row); moveset.Moves.Add(move); MoveArrays.KingTotalMoves[index]++; } row = x; col = y; if (row < 7 && col < 7) { row++; col++; move = Position(col, row); moveset.Moves.Add(move); MoveArrays.KingTotalMoves[index]++; } row = x; col = y; if (row < 7 && col > 0) { row++; col--; move = Position(col, row); moveset.Moves.Add(move); MoveArrays.KingTotalMoves[index]++; } row = x; col = y; if (row > 0 && col < 7) { row--; col++; move = Position(col, row); moveset.Moves.Add(move); MoveArrays.KingTotalMoves[index]++; } row = x; col = y; if (row > 0 && col > 0) { row--; col--; move = Position(col, row); moveset.Moves.Add(move); MoveArrays.KingTotalMoves[index]++; } MoveArrays.KingMoves[index] = moveset; } } }