private static void SetMovesBlackPawn() { for (byte index = 8; index <= 55; index++) { var moveset = new PieceMoveSet(new List <byte>()); var x = (byte)(index % 8); var y = (byte)(index / 8); //Diagonal Kill if (y < 7 && x < 7) { moveset.Moves.Add((byte)(index + 8 + 1)); MoveArrays.BlackPawnTotalMoves[index]++; } if (x > 0 && y < 7) { moveset.Moves.Add((byte)(index + 8 - 1)); MoveArrays.BlackPawnTotalMoves[index]++; } //One Forward moveset.Moves.Add((byte)(index + 8)); MoveArrays.BlackPawnTotalMoves[index]++; //Starting Position we can jump 2 if (y == 1) { moveset.Moves.Add((byte)(index + 16)); MoveArrays.BlackPawnTotalMoves[index]++; } MoveArrays.BlackPawnMoves[index] = moveset; } }
private static void SetMovesQueen() { for (byte y = 0; y < 8; y++) { for (byte x = 0; x < 8; x++) { var index = (byte)(y + x * 8); var moveset = new PieceMoveSet(new List <byte>()); byte move; var row = x; var col = y; while (row < 7) { row++; move = Position(col, row); moveset.Moves.Add(move); MoveArrays.QueenTotalMoves1[index]++; } MoveArrays.QueenMoves1[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.QueenTotalMoves2[index]++; } MoveArrays.QueenMoves2[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.QueenTotalMoves3[index]++; } MoveArrays.QueenMoves3[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.QueenTotalMoves4[index]++; } MoveArrays.QueenMoves4[index] = moveset; moveset = new PieceMoveSet(new List <byte>()); row = x; col = y; while (row < 7 && col < 7) { row++; col++; move = Position(col, row); moveset.Moves.Add(move); MoveArrays.QueenTotalMoves5[index]++; } MoveArrays.QueenMoves5[index] = moveset; moveset = new PieceMoveSet(new List <byte>()); row = x; col = y; while (row < 7 && col > 0) { row++; col--; move = Position(col, row); moveset.Moves.Add(move); MoveArrays.QueenTotalMoves6[index]++; } MoveArrays.QueenMoves6[index] = moveset; moveset = new PieceMoveSet(new List <byte>()); row = x; col = y; while (row > 0 && col < 7) { row--; col++; move = Position(col, row); moveset.Moves.Add(move); MoveArrays.QueenTotalMoves7[index]++; } MoveArrays.QueenMoves7[index] = moveset; moveset = new PieceMoveSet(new List <byte>()); row = x; col = y; while (row > 0 && col > 0) { row--; col--; move = Position(col, row); moveset.Moves.Add(move); MoveArrays.QueenTotalMoves8[index]++; } MoveArrays.QueenMoves8[index] = moveset; } } }
private static void SetMovesKing() { for (byte y = 0; y < 8; y++) { for (byte x = 0; x < 8; x++) { var index = (byte)(y + x * 8); var moveset = new PieceMoveSet(new List <byte>()); byte move; var row = x; var 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; } } }
private static void SetMovesKnight() { for (byte y = 0; y < 8; y++) { for (byte x = 0; x < 8; x++) { var 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; } } }