perfect/position: deleteArrays -> exit
This commit is contained in:
parent
1aef4bbc4e
commit
840c412e6a
|
@ -32,14 +32,14 @@ Position::Position()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
Position::~Position()
|
Position::~Position()
|
||||||
{
|
{
|
||||||
deleteArrays();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Name: deleteArrays()
|
// Name: deleteArrays()
|
||||||
// Desc: Deletes all arrays the Position class has created.
|
// Desc: Deletes all arrays the Position class has created.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Position::deleteArrays()
|
void Position::exit()
|
||||||
{
|
{
|
||||||
SAFE_DELETE_ARRAY(moveLogFrom);
|
SAFE_DELETE_ARRAY(moveLogFrom);
|
||||||
SAFE_DELETE_ARRAY(moveLogTo);
|
SAFE_DELETE_ARRAY(moveLogTo);
|
||||||
|
@ -55,7 +55,7 @@ void Position::deleteArrays()
|
||||||
void Position::beginNewGame(millAI *firstPlayerAI, millAI *secondPlayerAI, int currentPlayer)
|
void Position::beginNewGame(millAI *firstPlayerAI, millAI *secondPlayerAI, int currentPlayer)
|
||||||
{
|
{
|
||||||
// free mem
|
// free mem
|
||||||
deleteArrays();
|
exit();
|
||||||
|
|
||||||
// create arrays
|
// create arrays
|
||||||
field.createField();
|
field.createField();
|
||||||
|
@ -107,19 +107,24 @@ void Position::setUpCalcPossibleMoves(playerStruct *player)
|
||||||
for (j = 0; j < fieldStruct::size; j++) {
|
for (j = 0; j < fieldStruct::size; j++) {
|
||||||
|
|
||||||
// is stone from player ?
|
// is stone from player ?
|
||||||
if (field.field[i] != player->id) continue;
|
if (field.field[i] != player->id)
|
||||||
|
continue;
|
||||||
|
|
||||||
// is destination free ?
|
// is destination free ?
|
||||||
if (field.field[j] != field.squareIsFree) continue;
|
if (field.field[j] != field.squareIsFree)
|
||||||
|
continue;
|
||||||
|
|
||||||
// when current player has only 3 stones he is allowed to spring his stone
|
// when current player has only 3 stones he is allowed to spring his stone
|
||||||
if (player->numStones > 3 || field.settingPhase) {
|
if (player->numStones > 3 || field.settingPhase) {
|
||||||
|
|
||||||
// determine moving direction
|
// determine moving direction
|
||||||
for (k = 0, movingDirection = 4; k < 4; k++) if (field.connectedSquare[i][k] == j) movingDirection = k;
|
for (k = 0, movingDirection = 4; k < 4; k++)
|
||||||
|
if (field.connectedSquare[i][k] == j)
|
||||||
|
movingDirection = k;
|
||||||
|
|
||||||
// are both squares connected ?
|
// are both squares connected ?
|
||||||
if (movingDirection == 4) continue;
|
if (movingDirection == 4)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// everything is ok
|
// everything is ok
|
||||||
|
@ -147,10 +152,10 @@ void Position::setUpSetWarningAndMill(unsigned int stone, unsigned int firstNeig
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Name: putStone()
|
// Name: put_piece()
|
||||||
// Desc: Put a stone onto the field during the setting phase.
|
// Desc: Put a stone onto the field during the setting phase.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool Position::putStone(unsigned int pos, int player)
|
bool Position::put_piece(unsigned int pos, int player)
|
||||||
{
|
{
|
||||||
// locals
|
// locals
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
|
@ -44,7 +44,7 @@ private:
|
||||||
int beginningPlayer; // playerId of the player who makes the first move
|
int beginningPlayer; // playerId of the player who makes the first move
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
void deleteArrays();
|
void exit();
|
||||||
void setNextPlayer();
|
void setNextPlayer();
|
||||||
void calcPossibleMoves(playerStruct *player);
|
void calcPossibleMoves(playerStruct *player);
|
||||||
void updateMillsAndWarnings(unsigned int newStone);
|
void updateMillsAndWarnings(unsigned int newStone);
|
||||||
|
@ -67,7 +67,7 @@ public:
|
||||||
bool comparePlayers(playerStruct *playerA, playerStruct *playerB);
|
bool comparePlayers(playerStruct *playerA, playerStruct *playerB);
|
||||||
void printField();
|
void printField();
|
||||||
bool startSettingPhase(millAI *firstPlayerAI, millAI *secondPlayerAI, int currentPlayer, bool settingPhase);
|
bool startSettingPhase(millAI *firstPlayerAI, millAI *secondPlayerAI, int currentPlayer, bool settingPhase);
|
||||||
bool putStone(unsigned int pos, int player);
|
bool put_piece(unsigned int pos, int player);
|
||||||
bool settingPhaseHasFinished();
|
bool settingPhaseHasFinished();
|
||||||
void getChoiceOfSpecialAI(millAI *AI, unsigned int *pushFrom, unsigned int *pushTo);
|
void getChoiceOfSpecialAI(millAI *AI, unsigned int *pushFrom, unsigned int *pushTo);
|
||||||
void setUpCalcPossibleMoves(playerStruct *player);
|
void setUpCalcPossibleMoves(playerStruct *player);
|
||||||
|
|
Loading…
Reference in New Issue