Commit e93caa1c authored by Radia EL HAMDOUNI's avatar Radia EL HAMDOUNI

Upload New File

parent e8c46c05
// Libraries
#include<stdio.h>
// files
#include "board.h"
#include "fen.c"
// Print the board to the console
void show_board(){
// pint new line
printf("\n\n\n");
// A rank is a line
// A file is a column
for(int i = 0 ; i<8 ; i++){//loop over the ranks
for(int j=0;j<16;j++ ){// loop over the files
int square = 16 * i + j;
if(j == 0){
printf("%d " , 8-i); // print ranks
}
// print the board's valid quares
if(!(square & 0x88)){
printf("%s" ,chess_pieces[board[square]]);
}
}
printf("\n");
}
printf("\n a b c d e f g h \n\n\n"); // print files
}
// reset the board => remove all the pieces
void reset(){
for(int i = 0 ; i<8 ; i++){//loop over the ranks
for(int j=0;j<16;j++ ){// loop over the files
int square = 16 * i + j;
// print the board's valid quares
if(!(square & 0x88)){
board[square] = e;
}
}
}
}
// Main
int main(){
// moving chess pieces
board[e2] = e;
show_board();
board[e4] = p;
show_board();
reset();
show_board();
printf("\n");
return 1;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment