fixup
This commit is contained in:
9
chess.c
9
chess.c
@@ -6,7 +6,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define E 0 /* empty */
|
|
||||||
|
#define E 0 /* empty */
|
||||||
#define K 1 /* king */
|
#define K 1 /* king */
|
||||||
#define Q 2 /* queen */
|
#define Q 2 /* queen */
|
||||||
#define R 3 /* rook */
|
#define R 3 /* rook */
|
||||||
@@ -23,6 +24,7 @@ void print_board(int* board);
|
|||||||
void init_board(int* board);
|
void init_board(int* board);
|
||||||
void do_turn(int turn_no, int* board);
|
void do_turn(int turn_no, int* board);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* main
|
* main
|
||||||
*/
|
*/
|
||||||
@@ -119,7 +121,7 @@ void print_board(int* board){
|
|||||||
* Resets/inits the board
|
* Resets/inits the board
|
||||||
*/
|
*/
|
||||||
void init_board(int *board){
|
void init_board(int *board){
|
||||||
|
|
||||||
// black pieces are prefixed by a minus (-)
|
// black pieces are prefixed by a minus (-)
|
||||||
const int start[] = {
|
const int start[] = {
|
||||||
-R,-N,-B,-Q,-K,-B,-N,-R,
|
-R,-N,-B,-Q,-K,-B,-N,-R,
|
||||||
@@ -190,13 +192,12 @@ int get_piece(char *str){
|
|||||||
|
|
||||||
if( 'A' <= c && c <= 'H' ){
|
if( 'A' <= c && c <= 'H' ){
|
||||||
x = c - 'A';
|
x = c - 'A';
|
||||||
}else if( '1' <= c && c <= '8'){
|
}else if('1' <= c && c <= '8'){
|
||||||
y = c - '1';
|
y = c - '1';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(x != -1 && y != -1){
|
if(x != -1 && y != -1){
|
||||||
printf("%i", 8*(8-y) + x);
|
|
||||||
return 8*(7-y) + x;
|
return 8*(7-y) + x;
|
||||||
}else{
|
}else{
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user