perfect: Rename KI to AI and rename muehle to mill

This commit is contained in:
Calcitem 2021-01-18 01:18:07 +08:00
parent f8287f04fd
commit 1649be403f
14 changed files with 202 additions and 202 deletions

View File

@ -1,10 +1,10 @@
#include <cstdio> #include <cstdio>
#include <iostream> #include <iostream>
#include <windows.h> #include <windows.h>
#include "muehle.h" #include "mill.h"
#include "minMaxKI.h" #include "miniMaxAI.h"
#include "randomKI.h" #include "randomAI.h"
#include "perfectKI.h" #include "perfectAI.h"
using namespace std; using namespace std;
@ -24,8 +24,8 @@ void main(void)
bool playerTwoHuman = false; bool playerTwoHuman = false;
char tmpChar[100]; char tmpChar[100];
unsigned int pushFrom, pushTo; unsigned int pushFrom, pushTo;
muehle *myGame = new muehle(); Mill *myGame = new Mill();
perfectKI *myKI = new perfectKI(databaseDirectory); perfectAI *myKI = new perfectAI(databaseDirectory);
SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS); SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS);
srand(GetTickCount()); srand(GetTickCount());

View File

@ -36,8 +36,8 @@ cyclicArray::cyclicArray(unsigned int blockSizeInBytes, unsigned int numberOfBlo
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Name: ~randomKI() // Name: ~randomAI()
// Desc: randomKI class destructor // Desc: randomAI class destructor
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
cyclicArray::~cyclicArray() cyclicArray::~cyclicArray()
{ {

View File

@ -1,18 +1,18 @@
/********************************************************************* /*********************************************************************
muehle.cpp Mill.cpp
Copyright (c) Thomas Weber. All rights reserved. Copyright (c) Thomas Weber. All rights reserved.
Copyright (C) 2021 The Sanmill developers (see AUTHORS file) Copyright (C) 2021 The Sanmill developers (see AUTHORS file)
Licensed under the MIT License. Licensed under the MIT License.
https://github.com/madweasel/madweasels-cpp https://github.com/madweasel/madweasels-cpp
\*********************************************************************/ \*********************************************************************/
#include "muehle.h" #include "mill.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Name: muehle() // Name: Mill()
// Desc: muehle class constructor // Desc: Mill class constructor
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
muehle::muehle() Mill::Mill()
{ {
srand((unsigned)time(nullptr)); srand((unsigned)time(nullptr));
@ -27,19 +27,19 @@ muehle::muehle()
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Name: ~muehle() // Name: ~Mill()
// Desc: muehle class destructor // Desc: Mill class destructor
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
muehle::~muehle() Mill::~Mill()
{ {
deleteArrays(); deleteArrays();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Name: deleteArrays() // Name: deleteArrays()
// Desc: Deletes all arrays the muehle class has created. // Desc: Deletes all arrays the Mill class has created.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void muehle::deleteArrays() void Mill::deleteArrays()
{ {
SAFE_DELETE_ARRAY(moveLogFrom); SAFE_DELETE_ARRAY(moveLogFrom);
SAFE_DELETE_ARRAY(moveLogTo); SAFE_DELETE_ARRAY(moveLogTo);
@ -50,9 +50,9 @@ void muehle::deleteArrays()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Name: beginNewGame() // Name: beginNewGame()
// Desc: Reinitializes the muehle object. // Desc: Reinitializes the Mill object.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void muehle::beginNewGame(muehleKI *firstPlayerKI, muehleKI *secondPlayerKI, int currentPlayer) void Mill::beginNewGame(millAI *firstPlayerKI, millAI *secondPlayerKI, int currentPlayer)
{ {
// free mem // free mem
deleteArrays(); deleteArrays();
@ -85,7 +85,7 @@ void muehle::beginNewGame(muehleKI *firstPlayerKI, muehleKI *secondPlayerKI, int
// Name: startSettingPhase() // Name: startSettingPhase()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool muehle::startSettingPhase(muehleKI *firstPlayerKI, muehleKI *secondPlayerKI, int currentPlayer, bool settingPhase) bool Mill::startSettingPhase(millAI *firstPlayerKI, millAI *secondPlayerKI, int currentPlayer, bool settingPhase)
{ {
beginNewGame(firstPlayerKI, secondPlayerKI, currentPlayer); beginNewGame(firstPlayerKI, secondPlayerKI, currentPlayer);
@ -98,7 +98,7 @@ bool muehle::startSettingPhase(muehleKI *firstPlayerKI, muehleKI *secondPlayerKI
// Name: setUpCalcPossibleMoves() // Name: setUpCalcPossibleMoves()
// Desc: Calculates and set the number of possible moves for the passed player considering the game state stored in the 'field' variable. // Desc: Calculates and set the number of possible moves for the passed player considering the game state stored in the 'field' variable.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void muehle::setUpCalcPossibleMoves(playerStruct *player) void Mill::setUpCalcPossibleMoves(playerStruct *player)
{ {
// locals // locals
unsigned int i, j, k, movingDirection; unsigned int i, j, k, movingDirection;
@ -132,7 +132,7 @@ void muehle::setUpCalcPossibleMoves(playerStruct *player)
// Name: setUpSetWarningAndMill() // Name: setUpSetWarningAndMill()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void muehle::setUpSetWarningAndMill(unsigned int stone, unsigned int firstNeighbour, unsigned int secondNeighbour) void Mill::setUpSetWarningAndMill(unsigned int stone, unsigned int firstNeighbour, unsigned int secondNeighbour)
{ {
// locals // locals
int rowOwner = field.field[stone]; int rowOwner = field.field[stone];
@ -150,7 +150,7 @@ void muehle::setUpSetWarningAndMill(unsigned int stone, unsigned int firstNeighb
// Name: putStone() // Name: putStone()
// Desc: Put a stone onto the field during the setting phase. // Desc: Put a stone onto the field during the setting phase.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool muehle::putStone(unsigned int pos, int player) bool Mill::putStone(unsigned int pos, int player)
{ {
// locals // locals
unsigned int i; unsigned int i;
@ -221,7 +221,7 @@ bool muehle::putStone(unsigned int pos, int player)
// Name: settingPhaseHasFinished() // Name: settingPhaseHasFinished()
// Desc: This function has to be called when the setting phase has finished. // Desc: This function has to be called when the setting phase has finished.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool muehle::settingPhaseHasFinished() bool Mill::settingPhaseHasFinished()
{ {
// remember initialField // remember initialField
field.copyField(&initialField); field.copyField(&initialField);
@ -233,7 +233,7 @@ bool muehle::settingPhaseHasFinished()
// Name: getField() // Name: getField()
// Desc: Copy the current field state into the array 'pField'. // Desc: Copy the current field state into the array 'pField'.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool muehle::getField(int *pField) bool Mill::getField(int *pField)
{ {
unsigned int index; unsigned int index;
@ -252,7 +252,7 @@ bool muehle::getField(int *pField)
// Name: getLog() // Name: getLog()
// Desc: Copy the whole history of moves into the passed arrays, which must be of size [MAX_NUM_MOVES]. // Desc: Copy the whole history of moves into the passed arrays, which must be of size [MAX_NUM_MOVES].
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void muehle::getLog(unsigned int &numMovesDone, unsigned int *from, unsigned int *to) void Mill::getLog(unsigned int &numMovesDone, unsigned int *from, unsigned int *to)
{ {
unsigned int index; unsigned int index;
@ -268,7 +268,7 @@ void muehle::getLog(unsigned int &numMovesDone, unsigned int *from, unsigned int
// Name: setNextPlayer() // Name: setNextPlayer()
// Desc: Current player and opponent player are switched in the field struct. // Desc: Current player and opponent player are switched in the field struct.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void muehle::setNextPlayer() void Mill::setNextPlayer()
{ {
playerStruct *tmpPlayer; playerStruct *tmpPlayer;
@ -281,7 +281,7 @@ void muehle::setNextPlayer()
// Name: isCurrentPlayerHuman() // Name: isCurrentPlayerHuman()
// Desc: Returns true if the current player is not assigned to an AI. // Desc: Returns true if the current player is not assigned to an AI.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool muehle::isCurrentPlayerHuman() bool Mill::isCurrentPlayerHuman()
{ {
if (field.curPlayer->id == field.playerOne) return (playerOneKI == nullptr) ? true : false; if (field.curPlayer->id == field.playerOne) return (playerOneKI == nullptr) ? true : false;
else return (playerTwoKI == nullptr) ? true : false; else return (playerTwoKI == nullptr) ? true : false;
@ -291,7 +291,7 @@ bool muehle::isCurrentPlayerHuman()
// Name: isOpponentPlayerHuman() // Name: isOpponentPlayerHuman()
// Desc: Returns true if the opponent player is not assigned to an AI. // Desc: Returns true if the opponent player is not assigned to an AI.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool muehle::isOpponentPlayerHuman() bool Mill::isOpponentPlayerHuman()
{ {
if (field.oppPlayer->id == field.playerOne) return (playerOneKI == nullptr) ? true : false; if (field.oppPlayer->id == field.playerOne) return (playerOneKI == nullptr) ? true : false;
else return (playerTwoKI == nullptr) ? true : false; else return (playerTwoKI == nullptr) ? true : false;
@ -301,7 +301,7 @@ bool muehle::isOpponentPlayerHuman()
// Name: setKI() // Name: setKI()
// Desc: Assigns an AI to a player. // Desc: Assigns an AI to a player.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void muehle::setKI(int player, muehleKI *KI) void Mill::setKI(int player, millAI *KI)
{ {
if (player == field.playerOne) { if (player == field.playerOne) {
playerOneKI = KI; playerOneKI = KI;
@ -315,7 +315,7 @@ void muehle::setKI(int player, muehleKI *KI)
// Name: getChoiceOfSpecialKI() // Name: getChoiceOfSpecialKI()
// Desc: Returns the move the passed AI would do. // Desc: Returns the move the passed AI would do.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void muehle::getChoiceOfSpecialKI(muehleKI *KI, unsigned int *pushFrom, unsigned int *pushTo) void Mill::getChoiceOfSpecialKI(millAI *KI, unsigned int *pushFrom, unsigned int *pushTo)
{ {
fieldStruct theField; fieldStruct theField;
*pushFrom = field.size; *pushFrom = field.size;
@ -330,7 +330,7 @@ void muehle::getChoiceOfSpecialKI(muehleKI *KI, unsigned int *pushFrom, unsigned
// Name: getComputersChoice() // Name: getComputersChoice()
// Desc: Returns the move the AI of the current player would do. // Desc: Returns the move the AI of the current player would do.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void muehle::getComputersChoice(unsigned int *pushFrom, unsigned int *pushTo) void Mill::getComputersChoice(unsigned int *pushFrom, unsigned int *pushTo)
{ {
fieldStruct theField; fieldStruct theField;
*pushFrom = field.size; *pushFrom = field.size;
@ -353,7 +353,7 @@ void muehle::getComputersChoice(unsigned int *pushFrom, unsigned int *pushTo)
// Name: isNormalMovePossible() // Name: isNormalMovePossible()
// Desc: 'Normal' in this context means, by moving the stone along a connection without jumping. // Desc: 'Normal' in this context means, by moving the stone along a connection without jumping.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool muehle::isNormalMovePossible(unsigned int from, unsigned int to, playerStruct *player) bool Mill::isNormalMovePossible(unsigned int from, unsigned int to, playerStruct *player)
{ {
// locals // locals
unsigned int movingDirection, i; unsigned int movingDirection, i;
@ -386,7 +386,7 @@ bool muehle::isNormalMovePossible(unsigned int from, unsigned int to, playerStru
// Name: calcPossibleMoves() // Name: calcPossibleMoves()
// Desc: ... // Desc: ...
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void muehle::calcPossibleMoves(playerStruct *player) void Mill::calcPossibleMoves(playerStruct *player)
{ {
// locals // locals
unsigned int i, j; unsigned int i, j;
@ -419,7 +419,7 @@ void muehle::calcPossibleMoves(playerStruct *player)
// Name: setWarningAndMill() // Name: setWarningAndMill()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void muehle::setWarningAndMill(unsigned int stone, unsigned int firstNeighbour, unsigned int secondNeighbour, bool isNewStone) void Mill::setWarningAndMill(unsigned int stone, unsigned int firstNeighbour, unsigned int secondNeighbour, bool isNewStone)
{ {
// locals // locals
int rowOwner = field.field[stone]; int rowOwner = field.field[stone];
@ -443,7 +443,7 @@ void muehle::setWarningAndMill(unsigned int stone, unsigned int firstNeighbour,
// Name: updateMillsAndWarnings() // Name: updateMillsAndWarnings()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void muehle::updateMillsAndWarnings(unsigned int newStone) void Mill::updateMillsAndWarnings(unsigned int newStone)
{ {
// locals // locals
unsigned int i; unsigned int i;
@ -473,7 +473,7 @@ void muehle::updateMillsAndWarnings(unsigned int newStone)
// Name: moveStone() // Name: moveStone()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool muehle::moveStone(unsigned int pushFrom, unsigned int pushTo) bool Mill::moveStone(unsigned int pushFrom, unsigned int pushTo)
{ {
// avoid index override // avoid index override
if (movesDone >= MAX_NUM_MOVES) if (movesDone >= MAX_NUM_MOVES)
@ -600,7 +600,7 @@ bool muehle::moveStone(unsigned int pushFrom, unsigned int pushTo)
// Name: setCurrentGameState() // Name: setCurrentGameState()
// Desc: Set an arbitrary game state as the current one. // Desc: Set an arbitrary game state as the current one.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool muehle::setCurrentGameState(fieldStruct *curState) bool Mill::setCurrentGameState(fieldStruct *curState)
{ {
curState->copyField(&field); curState->copyField(&field);
@ -618,7 +618,7 @@ bool muehle::setCurrentGameState(fieldStruct *curState)
// Name: compareWithField() // Name: compareWithField()
// Desc: Compares the current 'field' variable with the passed one. 'stoneMoveAble[]' is ignored. // Desc: Compares the current 'field' variable with the passed one. 'stoneMoveAble[]' is ignored.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool muehle::compareWithField(fieldStruct *compareField) bool Mill::compareWithField(fieldStruct *compareField)
{ {
unsigned int i, j; unsigned int i, j;
bool ret = true; bool ret = true;
@ -671,7 +671,7 @@ bool muehle::compareWithField(fieldStruct *compareField)
// Name: comparePlayers() // Name: comparePlayers()
// Desc: Compares the two passed players and returns false if they differ. // Desc: Compares the two passed players and returns false if they differ.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool muehle::comparePlayers(playerStruct *playerA, playerStruct *playerB) bool Mill::comparePlayers(playerStruct *playerA, playerStruct *playerB)
{ {
// unsigned int i; // unsigned int i;
bool ret = true; bool ret = true;
@ -703,7 +703,7 @@ bool muehle::comparePlayers(playerStruct *playerA, playerStruct *playerB)
// Desc: Calls the printField() function of the current field. // Desc: Calls the printField() function of the current field.
// Prints the current game state on the screen. // Prints the current game state on the screen.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void muehle::printField() void Mill::printField()
{ {
field.printField(); field.printField();
} }
@ -712,7 +712,7 @@ void muehle::printField()
// Name: undoLastMove() // Name: undoLastMove()
// Desc: Sets the initial field as the current one and apply all (minus one) moves from the move history. // Desc: Sets the initial field as the current one and apply all (minus one) moves from the move history.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void muehle::undoLastMove(void) void Mill::undoLastMove(void)
{ {
// locals // locals
unsigned int *moveLogFrom_bak = new unsigned int[movesDone]; unsigned int *moveLogFrom_bak = new unsigned int[movesDone];
@ -749,7 +749,7 @@ void muehle::undoLastMove(void)
// Name: calcNumberOfRestingStones() // Name: calcNumberOfRestingStones()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void muehle::calcNumberOfRestingStones(int &numWhiteStonesResting, int &numBlackStonesResting) void Mill::calcNumberOfRestingStones(int &numWhiteStonesResting, int &numBlackStonesResting)
{ {
if (getCurrentPlayer() == fieldStruct::playerTwo) { if (getCurrentPlayer() == fieldStruct::playerTwo) {
numWhiteStonesResting = fieldStruct::numStonesPerPlayer - field.curPlayer->numStonesMissing - field.curPlayer->numStones; numWhiteStonesResting = fieldStruct::numStonesPerPlayer - field.curPlayer->numStonesMissing - field.curPlayer->numStones;

View File

@ -1,5 +1,5 @@
/*********************************************************************\ /*********************************************************************\
muehle.h Mill.h
Copyright (c) Thomas Weber. All rights reserved. Copyright (c) Thomas Weber. All rights reserved.
Copyright (C) 2021 The Sanmill developers (see AUTHORS file) Copyright (C) 2021 The Sanmill developers (see AUTHORS file)
Licensed under the MIT License. Licensed under the MIT License.
@ -14,7 +14,7 @@
#include <cstdio> #include <cstdio>
#include <time.h> #include <time.h>
#include <stdlib.h> #include <stdlib.h>
#include "muehleKI.h" #include "millAI.h"
using namespace std; using namespace std;
@ -27,13 +27,13 @@ using namespace std;
/*** Klassen *********************************************************/ /*** Klassen *********************************************************/
class muehle class Mill
{ {
private: private:
// Variables // Variables
unsigned int *moveLogFrom, *moveLogTo, movesDone; // array containing the history of moves done unsigned int *moveLogFrom, *moveLogTo, movesDone; // array containing the history of moves done
muehleKI *playerOneKI; // class-pointer to the AI of player one millAI *playerOneKI; // class-pointer to the AI of player one
muehleKI *playerTwoKI; // class-pointer to the AI of player two millAI *playerTwoKI; // class-pointer to the AI of player two
fieldStruct field; // current field fieldStruct field; // current field
fieldStruct initialField; // undo of the last move is done by setting the initial field und performing all moves saved in history fieldStruct initialField; // undo of the last move is done by setting the initial field und performing all moves saved in history
int winner; // playerId of the player who has won the game. zero if game is still running. int winner; // playerId of the player who has won the game. zero if game is still running.
@ -49,23 +49,23 @@ private:
public: public:
// Constructor / destructor // Constructor / destructor
muehle(); Mill();
~muehle(); ~Mill();
// Functions // Functions
void undoLastMove(); void undoLastMove();
void beginNewGame(muehleKI *firstPlayerKI, muehleKI *secondPlayerKI, int currentPlayer); void beginNewGame(millAI *firstPlayerKI, millAI *secondPlayerKI, int currentPlayer);
void setKI(int player, muehleKI *KI); void setKI(int player, millAI *KI);
bool moveStone(unsigned int pushFrom, unsigned int pushTo); bool moveStone(unsigned int pushFrom, unsigned int pushTo);
void getComputersChoice(unsigned int *pushFrom, unsigned int *pushTo); void getComputersChoice(unsigned int *pushFrom, unsigned int *pushTo);
bool setCurrentGameState(fieldStruct *curState); bool setCurrentGameState(fieldStruct *curState);
bool compareWithField(fieldStruct *compareField); bool compareWithField(fieldStruct *compareField);
bool comparePlayers(playerStruct *playerA, playerStruct *playerB); bool comparePlayers(playerStruct *playerA, playerStruct *playerB);
void printField(); void printField();
bool startSettingPhase(muehleKI *firstPlayerKI, muehleKI *secondPlayerKI, int currentPlayer, bool settingPhase); bool startSettingPhase(millAI *firstPlayerKI, millAI *secondPlayerKI, int currentPlayer, bool settingPhase);
bool putStone(unsigned int pos, int player); bool putStone(unsigned int pos, int player);
bool settingPhaseHasFinished(); bool settingPhaseHasFinished();
void getChoiceOfSpecialKI(muehleKI *KI, unsigned int *pushFrom, unsigned int *pushTo); void getChoiceOfSpecialKI(millAI *KI, unsigned int *pushFrom, unsigned int *pushTo);
void setUpCalcPossibleMoves(playerStruct *player); void setUpCalcPossibleMoves(playerStruct *player);
void setUpSetWarningAndMill(unsigned int stone, unsigned int firstNeighbour, unsigned int secondNeighbour); void setUpSetWarningAndMill(unsigned int stone, unsigned int firstNeighbour, unsigned int secondNeighbour);
void calcNumberOfRestingStones(int &numWhiteStonesResting, int &numBlackStonesResting); void calcNumberOfRestingStones(int &numWhiteStonesResting, int &numBlackStonesResting);

View File

@ -1,12 +1,12 @@
/********************************************************************* /*********************************************************************
muehleKI.cpp millAI.cpp
Copyright (c) Thomas Weber. All rights reserved. Copyright (c) Thomas Weber. All rights reserved.
Copyright (C) 2021 The Sanmill developers (see AUTHORS file) Copyright (C) 2021 The Sanmill developers (see AUTHORS file)
Licensed under the MIT License. Licensed under the MIT License.
https://github.com/madweasel/madweasels-cpp https://github.com/madweasel/madweasels-cpp
\*********************************************************************/ \*********************************************************************/
#include "muehleKI.h" #include "millAI.h"
using namespace std; using namespace std;

View File

@ -1,5 +1,5 @@
/*********************************************************************\ /*********************************************************************\
muehleKI.h millAI.h
Copyright (c) Thomas Weber. All rights reserved. Copyright (c) Thomas Weber. All rights reserved.
Copyright (C) 2021 The Sanmill developers (see AUTHORS file) Copyright (C) 2021 The Sanmill developers (see AUTHORS file)
Licensed under the MIT License. Licensed under the MIT License.
@ -77,18 +77,18 @@ private:
void setNeighbour(unsigned int index, unsigned int firstNeighbour0, unsigned int secondNeighbour0, unsigned int firstNeighbour1, unsigned int secondNeighbour1); void setNeighbour(unsigned int index, unsigned int firstNeighbour0, unsigned int secondNeighbour0, unsigned int firstNeighbour1, unsigned int secondNeighbour1);
}; };
class muehleKI abstract class millAI abstract
{ {
protected: protected:
fieldStruct dummyField; fieldStruct dummyField;
public: public:
// Constructor / destructor // Constructor / destructor
muehleKI() millAI()
{ {
dummyField.createField(); dummyField.createField();
}; };
~muehleKI() ~millAI()
{ {
dummyField.deleteField(); dummyField.deleteField();
}; };

View File

@ -1,27 +1,27 @@
/********************************************************************* /*********************************************************************
minMaxKI.cpp miniMaxAI.cpp
Copyright (c) Thomas Weber. All rights reserved. Copyright (c) Thomas Weber. All rights reserved.
Copyright (C) 2021 The Sanmill developers (see AUTHORS file) Copyright (C) 2021 The Sanmill developers (see AUTHORS file)
Licensed under the MIT License. Licensed under the MIT License.
https://github.com/madweasel/madweasels-cpp https://github.com/madweasel/madweasels-cpp
\*********************************************************************/ \*********************************************************************/
#include "minMaxKI.h" #include "miniMaxAI.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Name: minMaxKI() // Name: miniMaxAI()
// Desc: minMaxKI class constructor // Desc: miniMaxAI class constructor
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
minMaxKI::minMaxKI() miniMaxAI::miniMaxAI()
{ {
depthOfFullTree = 0; depthOfFullTree = 0;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Name: ~minMaxKI() // Name: ~miniMaxAI()
// Desc: minMaxKI class destructor // Desc: miniMaxAI class destructor
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
minMaxKI::~minMaxKI() miniMaxAI::~miniMaxAI()
{ {
} }
@ -29,7 +29,7 @@ minMaxKI::~minMaxKI()
// Name: play() // Name: play()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void minMaxKI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int *pushTo) void miniMaxAI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int *pushTo)
{ {
// globals // globals
field = theField; field = theField;
@ -49,7 +49,7 @@ void minMaxKI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int
} }
// Inform user about progress // Inform user about progress
cout << "minMaxKI is thinking with a depth of " << searchDepth << " steps!\n\n\n"; cout << "miniMaxAI is thinking with a depth of " << searchDepth << " steps!\n\n\n";
// reserve memory // reserve memory
possibilities = new possibilityStruct[searchDepth + 1]; possibilities = new possibilityStruct[searchDepth + 1];
@ -82,7 +82,7 @@ void minMaxKI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int
// Name: setSearchDepth() // Name: setSearchDepth()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void minMaxKI::setSearchDepth(unsigned int depth) void miniMaxAI::setSearchDepth(unsigned int depth)
{ {
depthOfFullTree = depth; depthOfFullTree = depth;
} }
@ -91,7 +91,7 @@ void minMaxKI::setSearchDepth(unsigned int depth)
// Name: prepareBestChoiceCalculation() // Name: prepareBestChoiceCalculation()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void minMaxKI::prepareBestChoiceCalculation() void miniMaxAI::prepareBestChoiceCalculation()
{ {
// calculate current value // calculate current value
currentValue = 0; currentValue = 0;
@ -102,7 +102,7 @@ void minMaxKI::prepareBestChoiceCalculation()
// Name: getPossSettingPhase() // Name: getPossSettingPhase()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
unsigned int *minMaxKI::getPossSettingPhase(unsigned int *numPossibilities, void **pPossibilities) unsigned int *miniMaxAI::getPossSettingPhase(unsigned int *numPossibilities, void **pPossibilities)
{ {
// locals // locals
unsigned int i; unsigned int i;
@ -129,7 +129,7 @@ unsigned int *minMaxKI::getPossSettingPhase(unsigned int *numPossibilities, void
// Name: getPossNormalMove() // Name: getPossNormalMove()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
unsigned int *minMaxKI::getPossNormalMove(unsigned int *numPossibilities, void **pPossibilities) unsigned int *miniMaxAI::getPossNormalMove(unsigned int *numPossibilities, void **pPossibilities)
{ {
// locals // locals
unsigned int from, to, dir; unsigned int from, to, dir;
@ -186,7 +186,7 @@ unsigned int *minMaxKI::getPossNormalMove(unsigned int *numPossibilities, void *
// Name: getPossStoneRemove() // Name: getPossStoneRemove()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
unsigned int *minMaxKI::getPossStoneRemove(unsigned int *numPossibilities, void **pPossibilities) unsigned int *miniMaxAI::getPossStoneRemove(unsigned int *numPossibilities, void **pPossibilities)
{ {
// locals // locals
unsigned int i; unsigned int i;
@ -213,7 +213,7 @@ unsigned int *minMaxKI::getPossStoneRemove(unsigned int *numPossibilities, void
// Name: getPossibilities() // Name: getPossibilities()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
unsigned int *minMaxKI::getPossibilities(unsigned int threadNo, unsigned int *numPossibilities, bool *opponentsMove, void **pPossibilities) unsigned int *miniMaxAI::getPossibilities(unsigned int threadNo, unsigned int *numPossibilities, bool *opponentsMove, void **pPossibilities)
{ {
// set opponentsMove // set opponentsMove
*opponentsMove = (field->curPlayer->id == ownId) ? false : true; *opponentsMove = (field->curPlayer->id == ownId) ? false : true;
@ -234,7 +234,7 @@ unsigned int *minMaxKI::getPossibilities(unsigned int threadNo, unsigned int *nu
// Name: getValueOfSituation() // Name: getValueOfSituation()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void minMaxKI::getValueOfSituation(unsigned int threadNo, float &floatValue, twoBit &shortValue) void miniMaxAI::getValueOfSituation(unsigned int threadNo, float &floatValue, twoBit &shortValue)
{ {
floatValue = currentValue; floatValue = currentValue;
shortValue = 0; shortValue = 0;
@ -244,7 +244,7 @@ void minMaxKI::getValueOfSituation(unsigned int threadNo, float &floatValue, two
// Name: deletePossibilities() // Name: deletePossibilities()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void minMaxKI::deletePossibilities(unsigned int threadNo, void *pPossibilities) void miniMaxAI::deletePossibilities(unsigned int threadNo, void *pPossibilities)
{ {
} }
@ -252,7 +252,7 @@ void minMaxKI::deletePossibilities(unsigned int threadNo, void *pPossibilities)
// Name: undo() // Name: undo()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void minMaxKI::undo(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void *pBackup, void *pPossibilities) void miniMaxAI::undo(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void *pBackup, void *pPossibilities)
{ {
// locals // locals
backupStruct *oldState = (backupStruct *)pBackup; backupStruct *oldState = (backupStruct *)pBackup;
@ -287,7 +287,7 @@ void minMaxKI::undo(unsigned int threadNo, unsigned int idPossibility, bool oppo
// Name: setWarning() // Name: setWarning()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
inline void minMaxKI::setWarning(unsigned int stoneOne, unsigned int stoneTwo, unsigned int stoneThree) inline void miniMaxAI::setWarning(unsigned int stoneOne, unsigned int stoneTwo, unsigned int stoneThree)
{ {
// if all 3 fields are occupied by current player than he closed a mill // if all 3 fields are occupied by current player than he closed a mill
if (field->field[stoneOne] == field->curPlayer->id && field->field[stoneTwo] == field->curPlayer->id && field->field[stoneThree] == field->curPlayer->id) { if (field->field[stoneOne] == field->curPlayer->id && field->field[stoneTwo] == field->curPlayer->id && field->field[stoneThree] == field->curPlayer->id) {
@ -349,7 +349,7 @@ inline void minMaxKI::setWarning(unsigned int stoneOne, unsigned int stoneTwo, u
// Name: updateWarning() // Name: updateWarning()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
inline void minMaxKI::updateWarning(unsigned int firstStone, unsigned int secondStone) inline void miniMaxAI::updateWarning(unsigned int firstStone, unsigned int secondStone)
{ {
// set warnings // set warnings
if (firstStone < field->size) setWarning(firstStone, field->neighbour[firstStone][0][0], field->neighbour[firstStone][0][1]); if (firstStone < field->size) setWarning(firstStone, field->neighbour[firstStone][0][0], field->neighbour[firstStone][0][1]);
@ -371,7 +371,7 @@ inline void minMaxKI::updateWarning(unsigned int firstStone, unsigned int second
// Name: updatePossibleMoves() // Name: updatePossibleMoves()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
inline void minMaxKI::updatePossibleMoves(unsigned int stone, playerStruct *stoneOwner, bool stoneRemoved, unsigned int ignoreStone) inline void miniMaxAI::updatePossibleMoves(unsigned int stone, playerStruct *stoneOwner, bool stoneRemoved, unsigned int ignoreStone)
{ {
// locals // locals
unsigned int neighbor, direction; unsigned int neighbor, direction;
@ -416,7 +416,7 @@ inline void minMaxKI::updatePossibleMoves(unsigned int stone, playerStruct *ston
// Name: setStone() // Name: setStone()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
inline void minMaxKI::setStone(unsigned int to, backupStruct *backup) inline void miniMaxAI::setStone(unsigned int to, backupStruct *backup)
{ {
// backup // backup
backup->from = field->size; backup->from = field->size;
@ -443,7 +443,7 @@ inline void minMaxKI::setStone(unsigned int to, backupStruct *backup)
// Name: normalMove() // Name: normalMove()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
inline void minMaxKI::normalMove(unsigned int from, unsigned int to, backupStruct *backup) inline void miniMaxAI::normalMove(unsigned int from, unsigned int to, backupStruct *backup)
{ {
// backup // backup
backup->from = from; backup->from = from;
@ -467,7 +467,7 @@ inline void minMaxKI::normalMove(unsigned int from, unsigned int to, backupStruc
// Name: removeStone() // Name: removeStone()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
inline void minMaxKI::removeStone(unsigned int from, backupStruct *backup) inline void miniMaxAI::removeStone(unsigned int from, backupStruct *backup)
{ {
// backup // backup
backup->from = from; backup->from = from;
@ -495,7 +495,7 @@ inline void minMaxKI::removeStone(unsigned int from, backupStruct *backup)
// Name: move() // Name: move()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void minMaxKI::move(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void **pBackup, void *pPossibilities) void miniMaxAI::move(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void **pBackup, void *pPossibilities)
{ {
// locals // locals
backupStruct *oldState = &oldStates[curSearchDepth]; backupStruct *oldState = &oldStates[curSearchDepth];
@ -558,7 +558,7 @@ void minMaxKI::move(unsigned int threadNo, unsigned int idPossibility, bool oppo
// Name: printMoveInformation() // Name: printMoveInformation()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void minMaxKI::printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities) void miniMaxAI::printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities)
{ {
// locals // locals
possibilityStruct *tmpPossibility = (possibilityStruct *)pPossibilities; possibilityStruct *tmpPossibility = (possibilityStruct *)pPossibilities;

View File

@ -1,5 +1,5 @@
/*********************************************************************\ /*********************************************************************\
minMaxKI.h miniMaxAI.h
Copyright (c) Thomas Weber. All rights reserved. Copyright (c) Thomas Weber. All rights reserved.
Copyright (C) 2021 The Sanmill developers (see AUTHORS file) Copyright (C) 2021 The Sanmill developers (see AUTHORS file)
Licensed under the MIT License. Licensed under the MIT License.
@ -12,7 +12,7 @@
#include <iostream> #include <iostream>
#include <cstdio> #include <cstdio>
#include <math.h> #include <math.h>
#include "muehleKI.h" #include "millAI.h"
#include "miniMax.h" #include "miniMax.h"
//using namespace std; //using namespace std;
@ -21,7 +21,7 @@
#define VALUE_GAME_WON 1000.0f #define VALUE_GAME_WON 1000.0f
/*** Klassen *********************************************************/ /*** Klassen *********************************************************/
class minMaxKI : public muehleKI, miniMax class miniMaxAI : public millAI, miniMax
{ {
protected: protected:
@ -139,8 +139,8 @@ protected:
public: public:
// Constructor / destructor // Constructor / destructor
minMaxKI(); miniMaxAI();
~minMaxKI(); ~miniMaxAI();
// Functions // Functions
void play(fieldStruct *theField, unsigned int *pushFrom, unsigned int *pushTo); void play(fieldStruct *theField, unsigned int *pushFrom, unsigned int *pushTo);

View File

@ -149,11 +149,11 @@
<ClInclude Include="miniMax.h" /> <ClInclude Include="miniMax.h" />
<ClInclude Include="miniMaxWin.h" /> <ClInclude Include="miniMaxWin.h" />
<ClInclude Include="miniMax_retroAnalysis.h" /> <ClInclude Include="miniMax_retroAnalysis.h" />
<ClInclude Include="minMaxKI.h" /> <ClInclude Include="miniMaxAI.h" />
<ClInclude Include="muehle.h" /> <ClInclude Include="mill.h" />
<ClInclude Include="muehleKI.h" /> <ClInclude Include="millAI.h" />
<ClInclude Include="perfectKI.h" /> <ClInclude Include="perfectAI.h" />
<ClInclude Include="randomKI.h" /> <ClInclude Include="randomAI.h" />
<ClInclude Include="strLib.h" /> <ClInclude Include="strLib.h" />
<ClInclude Include="threadManager.h" /> <ClInclude Include="threadManager.h" />
</ItemGroup> </ItemGroup>
@ -168,10 +168,10 @@
<ClCompile Include="miniMax_statistics.cpp" /> <ClCompile Include="miniMax_statistics.cpp" />
<ClCompile Include="miniMax_test.cpp" /> <ClCompile Include="miniMax_test.cpp" />
<ClCompile Include="minMaxKI.cpp" /> <ClCompile Include="minMaxKI.cpp" />
<ClCompile Include="muehle.cpp" /> <ClCompile Include="mill.cpp" />
<ClCompile Include="muehleKI.cpp" /> <ClCompile Include="millAI.cpp" />
<ClCompile Include="perfectKI.cpp" /> <ClCompile Include="perfectAI.cpp" />
<ClCompile Include="randomKI.cpp" /> <ClCompile Include="randomAI.cpp" />
<ClCompile Include="strLib.cpp" /> <ClCompile Include="strLib.cpp" />
<ClCompile Include="threadManager.cpp" /> <ClCompile Include="threadManager.cpp" />
</ItemGroup> </ItemGroup>

View File

@ -21,21 +21,6 @@
<ClInclude Include="cyclicArray.h"> <ClInclude Include="cyclicArray.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="minMaxKI.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="muehle.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="muehleKI.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="perfectKI.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="randomKI.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="strLib.h"> <ClInclude Include="strLib.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -51,6 +36,21 @@
<ClInclude Include="miniMaxWin.h"> <ClInclude Include="miniMaxWin.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="perfectAI.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="millAI.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="mill.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="miniMaxAI.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="randomAI.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="bufferedFile.cpp"> <ClCompile Include="bufferedFile.cpp">
@ -65,18 +65,6 @@
<ClCompile Include="minMaxKI.cpp"> <ClCompile Include="minMaxKI.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="muehle.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="muehleKI.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="perfectKI.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="randomKI.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="strLib.cpp"> <ClCompile Include="strLib.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -101,5 +89,17 @@
<ClCompile Include="miniMax_test.cpp"> <ClCompile Include="miniMax_test.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="perfectAI.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="mill.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="millAI.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="randomAI.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -6,7 +6,7 @@
https://github.com/madweasel/madweasels-cpp https://github.com/madweasel/madweasels-cpp
\*********************************************************************/ \*********************************************************************/
#include "perfectKI.h" #include "perfectAI.h"
unsigned int soTableTurnLeft[] = { unsigned int soTableTurnLeft[] = {
2, 14, 23, 2, 14, 23,
@ -186,7 +186,7 @@ unsigned int fieldPosIsOfGroup[] = { GROUP_C, GROUP_D,
// Name: perfectKI() // Name: perfectKI()
// Desc: perfectKI class constructor // Desc: perfectKI class constructor
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
perfectKI::perfectKI(const char *directory) perfectAI::perfectAI(const char *directory)
{ {
// loacls // loacls
unsigned int i, a, b, c, totalNumStones; unsigned int i, a, b, c, totalNumStones;
@ -629,7 +629,7 @@ perfectKI::perfectKI(const char *directory)
// Name: ~perfectKI() // Name: ~perfectKI()
// Desc: perfectKI class destructor // Desc: perfectKI class destructor
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
perfectKI::~perfectKI() perfectAI::~perfectAI()
{ {
// locals // locals
unsigned int curThread; unsigned int curThread;
@ -648,7 +648,7 @@ perfectKI::~perfectKI()
// Name: play() // Name: play()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int *pushTo) void perfectAI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int *pushTo)
{ {
// ... trick 17 // ... trick 17
theField->copyField(&dummyField); theField->copyField(&dummyField);
@ -703,7 +703,7 @@ void perfectKI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int
// Name: prepareDatabaseCalculation() // Name: prepareDatabaseCalculation()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::prepareDatabaseCalculation() void perfectAI::prepareDatabaseCalculation()
{ {
// only prepare layers? // only prepare layers?
unsigned int curThread; unsigned int curThread;
@ -723,7 +723,7 @@ void perfectKI::prepareDatabaseCalculation()
// Name: wrapUpDatabaseCalculation() // Name: wrapUpDatabaseCalculation()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::wrapUpDatabaseCalculation(bool calculationAborted) void perfectAI::wrapUpDatabaseCalculation(bool calculationAborted)
{ {
// locals // locals
unsigned int curThread; unsigned int curThread;
@ -740,7 +740,7 @@ void perfectKI::wrapUpDatabaseCalculation(bool calculationAborted)
// Name: testLayers() // Name: testLayers()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool perfectKI::testLayers(unsigned int startTestFromLayer, unsigned int endTestAtLayer) bool perfectAI::testLayers(unsigned int startTestFromLayer, unsigned int endTestAtLayer)
{ {
// locals // locals
unsigned int curLayer; unsigned int curLayer;
@ -762,7 +762,7 @@ bool perfectKI::testLayers(unsigned int startTestFromLayer, unsigned int endTest
// Name: setDatabasePath() // Name: setDatabasePath()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool perfectKI::setDatabasePath(const char *directory) bool perfectAI::setDatabasePath(const char *directory)
{ {
if (directory == nullptr) { if (directory == nullptr) {
return false; return false;
@ -777,7 +777,7 @@ bool perfectKI::setDatabasePath(const char *directory)
// Name: prepareBestChoiceCalculation() // Name: prepareBestChoiceCalculation()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::prepareBestChoiceCalculation() void perfectAI::prepareBestChoiceCalculation()
{ {
for (unsigned int curThread = 0; curThread < getNumThreads(); curThread++) { for (unsigned int curThread = 0; curThread < getNumThreads(); curThread++) {
threadVars[curThread].floatValue = 0.0f; threadVars[curThread].floatValue = 0.0f;
@ -791,7 +791,7 @@ void perfectKI::prepareBestChoiceCalculation()
// Name: threadVarsStruct() // Name: threadVarsStruct()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
perfectKI::threadVarsStruct::threadVarsStruct() perfectAI::threadVarsStruct::threadVarsStruct()
{ {
field = nullptr; field = nullptr;
floatValue = 0; floatValue = 0;
@ -811,7 +811,7 @@ perfectKI::threadVarsStruct::threadVarsStruct()
// Name: getPossSettingPhase() // Name: getPossSettingPhase()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
unsigned int *perfectKI::threadVarsStruct::getPossSettingPhase(unsigned int *numPossibilities, void **pPossibilities) unsigned int *perfectAI::threadVarsStruct::getPossSettingPhase(unsigned int *numPossibilities, void **pPossibilities)
{ {
// locals // locals
unsigned int i; unsigned int i;
@ -858,7 +858,7 @@ unsigned int *perfectKI::threadVarsStruct::getPossSettingPhase(unsigned int *num
// Name: getPossNormalMove() // Name: getPossNormalMove()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
unsigned int *perfectKI::threadVarsStruct::getPossNormalMove(unsigned int *numPossibilities, void **pPossibilities) unsigned int *perfectAI::threadVarsStruct::getPossNormalMove(unsigned int *numPossibilities, void **pPossibilities)
{ {
// locals // locals
unsigned int from, to, dir; unsigned int from, to, dir;
@ -917,7 +917,7 @@ unsigned int *perfectKI::threadVarsStruct::getPossNormalMove(unsigned int *numPo
// Name: getPossStoneRemove() // Name: getPossStoneRemove()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
unsigned int *perfectKI::threadVarsStruct::getPossStoneRemove(unsigned int *numPossibilities, void **pPossibilities) unsigned int *perfectAI::threadVarsStruct::getPossStoneRemove(unsigned int *numPossibilities, void **pPossibilities)
{ {
// locals // locals
unsigned int i; unsigned int i;
@ -944,7 +944,7 @@ unsigned int *perfectKI::threadVarsStruct::getPossStoneRemove(unsigned int *numP
// Name: getPossibilities() // Name: getPossibilities()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
unsigned int *perfectKI::getPossibilities(unsigned int threadNo, unsigned int *numPossibilities, bool *opponentsMove, void **pPossibilities) unsigned int *perfectAI::getPossibilities(unsigned int threadNo, unsigned int *numPossibilities, bool *opponentsMove, void **pPossibilities)
{ {
// locals // locals
bool aStoneCanBeRemovedFromCurPlayer = 0; bool aStoneCanBeRemovedFromCurPlayer = 0;
@ -981,7 +981,7 @@ unsigned int *perfectKI::getPossibilities(unsigned int threadNo, unsigned int *n
// Name: getValueOfSituation() // Name: getValueOfSituation()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::getValueOfSituation(unsigned int threadNo, float &floatValue, twoBit &shortValue) void perfectAI::getValueOfSituation(unsigned int threadNo, float &floatValue, twoBit &shortValue)
{ {
threadVarsStruct *tv = &threadVars[threadNo]; threadVarsStruct *tv = &threadVars[threadNo];
floatValue = tv->floatValue; floatValue = tv->floatValue;
@ -992,7 +992,7 @@ void perfectKI::getValueOfSituation(unsigned int threadNo, float &floatValue, tw
// Name: deletePossibilities() // Name: deletePossibilities()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::deletePossibilities(unsigned int threadNo, void *pPossibilities) void perfectAI::deletePossibilities(unsigned int threadNo, void *pPossibilities)
{ {
} }
@ -1000,7 +1000,7 @@ void perfectKI::deletePossibilities(unsigned int threadNo, void *pPossibilities)
// Name: undo() // Name: undo()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::undo(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void *pBackup, void *pPossibilities) void perfectAI::undo(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void *pBackup, void *pPossibilities)
{ {
// locals // locals
threadVarsStruct *tv = &threadVars[threadNo]; threadVarsStruct *tv = &threadVars[threadNo];
@ -1036,7 +1036,7 @@ void perfectKI::undo(unsigned int threadNo, unsigned int idPossibility, bool opp
// Name: setWarning() // Name: setWarning()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
inline void perfectKI::threadVarsStruct::setWarning(unsigned int stoneOne, unsigned int stoneTwo, unsigned int stoneThree) inline void perfectAI::threadVarsStruct::setWarning(unsigned int stoneOne, unsigned int stoneTwo, unsigned int stoneThree)
{ {
// if all 3 fields are occupied by current player than he closed a mill // if all 3 fields are occupied by current player than he closed a mill
if (field->field[stoneOne] == field->curPlayer->id && field->field[stoneTwo] == field->curPlayer->id && field->field[stoneThree] == field->curPlayer->id) { if (field->field[stoneOne] == field->curPlayer->id && field->field[stoneTwo] == field->curPlayer->id && field->field[stoneThree] == field->curPlayer->id) {
@ -1058,7 +1058,7 @@ inline void perfectKI::threadVarsStruct::setWarning(unsigned int stoneOne, unsig
// Name: updateWarning() // Name: updateWarning()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
inline void perfectKI::threadVarsStruct::updateWarning(unsigned int firstStone, unsigned int secondStone) inline void perfectAI::threadVarsStruct::updateWarning(unsigned int firstStone, unsigned int secondStone)
{ {
// set warnings // set warnings
if (firstStone < field->size) this->setWarning(firstStone, field->neighbour[firstStone][0][0], field->neighbour[firstStone][0][1]); if (firstStone < field->size) this->setWarning(firstStone, field->neighbour[firstStone][0][0], field->neighbour[firstStone][0][1]);
@ -1080,7 +1080,7 @@ inline void perfectKI::threadVarsStruct::updateWarning(unsigned int firstStone,
// Name: updatePossibleMoves() // Name: updatePossibleMoves()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
inline void perfectKI::threadVarsStruct::updatePossibleMoves(unsigned int stone, playerStruct *stoneOwner, bool stoneRemoved, unsigned int ignoreStone) inline void perfectAI::threadVarsStruct::updatePossibleMoves(unsigned int stone, playerStruct *stoneOwner, bool stoneRemoved, unsigned int ignoreStone)
{ {
// locals // locals
unsigned int neighbor, direction; unsigned int neighbor, direction;
@ -1125,7 +1125,7 @@ inline void perfectKI::threadVarsStruct::updatePossibleMoves(unsigned int stone,
// Name: setStone() // Name: setStone()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
inline void perfectKI::threadVarsStruct::setStone(unsigned int to, backupStruct *backup) inline void perfectAI::threadVarsStruct::setStone(unsigned int to, backupStruct *backup)
{ {
// backup // backup
backup->from = field->size; backup->from = field->size;
@ -1152,7 +1152,7 @@ inline void perfectKI::threadVarsStruct::setStone(unsigned int to, backupStruct
// Name: normalMove() // Name: normalMove()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
inline void perfectKI::threadVarsStruct::normalMove(unsigned int from, unsigned int to, backupStruct *backup) inline void perfectAI::threadVarsStruct::normalMove(unsigned int from, unsigned int to, backupStruct *backup)
{ {
// backup // backup
backup->from = from; backup->from = from;
@ -1176,7 +1176,7 @@ inline void perfectKI::threadVarsStruct::normalMove(unsigned int from, unsigned
// Name: removeStone() // Name: removeStone()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
inline void perfectKI::threadVarsStruct::removeStone(unsigned int from, backupStruct *backup) inline void perfectAI::threadVarsStruct::removeStone(unsigned int from, backupStruct *backup)
{ {
// backup // backup
backup->from = from; backup->from = from;
@ -1204,7 +1204,7 @@ inline void perfectKI::threadVarsStruct::removeStone(unsigned int from, backupSt
// Name: move() // Name: move()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::move(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void **pBackup, void *pPossibilities) void perfectAI::move(unsigned int threadNo, unsigned int idPossibility, bool opponentsMove, void **pBackup, void *pPossibilities)
{ {
// locals // locals
threadVarsStruct *tv = &threadVars[threadNo]; threadVarsStruct *tv = &threadVars[threadNo];
@ -1274,7 +1274,7 @@ void perfectKI::move(unsigned int threadNo, unsigned int idPossibility, bool opp
// Name: storeValueOfMove() // Name: storeValueOfMove()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::storeValueOfMove(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities, unsigned char value, unsigned int *freqValuesSubMoves, plyInfoVarType plyInfo) void perfectAI::storeValueOfMove(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities, unsigned char value, unsigned int *freqValuesSubMoves, plyInfoVarType plyInfo)
{ {
// locals // locals
threadVarsStruct *tv = &threadVars[threadNo]; threadVarsStruct *tv = &threadVars[threadNo];
@ -1297,7 +1297,7 @@ void perfectKI::storeValueOfMove(unsigned int threadNo, unsigned int idPossibili
// Name: getValueOfMoves() // Name: getValueOfMoves()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::getValueOfMoves(unsigned char *moveValue, unsigned int *freqValuesSubMoves, plyInfoVarType *plyInfo, unsigned int *moveQuality, unsigned char &knotValue, plyInfoVarType &bestAmountOfPlies) void perfectAI::getValueOfMoves(unsigned char *moveValue, unsigned int *freqValuesSubMoves, plyInfoVarType *plyInfo, unsigned int *moveQuality, unsigned char &knotValue, plyInfoVarType &bestAmountOfPlies)
{ {
// locals // locals
unsigned int moveQualities[fieldStruct::size * fieldStruct::size]; // 0 is bad, 1 is good unsigned int moveQualities[fieldStruct::size * fieldStruct::size]; // 0 is bad, 1 is good
@ -1384,7 +1384,7 @@ void perfectKI::getValueOfMoves(unsigned char *moveValue, unsigned int *freqValu
// Name: printMoveInformation() // Name: printMoveInformation()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities) void perfectAI::printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities)
{ {
// locals // locals
threadVarsStruct *tv = &threadVars[threadNo]; threadVarsStruct *tv = &threadVars[threadNo];
@ -1400,7 +1400,7 @@ void perfectKI::printMoveInformation(unsigned int threadNo, unsigned int idPossi
// Name: getNumberOfLayers() // Name: getNumberOfLayers()
// Desc: called one time // Desc: called one time
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
unsigned int perfectKI::getNumberOfLayers() unsigned int perfectAI::getNumberOfLayers()
{ {
return NUM_LAYERS; return NUM_LAYERS;
} }
@ -1409,7 +1409,7 @@ unsigned int perfectKI::getNumberOfLayers()
// Name: shallRetroAnalysisBeUsed() // Name: shallRetroAnalysisBeUsed()
// Desc: called one time for each layer time // Desc: called one time for each layer time
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool perfectKI::shallRetroAnalysisBeUsed(unsigned int layerNum) bool perfectAI::shallRetroAnalysisBeUsed(unsigned int layerNum)
{ {
if (layerNum < 100) if (layerNum < 100)
return true; return true;
@ -1421,7 +1421,7 @@ bool perfectKI::shallRetroAnalysisBeUsed(unsigned int layerNum)
// Name: getNumberOfKnotsInLayer() // Name: getNumberOfKnotsInLayer()
// Desc: called one time // Desc: called one time
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
unsigned int perfectKI::getNumberOfKnotsInLayer(unsigned int layerNum) unsigned int perfectAI::getNumberOfKnotsInLayer(unsigned int layerNum)
{ {
// locals // locals
unsigned int numberOfKnots = layer[layerNum].subLayer[layer[layerNum].numSubLayers - 1].maxIndex + 1; unsigned int numberOfKnots = layer[layerNum].subLayer[layer[layerNum].numSubLayers - 1].maxIndex + 1;
@ -1443,7 +1443,7 @@ unsigned int perfectKI::getNumberOfKnotsInLayer(unsigned int layerNum)
// Name: nOverN() // Name: nOverN()
// Desc: called seldom // Desc: called seldom
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
long long perfectKI::mOverN_Function(unsigned int m, unsigned int n) long long perfectAI::mOverN_Function(unsigned int m, unsigned int n)
{ {
// locals // locals
long long result = 1; long long result = 1;
@ -1472,7 +1472,7 @@ long long perfectKI::mOverN_Function(unsigned int m, unsigned int n)
// Name: applySymmetrieOperationOnField() // Name: applySymmetrieOperationOnField()
// Desc: called very often // Desc: called very often
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::applySymmetrieOperationOnField(unsigned char symmetryOperationNumber, unsigned int *sourceField, unsigned int *destField) void perfectAI::applySymmetrieOperationOnField(unsigned char symmetryOperationNumber, unsigned int *sourceField, unsigned int *destField)
{ {
for (unsigned int i = 0; i < fieldStruct::size; i++) { for (unsigned int i = 0; i < fieldStruct::size; i++) {
destField[i] = sourceField[symmetryOperationTable[symmetryOperationNumber][i]]; destField[i] = sourceField[symmetryOperationTable[symmetryOperationNumber][i]];
@ -1483,7 +1483,7 @@ void perfectKI::applySymmetrieOperationOnField(unsigned char symmetryOperationNu
// Name: getLayerNumber() // Name: getLayerNumber()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
unsigned int perfectKI::getLayerNumber(unsigned int threadNo) unsigned int perfectAI::getLayerNumber(unsigned int threadNo)
{ {
threadVarsStruct *tv = &threadVars[threadNo]; threadVarsStruct *tv = &threadVars[threadNo];
unsigned int numBlackStones = tv->field->oppPlayer->numStones; unsigned int numBlackStones = tv->field->oppPlayer->numStones;
@ -1496,7 +1496,7 @@ unsigned int perfectKI::getLayerNumber(unsigned int threadNo)
// Name: getLayerAndStateNumber() // Name: getLayerAndStateNumber()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
unsigned int perfectKI::getLayerAndStateNumber(unsigned int threadNo, unsigned int &layerNum, unsigned int &stateNumber) unsigned int perfectAI::getLayerAndStateNumber(unsigned int threadNo, unsigned int &layerNum, unsigned int &stateNumber)
{ {
threadVarsStruct *tv = &threadVars[threadNo]; threadVarsStruct *tv = &threadVars[threadNo];
return tv->getLayerAndStateNumber(layerNum, stateNumber); return tv->getLayerAndStateNumber(layerNum, stateNumber);
@ -1506,7 +1506,7 @@ unsigned int perfectKI::getLayerAndStateNumber(unsigned int threadNo, unsigned i
// Name: getLayerAndStateNumber() // Name: getLayerAndStateNumber()
// Desc: Current player has white stones, the opponent the black ones. // Desc: Current player has white stones, the opponent the black ones.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
unsigned int perfectKI::threadVarsStruct::getLayerAndStateNumber(unsigned int &layerNum, unsigned int &stateNumber) unsigned int perfectAI::threadVarsStruct::getLayerAndStateNumber(unsigned int &layerNum, unsigned int &stateNumber)
{ {
// locals // locals
unsigned int myField[fieldStruct::size]; unsigned int myField[fieldStruct::size];
@ -1581,7 +1581,7 @@ unsigned int perfectKI::threadVarsStruct::getLayerAndStateNumber(unsigned int &l
// Desc: Current player has white stones, the opponent the black ones. // Desc: Current player has white stones, the opponent the black ones.
// Sets up the game situation corresponding to the passed layer number and state. // Sets up the game situation corresponding to the passed layer number and state.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool perfectKI::setSituation(unsigned int threadNo, unsigned int layerNum, unsigned int stateNumber) bool perfectAI::setSituation(unsigned int threadNo, unsigned int layerNum, unsigned int stateNumber)
{ {
// parameters ok ? // parameters ok ?
if (getNumberOfLayers() <= layerNum) return false; if (getNumberOfLayers() <= layerNum) return false;
@ -1740,7 +1740,7 @@ bool perfectKI::setSituation(unsigned int threadNo, unsigned int layerNum, unsig
// Name: calcPossibleMoves() // Name: calcPossibleMoves()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::threadVarsStruct::calcPossibleMoves(playerStruct *player) void perfectAI::threadVarsStruct::calcPossibleMoves(playerStruct *player)
{ {
// locals // locals
unsigned int i, j, k, movingDirection; unsigned int i, j, k, movingDirection;
@ -1774,7 +1774,7 @@ void perfectKI::threadVarsStruct::calcPossibleMoves(playerStruct *player)
// Name: setWarningAndMill() // Name: setWarningAndMill()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::threadVarsStruct::setWarningAndMill(unsigned int stone, unsigned int firstNeighbour, unsigned int secondNeighbour) void perfectAI::threadVarsStruct::setWarningAndMill(unsigned int stone, unsigned int firstNeighbour, unsigned int secondNeighbour)
{ {
// locals // locals
int rowOwner = field->field[stone]; int rowOwner = field->field[stone];
@ -1792,7 +1792,7 @@ void perfectKI::threadVarsStruct::setWarningAndMill(unsigned int stone, unsigned
// Name: getOutputInformation() // Name: getOutputInformation()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
string perfectKI::getOutputInformation(unsigned int layerNum) string perfectAI::getOutputInformation(unsigned int layerNum)
{ {
stringstream ss; stringstream ss;
ss << " white stones : " << layer[layerNum].numWhiteStones << " \tblack stones : " << layer[layerNum].numBlackStones; ss << " white stones : " << layer[layerNum].numWhiteStones << " \tblack stones : " << layer[layerNum].numBlackStones;
@ -1803,7 +1803,7 @@ string perfectKI::getOutputInformation(unsigned int layerNum)
// Name: printField() // Name: printField()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::printField(unsigned int threadNo, unsigned char value) void perfectAI::printField(unsigned int threadNo, unsigned char value)
{ {
threadVarsStruct *tv = &threadVars[threadNo]; threadVarsStruct *tv = &threadVars[threadNo];
char wonStr[] = "WON"; char wonStr[] = "WON";
@ -1821,7 +1821,7 @@ void perfectKI::printField(unsigned int threadNo, unsigned char value)
// Name: getField() // Name: getField()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::getField(unsigned int layerNum, unsigned int stateNumber, fieldStruct *field, bool *gameHasFinished) void perfectAI::getField(unsigned int layerNum, unsigned int stateNumber, fieldStruct *field, bool *gameHasFinished)
{ {
// set current desired state on thread zero // set current desired state on thread zero
setSituation(0, layerNum, stateNumber); setSituation(0, layerNum, stateNumber);
@ -1836,7 +1836,7 @@ void perfectKI::getField(unsigned int layerNum, unsigned int stateNumber, fieldS
// Name: getLayerAndStateNumber() // Name: getLayerAndStateNumber()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::getLayerAndStateNumber(unsigned int &layerNum, unsigned int &stateNumber/*, unsigned int& symmetryOperation*/) void perfectAI::getLayerAndStateNumber(unsigned int &layerNum, unsigned int &stateNumber/*, unsigned int& symmetryOperation*/)
{ {
/*symmetryOperation = */threadVars[0].getLayerAndStateNumber(layerNum, stateNumber); /*symmetryOperation = */threadVars[0].getLayerAndStateNumber(layerNum, stateNumber);
} }
@ -1845,7 +1845,7 @@ void perfectKI::getLayerAndStateNumber(unsigned int &layerNum, unsigned int &sta
// Name: setOpponentLevel() // Name: setOpponentLevel()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::setOpponentLevel(unsigned int threadNo, bool isOpponentLevel) void perfectAI::setOpponentLevel(unsigned int threadNo, bool isOpponentLevel)
{ {
threadVarsStruct *tv = &threadVars[threadNo]; threadVarsStruct *tv = &threadVars[threadNo];
tv->ownId = isOpponentLevel ? tv->field->oppPlayer->id : tv->field->curPlayer->id; tv->ownId = isOpponentLevel ? tv->field->oppPlayer->id : tv->field->curPlayer->id;
@ -1855,7 +1855,7 @@ void perfectKI::setOpponentLevel(unsigned int threadNo, bool isOpponentLevel)
// Name: getOpponentLevel() // Name: getOpponentLevel()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool perfectKI::getOpponentLevel(unsigned int threadNo) bool perfectAI::getOpponentLevel(unsigned int threadNo)
{ {
threadVarsStruct *tv = &threadVars[threadNo]; threadVarsStruct *tv = &threadVars[threadNo];
return (tv->ownId == tv->field->oppPlayer->id); return (tv->ownId == tv->field->oppPlayer->id);
@ -1865,7 +1865,7 @@ bool perfectKI::getOpponentLevel(unsigned int threadNo)
// Name: getPartnerLayer() // Name: getPartnerLayer()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
unsigned int perfectKI::getPartnerLayer(unsigned int layerNum) unsigned int perfectAI::getPartnerLayer(unsigned int layerNum)
{ {
if (layerNum < 100) if (layerNum < 100)
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
@ -1881,7 +1881,7 @@ unsigned int perfectKI::getPartnerLayer(unsigned int layerNum)
// Name: getSuccLayers() // Name: getSuccLayers()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::getSuccLayers(unsigned int layerNum, unsigned int *amountOfSuccLayers, unsigned int *succLayers) void perfectAI::getSuccLayers(unsigned int layerNum, unsigned int *amountOfSuccLayers, unsigned int *succLayers)
{ {
// locals // locals
unsigned int i; unsigned int i;
@ -1913,7 +1913,7 @@ void perfectKI::getSuccLayers(unsigned int layerNum, unsigned int *amountOfSuccL
// Name: getSymStateNumWithDoubles() // Name: getSymStateNumWithDoubles()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::getSymStateNumWithDoubles(unsigned int threadNo, unsigned int *numSymmetricStates, unsigned int **symStateNumbers) void perfectAI::getSymStateNumWithDoubles(unsigned int threadNo, unsigned int *numSymmetricStates, unsigned int **symStateNumbers)
{ {
// locals // locals
threadVarsStruct *tv = &threadVars[threadNo]; threadVarsStruct *tv = &threadVars[threadNo];
@ -1954,7 +1954,7 @@ void perfectKI::getSymStateNumWithDoubles(unsigned int threadNo, unsigned int *n
// Name: fieldIntegrityOK() // Name: fieldIntegrityOK()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool perfectKI::threadVarsStruct::fieldIntegrityOK(unsigned int numberOfMillsCurrentPlayer, unsigned int numberOfMillsOpponentPlayer, bool aStoneCanBeRemovedFromCurPlayer) bool perfectAI::threadVarsStruct::fieldIntegrityOK(unsigned int numberOfMillsCurrentPlayer, unsigned int numberOfMillsOpponentPlayer, bool aStoneCanBeRemovedFromCurPlayer)
{ {
// locals // locals
int i, j; int i, j;
@ -1999,7 +1999,7 @@ bool perfectKI::threadVarsStruct::fieldIntegrityOK(unsigned int numberOfMillsCur
// Name: isSymOperationInvariantOnGroupCD() // Name: isSymOperationInvariantOnGroupCD()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool perfectKI::isSymOperationInvariantOnGroupCD(unsigned int symmetryOperation, int *theField) bool perfectAI::isSymOperationInvariantOnGroupCD(unsigned int symmetryOperation, int *theField)
{ {
// locals // locals
unsigned int i; unsigned int i;
@ -2028,7 +2028,7 @@ bool perfectKI::isSymOperationInvariantOnGroupCD(unsigned int symmetryOperation,
// Name: storePredecessor() // Name: storePredecessor()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::threadVarsStruct::storePredecessor(unsigned int numberOfMillsCurrentPlayer, unsigned int numberOfMillsOpponentPlayer, unsigned int *amountOfPred, retroAnalysisPredVars *predVars) void perfectAI::threadVarsStruct::storePredecessor(unsigned int numberOfMillsCurrentPlayer, unsigned int numberOfMillsOpponentPlayer, unsigned int *amountOfPred, retroAnalysisPredVars *predVars)
{ {
// locals // locals
int originalField[fieldStruct::size]; int originalField[fieldStruct::size];
@ -2072,7 +2072,7 @@ void perfectKI::threadVarsStruct::storePredecessor(unsigned int numberOfMillsCur
// Name: getPredecessors() // Name: getPredecessors()
// Desc: CAUTION: States musn't be returned twice. // Desc: CAUTION: States musn't be returned twice.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void perfectKI::getPredecessors(unsigned int threadNo, unsigned int *amountOfPred, retroAnalysisPredVars *predVars) void perfectAI::getPredecessors(unsigned int threadNo, unsigned int *amountOfPred, retroAnalysisPredVars *predVars)
{ {
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// the important variables, which much be updated for the getLayerAndStateNumber function are the following ones: // the important variables, which much be updated for the getLayerAndStateNumber function are the following ones:
@ -2308,7 +2308,7 @@ void perfectKI::getPredecessors(unsigned int threadNo, unsigned int *amountOfPre
// Name: checkMoveAndSetSituation() // Name: checkMoveAndSetSituation()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool perfectKI::checkMoveAndSetSituation() bool perfectAI::checkMoveAndSetSituation()
{ {
// locals // locals
bool aStoneCanBeRemovedFromCurPlayer; bool aStoneCanBeRemovedFromCurPlayer;
@ -2387,7 +2387,7 @@ bool perfectKI::checkMoveAndSetSituation()
// Name: checkGetPossThanGetPred() // Name: checkGetPossThanGetPred()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool perfectKI::checkGetPossThanGetPred() bool perfectAI::checkGetPossThanGetPred()
{ {
// locals // locals
unsigned int stateNum, layerNum, i, j; unsigned int stateNum, layerNum, i, j;
@ -2466,7 +2466,7 @@ bool perfectKI::checkGetPossThanGetPred()
// Name: checkGetPredThanGetPoss() // Name: checkGetPredThanGetPoss()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool perfectKI::checkGetPredThanGetPoss() bool perfectAI::checkGetPredThanGetPoss()
{ {
// locals // locals
unsigned int threadNo = 0; unsigned int threadNo = 0;

View File

@ -12,7 +12,7 @@
#include <iostream> #include <iostream>
#include <cstdio> #include <cstdio>
#include <math.h> #include <math.h>
#include "muehleKI.h" #include "millAI.h"
#include "miniMax.h" #include "miniMax.h"
//using namespace std; //using namespace std;
@ -75,7 +75,7 @@
#define NUM_SYM_OPERATIONS 16 #define NUM_SYM_OPERATIONS 16
/*** Klassen *********************************************************/ /*** Klassen *********************************************************/
class perfectKI : public muehleKI, public miniMax class perfectAI : public millAI, public miniMax
{ {
protected: protected:
@ -162,7 +162,7 @@ protected:
unsigned int *idPossibilities; // returned pointer of getPossibilities()-function unsigned int *idPossibilities; // returned pointer of getPossibilities()-function
backupStruct *oldStates; // for undo()-function backupStruct *oldStates; // for undo()-function
possibilityStruct *possibilities; // for getPossNormalMove()-function possibilityStruct *possibilities; // for getPossNormalMove()-function
perfectKI *parent; // perfectAI *parent; //
// constructor // constructor
threadVarsStruct(); threadVarsStruct();
@ -227,8 +227,8 @@ protected:
public: public:
// Constructor / destructor // Constructor / destructor
perfectKI(const char *directory); perfectAI(const char *directory);
~perfectKI(); ~perfectAI();
// Functions // Functions
bool setDatabasePath(const char *directory); bool setDatabasePath(const char *directory);

View File

@ -1,28 +1,28 @@
/********************************************************************* /*********************************************************************
randomKI.cpp randomAI.cpp
Copyright (c) Thomas Weber. All rights reserved. Copyright (c) Thomas Weber. All rights reserved.
Copyright (C) 2021 The Sanmill developers (see AUTHORS file) Copyright (C) 2021 The Sanmill developers (see AUTHORS file)
Licensed under the MIT License. Licensed under the MIT License.
https://github.com/madweasel/madweasels-cpp https://github.com/madweasel/madweasels-cpp
\*********************************************************************/ \*********************************************************************/
#include "randomKI.h" #include "randomAI.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Name: randomKI() // Name: randomAI()
// Desc: randomKI class constructor // Desc: randomAI class constructor
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
randomKI::randomKI() randomAI::randomAI()
{ {
// Init // Init
srand((unsigned)time(nullptr)); srand((unsigned)time(nullptr));
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Name: ~randomKI() // Name: ~randomAI()
// Desc: randomKI class destructor // Desc: randomAI class destructor
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
randomKI::~randomKI() randomAI::~randomAI()
{ {
// Locals // Locals
@ -32,7 +32,7 @@ randomKI::~randomKI()
// Name: play() // Name: play()
// Desc: // Desc:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void randomKI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int *pushTo) void randomAI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int *pushTo)
{ {
// locals // locals
unsigned int from, to, direction; unsigned int from, to, direction;

View File

@ -1,5 +1,5 @@
/*********************************************************************\ /*********************************************************************\
randomKI.h randomAI.h
Copyright (c) Thomas Weber. All rights reserved. Copyright (c) Thomas Weber. All rights reserved.
Copyright (C) 2021 The Sanmill developers (see AUTHORS file) Copyright (C) 2021 The Sanmill developers (see AUTHORS file)
Licensed under the MIT License. Licensed under the MIT License.
@ -11,16 +11,16 @@
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include "muehleKI.h" #include "millAI.h"
/*** Klassen *********************************************************/ /*** Klassen *********************************************************/
class randomKI : public muehleKI class randomAI : public millAI
{ {
public: public:
// Constructor / destructor // Constructor / destructor
randomKI(); randomAI();
~randomKI(); ~randomAI();
// Functions // Functions
void play(fieldStruct *theField, unsigned int *pushFrom, unsigned int *pushTo); void play(fieldStruct *theField, unsigned int *pushFrom, unsigned int *pushTo);