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

View File

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

View File

@ -1,18 +1,18 @@
/*********************************************************************
muehle.cpp
Mill.cpp
Copyright (c) Thomas Weber. All rights reserved.
Copyright (C) 2021 The Sanmill developers (see AUTHORS file)
Licensed under the MIT License.
https://github.com/madweasel/madweasels-cpp
\*********************************************************************/
#include "muehle.h"
#include "mill.h"
//-----------------------------------------------------------------------------
// Name: muehle()
// Desc: muehle class constructor
// Name: Mill()
// Desc: Mill class constructor
//-----------------------------------------------------------------------------
muehle::muehle()
Mill::Mill()
{
srand((unsigned)time(nullptr));
@ -27,19 +27,19 @@ muehle::muehle()
}
//-----------------------------------------------------------------------------
// Name: ~muehle()
// Desc: muehle class destructor
// Name: ~Mill()
// Desc: Mill class destructor
//-----------------------------------------------------------------------------
muehle::~muehle()
Mill::~Mill()
{
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(moveLogTo);
@ -50,9 +50,9 @@ void muehle::deleteArrays()
//-----------------------------------------------------------------------------
// 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
deleteArrays();
@ -85,7 +85,7 @@ void muehle::beginNewGame(muehleKI *firstPlayerKI, muehleKI *secondPlayerKI, int
// Name: startSettingPhase()
// 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);
@ -98,7 +98,7 @@ bool muehle::startSettingPhase(muehleKI *firstPlayerKI, muehleKI *secondPlayerKI
// Name: setUpCalcPossibleMoves()
// 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
unsigned int i, j, k, movingDirection;
@ -132,7 +132,7 @@ void muehle::setUpCalcPossibleMoves(playerStruct *player)
// Name: setUpSetWarningAndMill()
// 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
int rowOwner = field.field[stone];
@ -150,7 +150,7 @@ void muehle::setUpSetWarningAndMill(unsigned int stone, unsigned int firstNeighb
// Name: putStone()
// 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
unsigned int i;
@ -221,7 +221,7 @@ bool muehle::putStone(unsigned int pos, int player)
// Name: settingPhaseHasFinished()
// Desc: This function has to be called when the setting phase has finished.
//-----------------------------------------------------------------------------
bool muehle::settingPhaseHasFinished()
bool Mill::settingPhaseHasFinished()
{
// remember initialField
field.copyField(&initialField);
@ -233,7 +233,7 @@ bool muehle::settingPhaseHasFinished()
// Name: getField()
// Desc: Copy the current field state into the array 'pField'.
//-----------------------------------------------------------------------------
bool muehle::getField(int *pField)
bool Mill::getField(int *pField)
{
unsigned int index;
@ -252,7 +252,7 @@ bool muehle::getField(int *pField)
// Name: getLog()
// 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;
@ -268,7 +268,7 @@ void muehle::getLog(unsigned int &numMovesDone, unsigned int *from, unsigned int
// Name: setNextPlayer()
// Desc: Current player and opponent player are switched in the field struct.
//-----------------------------------------------------------------------------
void muehle::setNextPlayer()
void Mill::setNextPlayer()
{
playerStruct *tmpPlayer;
@ -281,7 +281,7 @@ void muehle::setNextPlayer()
// Name: isCurrentPlayerHuman()
// 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;
else return (playerTwoKI == nullptr) ? true : false;
@ -291,7 +291,7 @@ bool muehle::isCurrentPlayerHuman()
// Name: isOpponentPlayerHuman()
// 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;
else return (playerTwoKI == nullptr) ? true : false;
@ -301,7 +301,7 @@ bool muehle::isOpponentPlayerHuman()
// Name: setKI()
// 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) {
playerOneKI = KI;
@ -315,7 +315,7 @@ void muehle::setKI(int player, muehleKI *KI)
// Name: getChoiceOfSpecialKI()
// 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;
*pushFrom = field.size;
@ -330,7 +330,7 @@ void muehle::getChoiceOfSpecialKI(muehleKI *KI, unsigned int *pushFrom, unsigned
// Name: getComputersChoice()
// 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;
*pushFrom = field.size;
@ -353,7 +353,7 @@ void muehle::getComputersChoice(unsigned int *pushFrom, unsigned int *pushTo)
// Name: isNormalMovePossible()
// 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
unsigned int movingDirection, i;
@ -386,7 +386,7 @@ bool muehle::isNormalMovePossible(unsigned int from, unsigned int to, playerStru
// Name: calcPossibleMoves()
// Desc: ...
//-----------------------------------------------------------------------------
void muehle::calcPossibleMoves(playerStruct *player)
void Mill::calcPossibleMoves(playerStruct *player)
{
// locals
unsigned int i, j;
@ -419,7 +419,7 @@ void muehle::calcPossibleMoves(playerStruct *player)
// Name: setWarningAndMill()
// 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
int rowOwner = field.field[stone];
@ -443,7 +443,7 @@ void muehle::setWarningAndMill(unsigned int stone, unsigned int firstNeighbour,
// Name: updateMillsAndWarnings()
// Desc:
//-----------------------------------------------------------------------------
void muehle::updateMillsAndWarnings(unsigned int newStone)
void Mill::updateMillsAndWarnings(unsigned int newStone)
{
// locals
unsigned int i;
@ -473,7 +473,7 @@ void muehle::updateMillsAndWarnings(unsigned int newStone)
// Name: moveStone()
// Desc:
//-----------------------------------------------------------------------------
bool muehle::moveStone(unsigned int pushFrom, unsigned int pushTo)
bool Mill::moveStone(unsigned int pushFrom, unsigned int pushTo)
{
// avoid index override
if (movesDone >= MAX_NUM_MOVES)
@ -600,7 +600,7 @@ bool muehle::moveStone(unsigned int pushFrom, unsigned int pushTo)
// Name: setCurrentGameState()
// Desc: Set an arbitrary game state as the current one.
//-----------------------------------------------------------------------------
bool muehle::setCurrentGameState(fieldStruct *curState)
bool Mill::setCurrentGameState(fieldStruct *curState)
{
curState->copyField(&field);
@ -618,7 +618,7 @@ bool muehle::setCurrentGameState(fieldStruct *curState)
// Name: compareWithField()
// 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;
bool ret = true;
@ -671,7 +671,7 @@ bool muehle::compareWithField(fieldStruct *compareField)
// Name: comparePlayers()
// 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;
bool ret = true;
@ -703,7 +703,7 @@ bool muehle::comparePlayers(playerStruct *playerA, playerStruct *playerB)
// Desc: Calls the printField() function of the current field.
// Prints the current game state on the screen.
//-----------------------------------------------------------------------------
void muehle::printField()
void Mill::printField()
{
field.printField();
}
@ -712,7 +712,7 @@ void muehle::printField()
// Name: undoLastMove()
// 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
unsigned int *moveLogFrom_bak = new unsigned int[movesDone];
@ -749,7 +749,7 @@ void muehle::undoLastMove(void)
// Name: calcNumberOfRestingStones()
// Desc:
//-----------------------------------------------------------------------------
void muehle::calcNumberOfRestingStones(int &numWhiteStonesResting, int &numBlackStonesResting)
void Mill::calcNumberOfRestingStones(int &numWhiteStonesResting, int &numBlackStonesResting)
{
if (getCurrentPlayer() == fieldStruct::playerTwo) {
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) 2021 The Sanmill developers (see AUTHORS file)
Licensed under the MIT License.
@ -14,7 +14,7 @@
#include <cstdio>
#include <time.h>
#include <stdlib.h>
#include "muehleKI.h"
#include "millAI.h"
using namespace std;
@ -27,13 +27,13 @@ using namespace std;
/*** Klassen *********************************************************/
class muehle
class Mill
{
private:
// Variables
unsigned int *moveLogFrom, *moveLogTo, movesDone; // array containing the history of moves done
muehleKI *playerOneKI; // class-pointer to the AI of player one
muehleKI *playerTwoKI; // class-pointer to the AI of player two
millAI *playerOneKI; // class-pointer to the AI of player one
millAI *playerTwoKI; // class-pointer to the AI of player two
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
int winner; // playerId of the player who has won the game. zero if game is still running.
@ -49,23 +49,23 @@ private:
public:
// Constructor / destructor
muehle();
~muehle();
Mill();
~Mill();
// Functions
void undoLastMove();
void beginNewGame(muehleKI *firstPlayerKI, muehleKI *secondPlayerKI, int currentPlayer);
void setKI(int player, muehleKI *KI);
void beginNewGame(millAI *firstPlayerKI, millAI *secondPlayerKI, int currentPlayer);
void setKI(int player, millAI *KI);
bool moveStone(unsigned int pushFrom, unsigned int pushTo);
void getComputersChoice(unsigned int *pushFrom, unsigned int *pushTo);
bool setCurrentGameState(fieldStruct *curState);
bool compareWithField(fieldStruct *compareField);
bool comparePlayers(playerStruct *playerA, playerStruct *playerB);
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 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 setUpSetWarningAndMill(unsigned int stone, unsigned int firstNeighbour, unsigned int secondNeighbour);
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) 2021 The Sanmill developers (see AUTHORS file)
Licensed under the MIT License.
https://github.com/madweasel/madweasels-cpp
\*********************************************************************/
#include "muehleKI.h"
#include "millAI.h"
using namespace std;

View File

@ -1,5 +1,5 @@
/*********************************************************************\
muehleKI.h
millAI.h
Copyright (c) Thomas Weber. All rights reserved.
Copyright (C) 2021 The Sanmill developers (see AUTHORS file)
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);
};
class muehleKI abstract
class millAI abstract
{
protected:
fieldStruct dummyField;
public:
// Constructor / destructor
muehleKI()
millAI()
{
dummyField.createField();
};
~muehleKI()
~millAI()
{
dummyField.deleteField();
};

View File

@ -1,27 +1,27 @@
/*********************************************************************
minMaxKI.cpp
miniMaxAI.cpp
Copyright (c) Thomas Weber. All rights reserved.
Copyright (C) 2021 The Sanmill developers (see AUTHORS file)
Licensed under the MIT License.
https://github.com/madweasel/madweasels-cpp
\*********************************************************************/
#include "minMaxKI.h"
#include "miniMaxAI.h"
//-----------------------------------------------------------------------------
// Name: minMaxKI()
// Desc: minMaxKI class constructor
// Name: miniMaxAI()
// Desc: miniMaxAI class constructor
//-----------------------------------------------------------------------------
minMaxKI::minMaxKI()
miniMaxAI::miniMaxAI()
{
depthOfFullTree = 0;
}
//-----------------------------------------------------------------------------
// Name: ~minMaxKI()
// Desc: minMaxKI class destructor
// Name: ~miniMaxAI()
// Desc: miniMaxAI class destructor
//-----------------------------------------------------------------------------
minMaxKI::~minMaxKI()
miniMaxAI::~miniMaxAI()
{
}
@ -29,7 +29,7 @@ minMaxKI::~minMaxKI()
// Name: play()
// Desc:
//-----------------------------------------------------------------------------
void minMaxKI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int *pushTo)
void miniMaxAI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int *pushTo)
{
// globals
field = theField;
@ -49,7 +49,7 @@ void minMaxKI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int
}
// 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
possibilities = new possibilityStruct[searchDepth + 1];
@ -82,7 +82,7 @@ void minMaxKI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int
// Name: setSearchDepth()
// Desc:
//-----------------------------------------------------------------------------
void minMaxKI::setSearchDepth(unsigned int depth)
void miniMaxAI::setSearchDepth(unsigned int depth)
{
depthOfFullTree = depth;
}
@ -91,7 +91,7 @@ void minMaxKI::setSearchDepth(unsigned int depth)
// Name: prepareBestChoiceCalculation()
// Desc:
//-----------------------------------------------------------------------------
void minMaxKI::prepareBestChoiceCalculation()
void miniMaxAI::prepareBestChoiceCalculation()
{
// calculate current value
currentValue = 0;
@ -102,7 +102,7 @@ void minMaxKI::prepareBestChoiceCalculation()
// Name: getPossSettingPhase()
// Desc:
//-----------------------------------------------------------------------------
unsigned int *minMaxKI::getPossSettingPhase(unsigned int *numPossibilities, void **pPossibilities)
unsigned int *miniMaxAI::getPossSettingPhase(unsigned int *numPossibilities, void **pPossibilities)
{
// locals
unsigned int i;
@ -129,7 +129,7 @@ unsigned int *minMaxKI::getPossSettingPhase(unsigned int *numPossibilities, void
// Name: getPossNormalMove()
// Desc:
//-----------------------------------------------------------------------------
unsigned int *minMaxKI::getPossNormalMove(unsigned int *numPossibilities, void **pPossibilities)
unsigned int *miniMaxAI::getPossNormalMove(unsigned int *numPossibilities, void **pPossibilities)
{
// locals
unsigned int from, to, dir;
@ -186,7 +186,7 @@ unsigned int *minMaxKI::getPossNormalMove(unsigned int *numPossibilities, void *
// Name: getPossStoneRemove()
// Desc:
//-----------------------------------------------------------------------------
unsigned int *minMaxKI::getPossStoneRemove(unsigned int *numPossibilities, void **pPossibilities)
unsigned int *miniMaxAI::getPossStoneRemove(unsigned int *numPossibilities, void **pPossibilities)
{
// locals
unsigned int i;
@ -213,7 +213,7 @@ unsigned int *minMaxKI::getPossStoneRemove(unsigned int *numPossibilities, void
// Name: getPossibilities()
// 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
*opponentsMove = (field->curPlayer->id == ownId) ? false : true;
@ -234,7 +234,7 @@ unsigned int *minMaxKI::getPossibilities(unsigned int threadNo, unsigned int *nu
// Name: getValueOfSituation()
// Desc:
//-----------------------------------------------------------------------------
void minMaxKI::getValueOfSituation(unsigned int threadNo, float &floatValue, twoBit &shortValue)
void miniMaxAI::getValueOfSituation(unsigned int threadNo, float &floatValue, twoBit &shortValue)
{
floatValue = currentValue;
shortValue = 0;
@ -244,7 +244,7 @@ void minMaxKI::getValueOfSituation(unsigned int threadNo, float &floatValue, two
// Name: deletePossibilities()
// 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()
// 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
backupStruct *oldState = (backupStruct *)pBackup;
@ -287,7 +287,7 @@ void minMaxKI::undo(unsigned int threadNo, unsigned int idPossibility, bool oppo
// Name: setWarning()
// 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 (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()
// Desc:
//-----------------------------------------------------------------------------
inline void minMaxKI::updateWarning(unsigned int firstStone, unsigned int secondStone)
inline void miniMaxAI::updateWarning(unsigned int firstStone, unsigned int secondStone)
{
// set warnings
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()
// 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
unsigned int neighbor, direction;
@ -416,7 +416,7 @@ inline void minMaxKI::updatePossibleMoves(unsigned int stone, playerStruct *ston
// Name: setStone()
// Desc:
//-----------------------------------------------------------------------------
inline void minMaxKI::setStone(unsigned int to, backupStruct *backup)
inline void miniMaxAI::setStone(unsigned int to, backupStruct *backup)
{
// backup
backup->from = field->size;
@ -443,7 +443,7 @@ inline void minMaxKI::setStone(unsigned int to, backupStruct *backup)
// Name: normalMove()
// 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->from = from;
@ -467,7 +467,7 @@ inline void minMaxKI::normalMove(unsigned int from, unsigned int to, backupStruc
// Name: removeStone()
// Desc:
//-----------------------------------------------------------------------------
inline void minMaxKI::removeStone(unsigned int from, backupStruct *backup)
inline void miniMaxAI::removeStone(unsigned int from, backupStruct *backup)
{
// backup
backup->from = from;
@ -495,7 +495,7 @@ inline void minMaxKI::removeStone(unsigned int from, backupStruct *backup)
// Name: move()
// 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
backupStruct *oldState = &oldStates[curSearchDepth];
@ -558,7 +558,7 @@ void minMaxKI::move(unsigned int threadNo, unsigned int idPossibility, bool oppo
// Name: printMoveInformation()
// Desc:
//-----------------------------------------------------------------------------
void minMaxKI::printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities)
void miniMaxAI::printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities)
{
// locals
possibilityStruct *tmpPossibility = (possibilityStruct *)pPossibilities;

View File

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

View File

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

View File

@ -21,21 +21,6 @@
<ClInclude Include="cyclicArray.h">
<Filter>Header Files</Filter>
</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">
<Filter>Header Files</Filter>
</ClInclude>
@ -51,6 +36,21 @@
<ClInclude Include="miniMaxWin.h">
<Filter>Header Files</Filter>
</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>
<ClCompile Include="bufferedFile.cpp">
@ -65,18 +65,6 @@
<ClCompile Include="minMaxKI.cpp">
<Filter>Source Files</Filter>
</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">
<Filter>Source Files</Filter>
</ClCompile>
@ -101,5 +89,17 @@
<ClCompile Include="miniMax_test.cpp">
<Filter>Source Files</Filter>
</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>
</Project>

View File

@ -6,7 +6,7 @@
https://github.com/madweasel/madweasels-cpp
\*********************************************************************/
#include "perfectKI.h"
#include "perfectAI.h"
unsigned int soTableTurnLeft[] = {
2, 14, 23,
@ -186,7 +186,7 @@ unsigned int fieldPosIsOfGroup[] = { GROUP_C, GROUP_D,
// Name: perfectKI()
// Desc: perfectKI class constructor
//-----------------------------------------------------------------------------
perfectKI::perfectKI(const char *directory)
perfectAI::perfectAI(const char *directory)
{
// loacls
unsigned int i, a, b, c, totalNumStones;
@ -629,7 +629,7 @@ perfectKI::perfectKI(const char *directory)
// Name: ~perfectKI()
// Desc: perfectKI class destructor
//-----------------------------------------------------------------------------
perfectKI::~perfectKI()
perfectAI::~perfectAI()
{
// locals
unsigned int curThread;
@ -648,7 +648,7 @@ perfectKI::~perfectKI()
// Name: play()
// 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
theField->copyField(&dummyField);
@ -703,7 +703,7 @@ void perfectKI::play(fieldStruct *theField, unsigned int *pushFrom, unsigned int
// Name: prepareDatabaseCalculation()
// Desc:
//-----------------------------------------------------------------------------
void perfectKI::prepareDatabaseCalculation()
void perfectAI::prepareDatabaseCalculation()
{
// only prepare layers?
unsigned int curThread;
@ -723,7 +723,7 @@ void perfectKI::prepareDatabaseCalculation()
// Name: wrapUpDatabaseCalculation()
// Desc:
//-----------------------------------------------------------------------------
void perfectKI::wrapUpDatabaseCalculation(bool calculationAborted)
void perfectAI::wrapUpDatabaseCalculation(bool calculationAborted)
{
// locals
unsigned int curThread;
@ -740,7 +740,7 @@ void perfectKI::wrapUpDatabaseCalculation(bool calculationAborted)
// Name: testLayers()
// Desc:
//-----------------------------------------------------------------------------
bool perfectKI::testLayers(unsigned int startTestFromLayer, unsigned int endTestAtLayer)
bool perfectAI::testLayers(unsigned int startTestFromLayer, unsigned int endTestAtLayer)
{
// locals
unsigned int curLayer;
@ -762,7 +762,7 @@ bool perfectKI::testLayers(unsigned int startTestFromLayer, unsigned int endTest
// Name: setDatabasePath()
// Desc:
//-----------------------------------------------------------------------------
bool perfectKI::setDatabasePath(const char *directory)
bool perfectAI::setDatabasePath(const char *directory)
{
if (directory == nullptr) {
return false;
@ -777,7 +777,7 @@ bool perfectKI::setDatabasePath(const char *directory)
// Name: prepareBestChoiceCalculation()
// Desc:
//-----------------------------------------------------------------------------
void perfectKI::prepareBestChoiceCalculation()
void perfectAI::prepareBestChoiceCalculation()
{
for (unsigned int curThread = 0; curThread < getNumThreads(); curThread++) {
threadVars[curThread].floatValue = 0.0f;
@ -791,7 +791,7 @@ void perfectKI::prepareBestChoiceCalculation()
// Name: threadVarsStruct()
// Desc:
//-----------------------------------------------------------------------------
perfectKI::threadVarsStruct::threadVarsStruct()
perfectAI::threadVarsStruct::threadVarsStruct()
{
field = nullptr;
floatValue = 0;
@ -811,7 +811,7 @@ perfectKI::threadVarsStruct::threadVarsStruct()
// Name: getPossSettingPhase()
// Desc:
//-----------------------------------------------------------------------------
unsigned int *perfectKI::threadVarsStruct::getPossSettingPhase(unsigned int *numPossibilities, void **pPossibilities)
unsigned int *perfectAI::threadVarsStruct::getPossSettingPhase(unsigned int *numPossibilities, void **pPossibilities)
{
// locals
unsigned int i;
@ -858,7 +858,7 @@ unsigned int *perfectKI::threadVarsStruct::getPossSettingPhase(unsigned int *num
// Name: getPossNormalMove()
// Desc:
//-----------------------------------------------------------------------------
unsigned int *perfectKI::threadVarsStruct::getPossNormalMove(unsigned int *numPossibilities, void **pPossibilities)
unsigned int *perfectAI::threadVarsStruct::getPossNormalMove(unsigned int *numPossibilities, void **pPossibilities)
{
// locals
unsigned int from, to, dir;
@ -917,7 +917,7 @@ unsigned int *perfectKI::threadVarsStruct::getPossNormalMove(unsigned int *numPo
// Name: getPossStoneRemove()
// Desc:
//-----------------------------------------------------------------------------
unsigned int *perfectKI::threadVarsStruct::getPossStoneRemove(unsigned int *numPossibilities, void **pPossibilities)
unsigned int *perfectAI::threadVarsStruct::getPossStoneRemove(unsigned int *numPossibilities, void **pPossibilities)
{
// locals
unsigned int i;
@ -944,7 +944,7 @@ unsigned int *perfectKI::threadVarsStruct::getPossStoneRemove(unsigned int *numP
// Name: getPossibilities()
// 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
bool aStoneCanBeRemovedFromCurPlayer = 0;
@ -981,7 +981,7 @@ unsigned int *perfectKI::getPossibilities(unsigned int threadNo, unsigned int *n
// Name: getValueOfSituation()
// 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];
floatValue = tv->floatValue;
@ -992,7 +992,7 @@ void perfectKI::getValueOfSituation(unsigned int threadNo, float &floatValue, tw
// Name: deletePossibilities()
// 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()
// 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
threadVarsStruct *tv = &threadVars[threadNo];
@ -1036,7 +1036,7 @@ void perfectKI::undo(unsigned int threadNo, unsigned int idPossibility, bool opp
// Name: setWarning()
// 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 (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()
// 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
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()
// 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
unsigned int neighbor, direction;
@ -1125,7 +1125,7 @@ inline void perfectKI::threadVarsStruct::updatePossibleMoves(unsigned int stone,
// Name: setStone()
// Desc:
//-----------------------------------------------------------------------------
inline void perfectKI::threadVarsStruct::setStone(unsigned int to, backupStruct *backup)
inline void perfectAI::threadVarsStruct::setStone(unsigned int to, backupStruct *backup)
{
// backup
backup->from = field->size;
@ -1152,7 +1152,7 @@ inline void perfectKI::threadVarsStruct::setStone(unsigned int to, backupStruct
// Name: normalMove()
// 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->from = from;
@ -1176,7 +1176,7 @@ inline void perfectKI::threadVarsStruct::normalMove(unsigned int from, unsigned
// Name: removeStone()
// Desc:
//-----------------------------------------------------------------------------
inline void perfectKI::threadVarsStruct::removeStone(unsigned int from, backupStruct *backup)
inline void perfectAI::threadVarsStruct::removeStone(unsigned int from, backupStruct *backup)
{
// backup
backup->from = from;
@ -1204,7 +1204,7 @@ inline void perfectKI::threadVarsStruct::removeStone(unsigned int from, backupSt
// Name: move()
// 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
threadVarsStruct *tv = &threadVars[threadNo];
@ -1274,7 +1274,7 @@ void perfectKI::move(unsigned int threadNo, unsigned int idPossibility, bool opp
// Name: storeValueOfMove()
// 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
threadVarsStruct *tv = &threadVars[threadNo];
@ -1297,7 +1297,7 @@ void perfectKI::storeValueOfMove(unsigned int threadNo, unsigned int idPossibili
// Name: getValueOfMoves()
// 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
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()
// Desc:
//-----------------------------------------------------------------------------
void perfectKI::printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities)
void perfectAI::printMoveInformation(unsigned int threadNo, unsigned int idPossibility, void *pPossibilities)
{
// locals
threadVarsStruct *tv = &threadVars[threadNo];
@ -1400,7 +1400,7 @@ void perfectKI::printMoveInformation(unsigned int threadNo, unsigned int idPossi
// Name: getNumberOfLayers()
// Desc: called one time
//-----------------------------------------------------------------------------
unsigned int perfectKI::getNumberOfLayers()
unsigned int perfectAI::getNumberOfLayers()
{
return NUM_LAYERS;
}
@ -1409,7 +1409,7 @@ unsigned int perfectKI::getNumberOfLayers()
// Name: shallRetroAnalysisBeUsed()
// Desc: called one time for each layer time
//-----------------------------------------------------------------------------
bool perfectKI::shallRetroAnalysisBeUsed(unsigned int layerNum)
bool perfectAI::shallRetroAnalysisBeUsed(unsigned int layerNum)
{
if (layerNum < 100)
return true;
@ -1421,7 +1421,7 @@ bool perfectKI::shallRetroAnalysisBeUsed(unsigned int layerNum)
// Name: getNumberOfKnotsInLayer()
// Desc: called one time
//-----------------------------------------------------------------------------
unsigned int perfectKI::getNumberOfKnotsInLayer(unsigned int layerNum)
unsigned int perfectAI::getNumberOfKnotsInLayer(unsigned int layerNum)
{
// locals
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()
// 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
long long result = 1;
@ -1472,7 +1472,7 @@ long long perfectKI::mOverN_Function(unsigned int m, unsigned int n)
// Name: applySymmetrieOperationOnField()
// 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++) {
destField[i] = sourceField[symmetryOperationTable[symmetryOperationNumber][i]];
@ -1483,7 +1483,7 @@ void perfectKI::applySymmetrieOperationOnField(unsigned char symmetryOperationNu
// Name: getLayerNumber()
// Desc:
//-----------------------------------------------------------------------------
unsigned int perfectKI::getLayerNumber(unsigned int threadNo)
unsigned int perfectAI::getLayerNumber(unsigned int threadNo)
{
threadVarsStruct *tv = &threadVars[threadNo];
unsigned int numBlackStones = tv->field->oppPlayer->numStones;
@ -1496,7 +1496,7 @@ unsigned int perfectKI::getLayerNumber(unsigned int threadNo)
// Name: getLayerAndStateNumber()
// 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];
return tv->getLayerAndStateNumber(layerNum, stateNumber);
@ -1506,7 +1506,7 @@ unsigned int perfectKI::getLayerAndStateNumber(unsigned int threadNo, unsigned i
// Name: getLayerAndStateNumber()
// 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
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.
// 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 ?
if (getNumberOfLayers() <= layerNum) return false;
@ -1740,7 +1740,7 @@ bool perfectKI::setSituation(unsigned int threadNo, unsigned int layerNum, unsig
// Name: calcPossibleMoves()
// Desc:
//-----------------------------------------------------------------------------
void perfectKI::threadVarsStruct::calcPossibleMoves(playerStruct *player)
void perfectAI::threadVarsStruct::calcPossibleMoves(playerStruct *player)
{
// locals
unsigned int i, j, k, movingDirection;
@ -1774,7 +1774,7 @@ void perfectKI::threadVarsStruct::calcPossibleMoves(playerStruct *player)
// Name: setWarningAndMill()
// 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
int rowOwner = field->field[stone];
@ -1792,7 +1792,7 @@ void perfectKI::threadVarsStruct::setWarningAndMill(unsigned int stone, unsigned
// Name: getOutputInformation()
// Desc:
//-----------------------------------------------------------------------------
string perfectKI::getOutputInformation(unsigned int layerNum)
string perfectAI::getOutputInformation(unsigned int layerNum)
{
stringstream ss;
ss << " white stones : " << layer[layerNum].numWhiteStones << " \tblack stones : " << layer[layerNum].numBlackStones;
@ -1803,7 +1803,7 @@ string perfectKI::getOutputInformation(unsigned int layerNum)
// Name: printField()
// Desc:
//-----------------------------------------------------------------------------
void perfectKI::printField(unsigned int threadNo, unsigned char value)
void perfectAI::printField(unsigned int threadNo, unsigned char value)
{
threadVarsStruct *tv = &threadVars[threadNo];
char wonStr[] = "WON";
@ -1821,7 +1821,7 @@ void perfectKI::printField(unsigned int threadNo, unsigned char value)
// Name: getField()
// 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
setSituation(0, layerNum, stateNumber);
@ -1836,7 +1836,7 @@ void perfectKI::getField(unsigned int layerNum, unsigned int stateNumber, fieldS
// Name: getLayerAndStateNumber()
// 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);
}
@ -1845,7 +1845,7 @@ void perfectKI::getLayerAndStateNumber(unsigned int &layerNum, unsigned int &sta
// Name: setOpponentLevel()
// Desc:
//-----------------------------------------------------------------------------
void perfectKI::setOpponentLevel(unsigned int threadNo, bool isOpponentLevel)
void perfectAI::setOpponentLevel(unsigned int threadNo, bool isOpponentLevel)
{
threadVarsStruct *tv = &threadVars[threadNo];
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()
// Desc:
//-----------------------------------------------------------------------------
bool perfectKI::getOpponentLevel(unsigned int threadNo)
bool perfectAI::getOpponentLevel(unsigned int threadNo)
{
threadVarsStruct *tv = &threadVars[threadNo];
return (tv->ownId == tv->field->oppPlayer->id);
@ -1865,7 +1865,7 @@ bool perfectKI::getOpponentLevel(unsigned int threadNo)
// Name: getPartnerLayer()
// Desc:
//-----------------------------------------------------------------------------
unsigned int perfectKI::getPartnerLayer(unsigned int layerNum)
unsigned int perfectAI::getPartnerLayer(unsigned int layerNum)
{
if (layerNum < 100)
for (int i = 0; i < 100; i++) {
@ -1881,7 +1881,7 @@ unsigned int perfectKI::getPartnerLayer(unsigned int layerNum)
// Name: getSuccLayers()
// 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
unsigned int i;
@ -1913,7 +1913,7 @@ void perfectKI::getSuccLayers(unsigned int layerNum, unsigned int *amountOfSuccL
// Name: getSymStateNumWithDoubles()
// 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
threadVarsStruct *tv = &threadVars[threadNo];
@ -1954,7 +1954,7 @@ void perfectKI::getSymStateNumWithDoubles(unsigned int threadNo, unsigned int *n
// Name: fieldIntegrityOK()
// 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
int i, j;
@ -1999,7 +1999,7 @@ bool perfectKI::threadVarsStruct::fieldIntegrityOK(unsigned int numberOfMillsCur
// Name: isSymOperationInvariantOnGroupCD()
// Desc:
//-----------------------------------------------------------------------------
bool perfectKI::isSymOperationInvariantOnGroupCD(unsigned int symmetryOperation, int *theField)
bool perfectAI::isSymOperationInvariantOnGroupCD(unsigned int symmetryOperation, int *theField)
{
// locals
unsigned int i;
@ -2028,7 +2028,7 @@ bool perfectKI::isSymOperationInvariantOnGroupCD(unsigned int symmetryOperation,
// Name: storePredecessor()
// 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
int originalField[fieldStruct::size];
@ -2072,7 +2072,7 @@ void perfectKI::threadVarsStruct::storePredecessor(unsigned int numberOfMillsCur
// Name: getPredecessors()
// 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:
@ -2308,7 +2308,7 @@ void perfectKI::getPredecessors(unsigned int threadNo, unsigned int *amountOfPre
// Name: checkMoveAndSetSituation()
// Desc:
//-----------------------------------------------------------------------------
bool perfectKI::checkMoveAndSetSituation()
bool perfectAI::checkMoveAndSetSituation()
{
// locals
bool aStoneCanBeRemovedFromCurPlayer;
@ -2387,7 +2387,7 @@ bool perfectKI::checkMoveAndSetSituation()
// Name: checkGetPossThanGetPred()
// Desc:
//-----------------------------------------------------------------------------
bool perfectKI::checkGetPossThanGetPred()
bool perfectAI::checkGetPossThanGetPred()
{
// locals
unsigned int stateNum, layerNum, i, j;
@ -2466,7 +2466,7 @@ bool perfectKI::checkGetPossThanGetPred()
// Name: checkGetPredThanGetPoss()
// Desc:
//-----------------------------------------------------------------------------
bool perfectKI::checkGetPredThanGetPoss()
bool perfectAI::checkGetPredThanGetPoss()
{
// locals
unsigned int threadNo = 0;

View File

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

View File

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

View File

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