Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e065007
seems like the socket connection from the frontend simulator to backe…
MahdMalik Feb 14, 2026
2bab495
took forever, but fixed the issue of simulator not updating when the …
MahdMalik Feb 15, 2026
c40271a
gonna merge having piece type attributes into this for my next ingeni…
MahdMalik Feb 15, 2026
5d6256f
Piece type attribute (#269)
MahdMalik Feb 15, 2026
b847ac9
got the FEIN algorithm done for dynamically determinign robot default…
MahdMalik Feb 15, 2026
4e9d530
fixed issue with board not being updated when default position was tu…
MahdMalik Feb 15, 2026
1e41d47
alright checked everything, this should be good to push now
MahdMalik Feb 16, 2026
4a0c992
added comments and ran the format + link checker
MahdMalik Feb 16, 2026
1449c69
finished making changes
MahdMalik Feb 21, 2026
17c3867
Merge branch 'main' of https://github.com/Comet-Robotics/chessbots-se…
MahdMalik Feb 21, 2026
47c8e72
Merge branch 'main' of https://github.com/Comet-Robotics/chessbots-se…
MahdMalik Feb 21, 2026
2a43ff6
Merge branch 'main' of https://github.com/Comet-Robotics/chessbots-se…
MahdMalik Feb 21, 2026
e384217
Merge branch 'main' of https://github.com/Comet-Robotics/chessbots-se…
MahdMalik Feb 21, 2026
2da6c0e
fixed two issues
MahdMalik Feb 21, 2026
bf13bd4
queue works!
MahdMalik Feb 21, 2026
3ea21fc
fixed lint and format error
MahdMalik Feb 21, 2026
e114312
ok now fixed
MahdMalik Feb 21, 2026
7075c51
found an error with black side queen castling lol. Fixed now. I reall…
MahdMalik Feb 23, 2026
0d39d95
a couple qualms about the shimmying algo, but it's not blatantly obvi…
MahdMalik Feb 23, 2026
078db32
add formatting
MahdMalik Feb 23, 2026
c12d8ff
goo goo ga ga
MahdMalik Feb 23, 2026
4763e68
goo goo ga ga
MahdMalik Feb 24, 2026
0366019
alright, fixes stalemate/win/lose apearing early issue
MahdMalik Apr 12, 2026
9f5e522
Merge branch 'robot-reset' of https://github.com/Comet-Robotics/chess…
MahdMalik Apr 12, 2026
3073e79
i can taste the finish lin, i just need to not fall asleep
MahdMalik Apr 12, 2026
c49e1ea
things will work first try trust
MahdMalik Apr 12, 2026
ee311bb
CHESSBOTS BEGINS NOW!!!
MahdMalik Apr 12, 2026
92dddb4
Various fixes
ymmot239 Apr 16, 2026
b52d66f
robot reset
MahdMalik Apr 19, 2026
008fa3d
"/game-state"
MahdMalik Apr 19, 2026
d1a60f4
Banquet merge (#280)
MahdMalik Apr 19, 2026
62d69cd
just need to get on game end logic fixed and we're good!
MahdMalik Apr 19, 2026
ca972fe
HEXAPAWN MATPAT WORKS (I THINK, I DON'T WANNA TEST IT
MahdMalik Apr 19, 2026
4dc301c
centering code
ymmot239 Apr 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .yarn/install-state.gz
Binary file not shown.
135 changes: 135 additions & 0 deletions .yarn/patches/react-chessboard-npm-4.7.3-53276f9bfb.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
diff --git a/dist/index.esm.js b/dist/index.esm.js
index 3267047874ff62812505a97c7a96d3fae7a8e220..0992869f2bc525d938ad60815cd0630895a02bac 100644
--- a/dist/index.esm.js
+++ b/dist/index.esm.js
@@ -69,9 +69,9 @@ const WHITE_COLUMN_VALUES = {
c: 2,
d: 3,
e: 4,
- f: 5,
- g: 6,
- h: 7,
+ f: 0,
+ g: 1,
+ h: 2,
};
const BLACK_COLUMN_VALUES = {
a: 7,
@@ -83,8 +83,8 @@ const BLACK_COLUMN_VALUES = {
g: 1,
h: 0,
};
-const WHITE_ROWS = [7, 6, 5, 4, 3, 2, 1, 0];
-const BLACK_ROWS = [0, 1, 2, 3, 4, 5, 6, 7];
+const WHITE_ROWS = [2, 1, 0];
+const BLACK_ROWS = [0, 1, 2];

// https://commons.wikimedia.org/wiki/Category:SVG_chess_pieces
// By en:User:Cburnett - Own work
@@ -778,19 +778,19 @@ function Notation({ row, col }) {
const whiteColor = customLightSquareStyle.backgroundColor;
const blackColor = customDarkSquareStyle.backgroundColor;
const isRow = col === 0;
- const isColumn = row === 7;
+ const isColumn = row === 2;
const isBottomLeftSquare = isRow && isColumn;
function getRow() {
- return boardOrientation === "white" ? 8 - row : row + 1;
+ return boardOrientation === "white" ? 3 - row : row + 1;
}
function getColumn() {
return boardOrientation === "black" ? COLUMNS[7 - col] : COLUMNS[col];
}
function renderBottomLeft() {
- return (jsxs(Fragment, { children: [jsx("div", Object.assign({ style: Object.assign(Object.assign({ zIndex: 3, position: "absolute" }, { color: whiteColor }), numericStyle(boardWidth, customNotationStyle)) }, { children: getRow() })), jsx("div", Object.assign({ style: Object.assign(Object.assign({ zIndex: 3, position: "absolute" }, { color: whiteColor }), alphaStyle(boardWidth, customNotationStyle)) }, { children: getColumn() }))] }));
+ return (jsxs(Fragment, { children: [jsx("div", Object.assign({ style: Object.assign(Object.assign({ zIndex: 3, position: "absolute" }, { color: blackColor }), numericStyle(boardWidth, customNotationStyle)) }, { children: getRow() })), jsx("div", Object.assign({ style: Object.assign(Object.assign({ zIndex: 3, position: "absolute" }, { color: blackColor }), alphaStyle(boardWidth, customNotationStyle)) }, { children: getColumn() }))] }));
}
function renderLetters() {
- return (jsx("div", Object.assign({ style: Object.assign(Object.assign({ userSelect: "none", zIndex: 3, position: "absolute" }, { color: col % 2 !== 0 ? blackColor : whiteColor }), alphaStyle(boardWidth, customNotationStyle)) }, { children: getColumn() })));
+ return (jsx("div", Object.assign({ style: Object.assign(Object.assign({ userSelect: "none", zIndex: 3, position: "absolute" }, { color: col % 2 === 0 ? blackColor : whiteColor }), alphaStyle(boardWidth, customNotationStyle)) }, { children: getColumn() })));
}
function renderNumbers() {
return (jsx("div", Object.assign({ style: Object.assign(Object.assign({ userSelect: "none", zIndex: 3, position: "absolute" }, (boardOrientation === "black"
@@ -4844,15 +4844,15 @@ function Squares() {
});
return result;
}, [premoves]);
- return (jsx("div", Object.assign({ "data-boardid": id }, { children: [...Array(8)].map((_, r) => {
+ return (jsx("div", Object.assign({ "data-boardid": id }, { children: [...Array(3)].map((_, r) => {
return (jsx("div", Object.assign({ style: {
display: "flex",
flexWrap: "nowrap",
width: boardWidth,
- } }, { children: [...Array(8)].map((_, c) => {
+ } }, { children: [...Array(3)].map((_, c) => {
const square = boardOrientation === "black"
- ? (COLUMNS[7 - c] + (r + 1))
- : (COLUMNS[c] + (8 - r));
+ ? (COLUMNS[2 - c] + (r + 2))
+ : (COLUMNS[c] + (4 - r));
const squareColor = c % 2 === r % 2 ? "white" : "black";
const squareHasPremove = premoves.find((p) => p.sourceSq === square || p.targetSq === square);
const squareHasPremoveTarget = premovesHistory
diff --git a/dist/index.js b/dist/index.js
index a55a978e1a9de9b7eb3ec174177fc60186384931..fddcb4cc3fdd5ff2697ab748afc24bf4a58da8fb 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -30,7 +30,7 @@ function __rest(s, e) {
return t;
}

-const COLUMNS = "abcdefgh".split("");
+const COLUMNS = "abc".split("");
const START_POSITION_OBJECT = {
a8: "bR",
b8: "bN",
@@ -69,24 +69,14 @@ const WHITE_COLUMN_VALUES = {
a: 0,
b: 1,
c: 2,
- d: 3,
- e: 4,
- f: 5,
- g: 6,
- h: 7,
};
const BLACK_COLUMN_VALUES = {
- a: 7,
- b: 6,
- c: 5,
- d: 4,
- e: 3,
- f: 2,
- g: 1,
- h: 0,
+ a: 2,
+ b: 1,
+ c: 0,
};
-const WHITE_ROWS = [7, 6, 5, 4, 3, 2, 1, 0];
-const BLACK_ROWS = [0, 1, 2, 3, 4, 5, 6, 7];
+const WHITE_ROWS = [2, 1, 0];
+const BLACK_ROWS = [0, 1, 2];

// https://commons.wikimedia.org/wiki/Category:SVG_chess_pieces
// By en:User:Cburnett - Own work
@@ -4846,15 +4836,15 @@ function Squares() {
});
return result;
}, [premoves]);
- return (jsxRuntime.jsx("div", Object.assign({ "data-boardid": id }, { children: [...Array(8)].map((_, r) => {
+ return (jsxRuntime.jsx("div", Object.assign({ "data-boardid": id }, { children: [...Array(3)].map((_, r) => {
return (jsxRuntime.jsx("div", Object.assign({ style: {
display: "flex",
flexWrap: "nowrap",
width: boardWidth,
- } }, { children: [...Array(8)].map((_, c) => {
+ } }, { children: [...Array(3)].map((_, c) => {
const square = boardOrientation === "black"
- ? (COLUMNS[7 - c] + (r + 1))
- : (COLUMNS[c] + (8 - r));
+ ? (COLUMNS[2 - c] + (r + 1))
+ : (COLUMNS[c] + (3 - r));
const squareColor = c % 2 === r % 2 ? "white" : "black";
const squareHasPremove = premoves.find((p) => p.sourceSq === square || p.targetSq === square);
const squareHasPremoveTarget = premovesHistory
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"name": "utd-chess-bots",
"private": true,
"version": "0.0.0",
"workspaces": ["src/client", "src/server"],
"workspaces": [
"src/client",
"src/server"
],
"scripts": {
"dev": "ts-node src/server/main.ts",
"devup": "nodemon src/server/main.ts",
Expand Down Expand Up @@ -44,5 +47,5 @@
"optionalDependencies": {
"bufferutil": "^4.0.8"
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
"packageManager": "yarn@4.13.0"
}
2 changes: 1 addition & 1 deletion src/client/chessboard/chessboard-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function ChessboardWrapper(props: ChessboardWrapperProps): JSX.Element {
<Chessboard
// set up the board
boardOrientation={side === Side.WHITE ? "white" : "black"}
boardWidth={width}
boardWidth={width*2}
position={chess.fen}
// do a promotion check
onPromotionCheck={(from: Square, to: Square) => {
Expand Down
4 changes: 3 additions & 1 deletion src/client/debug/simulator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ export function Simulator() {
};

useEffect(() => {
fetchRobotState();
setInterval(() => {
fetchRobotState();
}, 500);
}, []);

// get /do-smth to move the robot randomly
Expand Down
21 changes: 15 additions & 6 deletions src/client/game/game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,22 @@ export function Game(): JSX.Element {
);

// checks if a game is currently active
const { isPending, data, isError } = useEffectQuery(
const {
isPending,
data: gameState,
isError,
} = useEffectQuery(
"game-state",
async () => {
return get("/game-state").then((gameState) => {
setChess(new ChessEngine(gameState.position));
// console.log("GAMESTATE ACQUIRED!");
// console.log(gameState);
setChess(new ChessEngine(gameState.type === "puzzle", gameState.position));
setPause(gameState.pause);
if (gameState.gameEndReason !== undefined) {
setGameInterruptedReason(gameState.gameEndReason);
}
return gameState.state;
return gameState;
});
},
false,
Expand All @@ -126,10 +132,12 @@ export function Game(): JSX.Element {
);
// go to /home if error
} else if (isError) {
console.log(isError);
console.log("error");
return <Navigate to="/home" />;
}

const side = data.side;
const side = gameState.side;

// check if the game has ended or been interrupted
let gameEndReason: GameEndReason | undefined = undefined;
Expand Down Expand Up @@ -178,6 +186,7 @@ export function Game(): JSX.Element {
(move: Move): void => {
setChess(chess.copy(move));
sendMessage(new MoveMessage(move));
window.location.reload();
}
: () => {}; //send a do-nothing function if game is paused

Expand All @@ -187,8 +196,8 @@ export function Game(): JSX.Element {
<NavbarMenu
sendMessage={sendMessage}
side={side}
difficulty={data.difficulty}
aiDifficulty={data.aiDifficulty}
difficulty={gameState.difficulty}
aiDifficulty={gameState.aiDifficulty}
setRotation={setRotation}
/>

Expand Down
2 changes: 1 addition & 1 deletion src/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"interactjs": "^1.10.27",
"motion": "^12.6.0",
"react": "^18.2.0",
"react-chessboard": "^4.5.0",
"react-chessboard": "patch:react-chessboard@npm%3A4.7.3#~/.yarn/patches/react-chessboard-npm-4.7.3-53276f9bfb.patch",
"react-dom": "^18.2.0",
"react-joystick-component": "^6.2.1",
"react-router-dom": "^6.21.3",
Expand Down
6 changes: 5 additions & 1 deletion src/client/setup/setup-game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,14 @@ export function SetupGame(props: SetupGameProps) {
side: selectedSide,
difficulty: difficulty.toString(),
});
} else {
} else if (props.gameType === GameType.HUMAN){
promise = post("/start-human-game", {
side: selectedSide,
});
} else{
promise = post("/start-hexapawn-game", {
side: selectedSide,
});
}
promise.then(() => {
navigate("/game");
Expand Down
14 changes: 12 additions & 2 deletions src/client/setup/setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum SetupType {
COMPUTER = "computer",
HUMAN = "human",
PUZZLE = "puzzle",
HEXAPAWN = "hexapawn",
}

/**
Expand Down Expand Up @@ -60,13 +61,14 @@ export function Setup(): JSX.Element {
: null}
{(
setupType === SetupType.COMPUTER ||
setupType === SetupType.HUMAN
setupType === SetupType.HUMAN ||
setupType === SetupType.HEXAPAWN
) ?
<SetupGame
gameType={
setupType === SetupType.COMPUTER ?
GameType.COMPUTER
: GameType.HUMAN
: setupType === SetupType.HUMAN ? GameType.HUMAN : GameType.HEXAPAWN
}
/>
: null}
Expand Down Expand Up @@ -132,6 +134,14 @@ function SetupMain(props: SetupMainProps) {
onClick={() => props.onPageChange(SetupType.PUZZLE)}
className={buttonColor()}
/>
<Button
large
text="Hexapawn"
rightIcon="arrow-right"
intent="primary"
onClick={() => props.onPageChange(SetupType.HEXAPAWN)}
className={buttonColor()}
/>
<ThemeButtons />
</>
);
Expand Down
4 changes: 4 additions & 0 deletions src/client/setup/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ export function Sidebar(props: sidebarProps): JSX.Element {
"get-queue",
async () => {
const newQueue = await get("/get-queue");
// console.log("queue data:")
// console.log(newQueue)
setQueue(newQueue);
// console.log("Set queue went fine");
return newQueue;
},
true,
);
Expand Down
10 changes: 8 additions & 2 deletions src/common/chess-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ import type { RobotManager } from "../server/robot/robot-manager";
*/
export class ChessEngine {
private chess: Chess;
private isPuzzle: boolean;

/**
* @param pgn - The pgn to use. If undefined, a new game is created.
*/
constructor(pgn?: string) {
constructor(isPuzzle: boolean = false, pgn?: string) {
this.chess = new Chess();
this.isPuzzle = isPuzzle;
if (pgn !== undefined) {
this.chess.loadPgn(pgn);
}
Expand All @@ -31,7 +33,7 @@ export class ChessEngine {
* @param move - A move to make.
*/
copy(move?: Move): ChessEngine {
const copy = new ChessEngine();
const copy = new ChessEngine(this.isPuzzle, this.pgn);
copy.loadPgn(this.pgn);
if (move !== undefined) {
copy.makeMove(move);
Expand Down Expand Up @@ -273,6 +275,10 @@ export class ChessEngine {
* @returns - a game finished reason from the enum
*/
getGameFinishedReason(): GameFinishedReason | undefined {
if (this.isPuzzle) {
return undefined;
}

if (this.chess.isCheckmate()) {
// If it's your turn, you lost
return this.chess.turn() === "w" ?
Expand Down
1 change: 1 addition & 0 deletions src/common/client-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ export enum Difficulty {
export enum GameType {
COMPUTER = "computer",
HUMAN = "human",
HEXAPAWN = "hexapawn",
}
Loading
Loading