/************************************ ChessAI.h Original Author: Eric Rollins. Copyright 1999-2005 Firepad, Inc. All rights reserved. The latest version of this file is located at http://www.whitehorsegames.com/chroma/source/ Use of this file governed by the GNU Public License Version 2, as defined here: http://www.opensource.org/licenses/gpl-license.php This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. Commercial licenses to this software, not subject to the limitations of GPL, are available from Firepad for a fee. Contact: Bill Mitchell Firepad, Inc. 3187-D Airway Avenue Costa Mesa, CA 92626 Or email "support" at "firepad dot com." Or do a whois lookup on firepad.com for the current technical contact. ***********************************/ #ifndef _CHESS_AI_H_ #define _CHESS_AI_H_ #include "Defines.h" #include "SharedAI.h" #include "ChessmateSave.h" #define CHESS_MOVE_SIZE 2 typedef struct FastBoardType { unsigned char board[kChessboardSize]; short whiteRankSum; short blackRankSum; short pawnRankSum; Boolean blackQueenCastleAllowed; Boolean blackKingCastleAllowed; Boolean whiteQueenCastleAllowed; Boolean whiteKingCastleAllowed; Boolean validRank; Boolean validPawnRank; char whiteKingLocation; char blackKingLocation; char enPassantLoc; } FastBoardType; // used to track repeated positions typedef struct ListNode { const FastBoardType *fastBoard; struct ListNode *next; PlayerColor turn; } ListNode; // malloced version of above: includes space for FastBoard typedef struct FatListNode { ListNode node; FastBoardType fb; } FatListNode; extern FatListNode *gRepeatListHead; // move[] array is filled in: move[0] is start position; // move[1] is destination int ChessAIGenerateMove(PlayerColor turn, Location move[], const GameStateType *board, UInt32 maxTimeInSeconds, Boolean *abortedDueToEvent, PieceType *promotionPieceType, FatListNode *repeatListHead, Boolean stopOnEvent); // fills in available move board: empty == invalid move, // whitepawn == valid move Boolean listValidChessMoves(PlayerColor turn, const GameStateType *currentBoard, GameStateType *availableMoveBoard, Location from); void freeRepeatList(FatListNode *repeatListHead); int lengthRepeatList(const FatListNode *repeatListHead); Boolean isEqualFastBoard(const FastBoardType *b1, const FastBoardType *b2); Boolean isThriceRepeatedBoard(FatListNode *head, GameStateType *board, PlayerColor turn); // returns new list head // automatically deletes old list nodes if repeatable == false FatListNode *addListNode(FatListNode *repeatListHead, const GameStateType *board, Boolean repeatable, PlayerColor turn); int getChessAILevel(int *nodes); // Debug routine. Boolean isKingInCheck(PlayerColor turn, const GameStateType *currentBoard); #endif