From 9a02e21fb86e597eb06ab4ee2030a33ebcbf7ef0 Mon Sep 17 00:00:00 2001 From: Noah Heath Date: Tue, 19 Dec 2023 18:19:39 -0500 Subject: [PATCH] Not needed --- .../chessserver3/model/computer/BitBoard.java | 116 ------------------ .../chessserver3/model/computer/MoveMaps.java | 6 - .../chessserver3/model/computer/Piece.java | 29 ----- .../chessserver3/model/computer/Pieces.java | 95 -------------- 4 files changed, 246 deletions(-) delete mode 100644 src/main/java/com/example/chessserver3/model/computer/BitBoard.java delete mode 100644 src/main/java/com/example/chessserver3/model/computer/MoveMaps.java delete mode 100644 src/main/java/com/example/chessserver3/model/computer/Piece.java delete mode 100644 src/main/java/com/example/chessserver3/model/computer/Pieces.java diff --git a/src/main/java/com/example/chessserver3/model/computer/BitBoard.java b/src/main/java/com/example/chessserver3/model/computer/BitBoard.java deleted file mode 100644 index e482c93..0000000 --- a/src/main/java/com/example/chessserver3/model/computer/BitBoard.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.example.chessserver3.model.computer; - -import lombok.NoArgsConstructor; - -import java.util.ArrayList; -import java.util.List; - -@NoArgsConstructor -public class BitBoard { - - private boolean[][] bitMap = new boolean[8][8]; - - public static BitBoard pieces(char[][] rows) { - BitBoard pieces = new BitBoard(); - for (byte i=0; i<8; i++) { - byte j = 0; - for (char k : rows[i]) { - if (Character.isDigit(k)) { - j += (byte) (k - 48); - } else { - pieces.on(i, j); - j++; - } - } - } - return pieces; - } - - public static BitBoard whitePieces(char[][] rows) { - BitBoard whitePieces = new BitBoard(); - for (byte i=0; i<8; i++) { - byte j = 0; - for (char k : rows[i]) { - if (Character.isDigit(k)) { - j += (byte) (k - 48); - } else { - if (Character.isUpperCase(k)) { - whitePieces.on(i, j); - } - j++; - } - } - } - return whitePieces; - } - - public static BitBoard blackPieces(char[][] rows) { - BitBoard blackPieces = new BitBoard(); - for (byte i=0; i<8; i++) { - byte j = 0; - for (char k : rows[i]) { - if (Character.isDigit(k)) { - j += (byte) (k - 48); - } else { - if (Character.isLowerCase(k)) { - blackPieces.on(i, j); - } - j++; - } - } - } - return blackPieces; - } - - private void on(byte i, byte j) { - bitMap[i][j] = true; - } - - private void off(byte i, byte j) { - bitMap[i][j] = false; - } - - private void allOn() { - for (byte i=0; i<8; i++) { - for (byte j=0; j<8; j++) { - bitMap[i][j] = true; - } - } - } - - private void allOff() { - for (byte i=0; i<8; i++) { - for (byte j=0; j<8; j++) { - bitMap[i][j] = false; - } - } - } - - public boolean get(byte i, byte j) { - return bitMap[i][j]; - } - - private List getAllOn() { - List spots = new ArrayList<>(); - for (byte i=0; i<8; i++) { - for (byte j=0; j<8; j++) { - if (bitMap[i][j]) { - spots.add(new byte[]{i, j}); - } - } - } - return spots; - } - - private List getAllOff() { - List spots = new ArrayList<>(); - for (byte i=0; i<8; i++) { - for (byte j=0; j<8; j++) { - if (!bitMap[i][j]) { - spots.add(new byte[]{i, j}); - } - } - } - return spots; - } -} diff --git a/src/main/java/com/example/chessserver3/model/computer/MoveMaps.java b/src/main/java/com/example/chessserver3/model/computer/MoveMaps.java deleted file mode 100644 index 85fd546..0000000 --- a/src/main/java/com/example/chessserver3/model/computer/MoveMaps.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.example.chessserver3.model.computer; - -public enum MoveMaps { - - KNIGHT() -} diff --git a/src/main/java/com/example/chessserver3/model/computer/Piece.java b/src/main/java/com/example/chessserver3/model/computer/Piece.java deleted file mode 100644 index 1813bb4..0000000 --- a/src/main/java/com/example/chessserver3/model/computer/Piece.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.example.chessserver3.model.computer; - -import com.example.chessserver3.model.board.Board; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.util.ArrayList; -import java.util.List; - -@Getter -@AllArgsConstructor -public class Piece { - - private char key; - private byte row; - private byte col; - -// public static List generateMoves(Piece p, BitBoard whitePieces, BitBoard blackPieces) { -// List moves; -// switch (p.key) { -// case 'k', 'K' -> moves = kingMoves(p, whitePieces, blackPieces); -// } -// } -// -// public static List kingMoves(Piece p, BitBoard whitePieces, BitBoard blackPieces) { -// List moves = new ArrayList<>(); -// -// } -} diff --git a/src/main/java/com/example/chessserver3/model/computer/Pieces.java b/src/main/java/com/example/chessserver3/model/computer/Pieces.java deleted file mode 100644 index 65293fb..0000000 --- a/src/main/java/com/example/chessserver3/model/computer/Pieces.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.example.chessserver3.model.computer; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -public class Pieces { - - public static final HashMap> moves = new HashMap<>(); - private final static boolean[][] kingSpots = {{false,true,true,true,false},{true,true,false,true,true},{false,true,true,true,false}}; - private final static boolean[][] whitePawnSpots = {{false,true,false},{true,true,true},{false,false,false}}; - private final static boolean[][] blackPawnSpots = {{false,false,false},{true,true,true},{false,true,false}}; - private final static boolean[][] knightSpots = {{false,true,false,true,false},{true,false,false,false,true},{false,false,false,false,false},{true,false,false,false,true},{false,true,false,true,false}}; - private final static boolean[][] bishopSpots = new boolean[15][15]; - private final static boolean[][] rookSpots = new boolean[15][15]; - private final static boolean[][] queenSpots = new boolean[15][15]; - public final static HashMap pieceLocations = new HashMap<>(); - static { - pieceLocations.put('k', new byte[]{1,2}); - pieceLocations.put('K', new byte[]{1,2}); - pieceLocations.put('p', new byte[]{0,1}); - pieceLocations.put('P', new byte[]{2,1}); - pieceLocations.put('n', new byte[]{2,2}); - pieceLocations.put('N', new byte[]{2,2}); - pieceLocations.put('b', new byte[]{7,7}); - pieceLocations.put('B', new byte[]{7,7}); - pieceLocations.put('r', new byte[]{7,7}); - pieceLocations.put('R', new byte[]{7,7}); - pieceLocations.put('q', new byte[]{7,7}); - pieceLocations.put('Q', new byte[]{7,7}); - for (int i=0; i<15; i++) { - for (int j=0; j<15; j++) { - rookSpots[i][j] = false; - bishopSpots[i][j] = false; - queenSpots[i][j] = false; - } - } - for (byte i=0;i<15;i++) { - for (byte j=0;j<15;j++) { - if (i == 7 && j != 7) { - rookSpots[i][j] = true; - queenSpots[i][j] = true; - } - if (j == 7 && i != 7) { - rookSpots[i][j] = true; - queenSpots[i][j] = true; - } - if (i == j && i != 7) { - bishopSpots[i][j] = true; - queenSpots[i][j] = true; - } - if (i == 14 - j && i != 7) { - bishopSpots[i][j] = true; - queenSpots[i][j] = true; - } - } - } - } - - static { - for (byte i=0; i<8; i++) { - for (byte j=0; j<8; j++) { - generateMoves('k', kingSpots, i, j); - generateMoves('K', kingSpots, i, j); - generateMoves('q', queenSpots, i, j); - generateMoves('Q', queenSpots, i, j); - generateMoves('r', rookSpots, i, j); - generateMoves('R', rookSpots, i, j); - generateMoves('n', knightSpots, i, j); - generateMoves('N', knightSpots, i, j); - generateMoves('b', bishopSpots, i, j); - generateMoves('B', bishopSpots, i, j); - generateMoves('p', blackPawnSpots, i, j); - generateMoves('P', whitePawnSpots, i, j); - } - } - } - - public static void generateMoves(char key, boolean[][] spots, byte i, byte j) { - List pieceMoves = new ArrayList<>(); - for (byte k = 0; k < spots.length; k++) { - for (byte l = 0; l < spots[k].length; l++) { - if (spots[k][l]) { - byte row = (byte) (i + (k - pieceLocations.get(key)[0])); - byte col = (byte) (j + (l - pieceLocations.get(key)[1])); - if (row >= 0 && row < 8 && col >= 0 && col < 8 && !(row == i && col == j)) { - byte[] moveArray = {i, j, row, col}; - pieceMoves.add(moveArray); - } - } - } - } - moves.put(String.format("%c%x%x", key, i, j), pieceMoves); - } -}