Skip to content

Commit

Permalink
RAHHHHH
Browse files Browse the repository at this point in the history
  • Loading branch information
ellenjxu committed Mar 20, 2024
1 parent e82a0f0 commit 445ed1d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
3 changes: 3 additions & 0 deletions brain.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static void paint_cursor(void) {
int visual_cursor_y = CHESS_SIZE - module.cursor_y - 1;
#endif
chess_gui_draw_cursor(visual_cursor_x, visual_cursor_y, is_piece_moved);
// printf("Cursor: %d, %d\n", visual_cursor_x, visual_cursor_y);
}

static void update_cursor(void *aux_data, const uint8_t *message, size_t len) {
Expand Down Expand Up @@ -123,6 +124,7 @@ static void button_press(void *aux_data, const uint8_t *message, size_t len) {

char your_move[8];
chess_get_move(your_move, sizeof(your_move)); // get stockfish move
// printf("Your move: %s\n", your_move);
if (strcmp(your_move, "NOPE\n") != 0) {
chess_gui_update(opp_move, false);
chess_gui_update(your_move, true);
Expand All @@ -137,6 +139,7 @@ static void button_press(void *aux_data, const uint8_t *message, size_t len) {
}

module.state = (module.state + 1) % 5; // next state
// printf("State: %d\n", module.state);

if (module.state == LISTENING_X1) { // show selected on button bress
paint_cursor();
Expand Down
34 changes: 18 additions & 16 deletions chess_gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ static void draw_stat(const char *label, char *number, int line) {
static void sidebar_draw(void) {
static const char *HEADERS[] = {
"Mango Chess",
"(100% Legit)",
"(Totally Legit)",
"",
"Javier&Ellen",
"Javier & Ellen",
"CS107E W2024",
"",
};
Expand Down Expand Up @@ -317,19 +317,19 @@ static void sidebar_draw(void) {
line++;
line++;

draw_text_centered(
"Stats:",
SQUARE_SIZE * 8,
(char_h + V_PADDING) * line,
SCREEN_WIDTH - SQUARE_SIZE * 8,
SIDEBAR_FT
);
// draw_text_centered(
// "Stats:",
// SQUARE_SIZE * 8,
// (char_h + V_PADDING) * line,
// SCREEN_WIDTH - SQUARE_SIZE * 8,
// SIDEBAR_FT
// );

line++;
// line++;

draw_stat("Win: ", sidebar.W, line++);
draw_stat("Draw: ", sidebar.D, line++);
draw_stat("Lose: ", sidebar.L, line++);
// draw_stat("Win: ", sidebar.W, line++);
// draw_stat("Draw: ", sidebar.D, line++);
// draw_stat("Lose: ", sidebar.L, line++);

line += 2;

Expand All @@ -344,12 +344,12 @@ static void sidebar_draw(void) {

for (; i < nmoves; i++) {
gl_draw_string(
SQUARE_SIZE * 8 + H_PADDING + (i % 2) * (SCREEN_WIDTH - SQUARE_SIZE) / 2,
SQUARE_SIZE * 8 + H_PADDING + (i % 2) * (SCREEN_WIDTH - SQUARE_SIZE*8) / 2,
(char_h + V_PADDING) * line,
move_history[i],
SIDEBAR_FT
);
line++;
if (i%2 == 1) line++;
}

}
Expand Down Expand Up @@ -418,6 +418,8 @@ void chess_gui_draw_cursor(int cursor_col, int cursor_row, bool is_piece_chosen)
if (is_piece_chosen && !cursor.has_chosen) {
cursor.chosen_col = cursor.col;
cursor.chosen_row = cursor.row;
} else if (!is_piece_chosen && cursor.has_chosen) {
stale_everything();
}

stale[cursor.row][cursor.col] = 1;
Expand Down Expand Up @@ -540,7 +542,7 @@ void chess_gui_print(void) {
}

void chess_gui_init(void) {
gl_init(SCREEN_WIDTH, SCREEN_HEIGHT, GL_DOUBLEBUFFER);
gl_init(SCREEN_WIDTH, SCREEN_HEIGHT, GL_SINGLEBUFFER);
memcpy(board, STARTING_BOARD, sizeof(STARTING_BOARD));

sidebar.W[0] = sidebar.D[0] = sidebar.L[0] = '*';
Expand Down
2 changes: 1 addition & 1 deletion engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def send_move(move):
stockfish.make_moves_from_current_position([best_move])

print("Stockfish move: ", best_move)
stats()
# stats()
send_move(best_move)

# except serial.serialutil.SerialException:
Expand Down

0 comments on commit 445ed1d

Please sign in to comment.