add license information & rename typedefs
This commit is contained in:
@@ -1,3 +1,16 @@
|
||||
/* position.c - position management.
|
||||
*
|
||||
* Copyright (C) 2021 Bruno Raoult ("br")
|
||||
* Licensed under the GNU General Public License v3.0 or later.
|
||||
* Some rights reserved. See COPYING.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this
|
||||
* program. If not, see <https://www.gnu.org/licenses/gpl-3.0-standalone.htmlL>.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later <https://spdx.org/licenses/GPL-3.0-or-later.html>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
@@ -42,11 +55,11 @@ inline static char piece2char(unsigned char p)
|
||||
|
||||
}
|
||||
|
||||
void pos_print(POS *pos)
|
||||
void pos_print(pos_t *pos)
|
||||
{
|
||||
int rank, file;
|
||||
piece_t piece;
|
||||
BOARD *board = pos->board;
|
||||
board_t *board = pos->board;
|
||||
|
||||
printf(" +---+---+---+---+---+---+---+---+\n");
|
||||
for (rank = 7; rank >= 0; --rank) {
|
||||
@@ -63,10 +76,10 @@ void pos_print(POS *pos)
|
||||
if (pos->en_passant == 0)
|
||||
printf("None.\n");
|
||||
else
|
||||
printf("%d %d = %c%c\n", SQUARE_F(pos->en_passant),
|
||||
SQUARE_R(pos->en_passant),
|
||||
FILE2C(SQUARE_F(pos->en_passant)),
|
||||
RANK2C(SQUARE_R(pos->en_passant)));
|
||||
printf("%d %d = %c%c\n", GET_F(pos->en_passant),
|
||||
GET_R(pos->en_passant),
|
||||
FILE2C(GET_F(pos->en_passant)),
|
||||
RANK2C(GET_R(pos->en_passant)));
|
||||
|
||||
printf("castle [%#x] : ", pos->castle);
|
||||
|
||||
@@ -83,10 +96,10 @@ void pos_print(POS *pos)
|
||||
printf("Current move = %d\n", pos->curmove);
|
||||
}
|
||||
|
||||
POS *pos_init(POS *pos)
|
||||
pos_t *pos_init(pos_t *pos)
|
||||
{
|
||||
int file, rank;
|
||||
BOARD *board = pos->board;
|
||||
board_t *board = pos->board;
|
||||
|
||||
for (rank = 0; rank < 8; ++rank) {
|
||||
for (file = 0; file < 8; ++file) {
|
||||
@@ -95,7 +108,7 @@ POS *pos_init(POS *pos)
|
||||
}
|
||||
}
|
||||
|
||||
pos->turn = TURN_WHITE;
|
||||
pos->turn = WHITE;
|
||||
pos->castle = 0;
|
||||
pos->clock_50 = 0;
|
||||
pos->curmove = 0;
|
||||
@@ -105,18 +118,18 @@ POS *pos_init(POS *pos)
|
||||
return pos;
|
||||
}
|
||||
|
||||
POS *pos_startpos(POS *pos)
|
||||
pos_t *pos_startpos(pos_t *pos)
|
||||
{
|
||||
static char *startfen="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
|
||||
|
||||
return fen2pos(pos, startfen);
|
||||
}
|
||||
|
||||
POS *pos_create()
|
||||
pos_t *pos_create()
|
||||
{
|
||||
POS *pos = malloc(sizeof(POS));
|
||||
pos_t *pos = malloc(sizeof(pos_t));
|
||||
if (pos) {
|
||||
pos->board = malloc(sizeof (BOARD));
|
||||
pos->board = malloc(sizeof (board_t));
|
||||
if (pos->board)
|
||||
pos_init(pos);
|
||||
else {
|
||||
@@ -124,5 +137,7 @@ POS *pos_create()
|
||||
pos = NULL;
|
||||
}
|
||||
}
|
||||
INIT_LIST_HEAD(&pos->w_pieces);
|
||||
INIT_LIST_HEAD(&pos->b_pieces);
|
||||
return pos;
|
||||
}
|
||||
|
Reference in New Issue
Block a user