summaryrefslogtreecommitdiff
path: root/chess.c
diff options
context:
space:
mode:
Diffstat (limited to 'chess.c')
-rw-r--r--chess.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/chess.c b/chess.c
index b913536..92277dc 100644
--- a/chess.c
+++ b/chess.c
@@ -6,7 +6,13 @@
#include "chesshelpers.h"
#include "chess.h"
-int main() {
+int main(int argc, char **argv) {
+ if(argc == 2) {
+ if(strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0) {
+ printf("Version 1.0.0\n");
+ exit(0);
+ }
+ }
//set up the board
int boardA[8][8] = {
{ rook + 6, pawn + 6, 0, 0, 0, 0, pawn, rook },
@@ -198,7 +204,6 @@ vectorp_t get_moves_final(board_t board, vector_t position, piece_t piece) {
free(moves.vectors);
return finalMoves;
}
-//TODO: add en passant
vectorp_t get_pawn_moves(board_t board, vector_t position, int color) {
vector_t* moves = malloc(6 * sizeof(vector_t));
int moveCount = 0;
@@ -216,12 +221,12 @@ vectorp_t get_pawn_moves(board_t board, vector_t position, int color) {
}
}
vector_t captureL = init_vector(position.mx - 1, position.my + forwardDir);
- if(in_board(captureL) && is_color(board, captureL, !color)) {
+ if(in_board(captureL) && (is_color(board, captureL, !color) || would_have_been_pawn(board, captureL, !color))) {
moves[moveCount] = captureL;
moveCount++;
}
vector_t captureR = init_vector(position.mx + 1, position.my + forwardDir);
- if(in_board(captureR) && is_color(board, captureR, !color)) {
+ if(in_board(captureR) && (is_color(board, captureR, !color) || would_have_been_pawn(board, captureR, !color))) {
moves[moveCount] = captureR;
moveCount++;
}