alten Code entfernt
Check auf Kantenzüge
This commit is contained in:
parent
c0d135fae2
commit
031d88284f
|
@ -22,34 +22,6 @@ send_move(int row, int col)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//int
|
|
||||||
//buildTree(gameTree *currentNode, cell (*field)[fieldSize], movesList *moves, int depth, char enemyc) {
|
|
||||||
// if (depth == 0 || moves->movesNumber == 0)
|
|
||||||
// return 0;
|
|
||||||
// currentNode->numChildMoves = moves->movesNumber;
|
|
||||||
// currentNode->childMove = new gameTree[maxMoves]();
|
|
||||||
// //switch stone char
|
|
||||||
// char ownc = getEnemyChar(enemyc);
|
|
||||||
//
|
|
||||||
////#ifdef debugprint
|
|
||||||
//// printf("Depth %d: enemy: %c\n", depth, enemyc);
|
|
||||||
////#endif
|
|
||||||
// for(size_t i=0; i<moves->movesNumber; ++i)
|
|
||||||
// {
|
|
||||||
// currentNode->childMove[i].nodeMove = moves->list[i];
|
|
||||||
// size_t fieldMemSize = fieldSize*fieldSize*sizeof(cell);
|
|
||||||
// auto futureField = new cell[fieldSize][fieldSize]();
|
|
||||||
// memcpy(futureField, field, fieldMemSize);
|
|
||||||
// futureField[(moves->list[i].turnRow-1)][(moves->list[i].turnCol-1)].content=enemyc;
|
|
||||||
// movesList *futureMoves = new movesList();
|
|
||||||
// findMoves(futureField, futureMoves, enemyc);
|
|
||||||
// buildTree(&(currentNode->childMove[i]), futureField, futureMoves, depth-1, getEnemyChar(enemyc));
|
|
||||||
// delete [] futureMoves;
|
|
||||||
// delete [] futureField;
|
|
||||||
// }
|
|
||||||
// return 1;
|
|
||||||
//}
|
|
||||||
|
|
||||||
move
|
move
|
||||||
maxEvalMove(std::vector<evalMove> *curMoves) {
|
maxEvalMove(std::vector<evalMove> *curMoves) {
|
||||||
evalMove maxM;
|
evalMove maxM;
|
||||||
|
@ -65,55 +37,17 @@ maxEvalMove(std::vector<evalMove> *curMoves) {
|
||||||
return maxM.m;
|
return maxM.m;
|
||||||
}
|
}
|
||||||
|
|
||||||
//int
|
int
|
||||||
//maxInt(std::vector<int> *evaluations) {
|
isEdgeMove(move m) {
|
||||||
// int maxE = -10;
|
if( ((m.turnRow == 1 || m.turnRow == fieldSize) && m.turnCol > 1 && m.turnCol < fieldSize) ||
|
||||||
// for(size_t i = 0; i<evaluations->size(); ++i)
|
((m.turnCol == 1 || m.turnCol == fieldSize) && m.turnRow > 1 && m.turnRow < fieldSize) )
|
||||||
// {
|
return 1;
|
||||||
// if(evaluations->at(i) > maxE)
|
return 0;
|
||||||
// {
|
}
|
||||||
// maxE = evaluations->at(i);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return maxE;
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
////MiniMax Algorithmus
|
|
||||||
//int
|
|
||||||
//eval(gameTree *currentNode, int depth) {
|
|
||||||
// if (depth == 0 || !currentNode->numChildMoves)
|
|
||||||
// {
|
|
||||||
// //gut: hohe Mobilität, Eckzüge. Schlecht: Züge auf Felder direkt vor der Ecke
|
|
||||||
// return (currentNode->numChildMoves + 5*isCornerField(currentNode->nodeMove) - 2*isCOrXField(currentNode->nodeMove));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// std::vector<int> curEvals;
|
|
||||||
// for(size_t i = 0; i < currentNode->numChildMoves; ++i)
|
|
||||||
// {
|
|
||||||
// int curEval = -1 * eval(&(currentNode->childMove[i]), depth-1);
|
|
||||||
// curEvals.push_back(curEval);
|
|
||||||
// }
|
|
||||||
// return maxInt(&curEvals);
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//move
|
|
||||||
//findBestMove(gameTree *currentNode, int depth) {
|
|
||||||
// std::vector<evalMove> curMoves;
|
|
||||||
// for(size_t i = 0; i < currentNode->numChildMoves; ++i)
|
|
||||||
// {
|
|
||||||
// evalMove m;
|
|
||||||
// m.evaluation = -1 * eval(&(currentNode->childMove[i]), depth-1);
|
|
||||||
// m.m = currentNode->childMove[i].nodeMove;
|
|
||||||
//#ifdef debugprint
|
|
||||||
// printf("findBest %d: %d, %d\n", m.evaluation, m.m.turnRow, m.m.turnCol);
|
|
||||||
//#endif
|
|
||||||
// curMoves.push_back(m);
|
|
||||||
// }
|
|
||||||
// return maxEvalMove(&curMoves);
|
|
||||||
//}
|
|
||||||
|
|
||||||
move
|
move
|
||||||
nFindBestMove(cell (*field)[fieldSize], movesList *moves, char enemyc) {
|
findBestMove(cell (*field)[fieldSize], movesList *moves, char enemyc) {
|
||||||
std::vector<evalMove> curMoves;
|
std::vector<evalMove> curMoves;
|
||||||
printf("NumOwnMoves: %d\n", moves->movesNumber);
|
printf("NumOwnMoves: %d\n", moves->movesNumber);
|
||||||
for(size_t i=0; i < moves->movesNumber; ++i)
|
for(size_t i=0; i < moves->movesNumber; ++i)
|
||||||
|
@ -129,8 +63,8 @@ nFindBestMove(cell (*field)[fieldSize], movesList *moves, char enemyc) {
|
||||||
findMoves(futureField, futureMoves, enemyc);
|
findMoves(futureField, futureMoves, enemyc);
|
||||||
evalMove m;
|
evalMove m;
|
||||||
m.m = moves->list[i];
|
m.m = moves->list[i];
|
||||||
//gut: Eckzüge. Schlecht: hohe Mobilität des Gegners, Züge auf Felder direkt vor der Ecke
|
//gut: Eckzüge, Kantenzüge(Endspiel). Schlecht: hohe Mobilität des Gegners, Züge auf Felder direkt vor der Ecke(außer im Endspiel), Kantenzüge(außer im Endspiel)
|
||||||
m.evaluation = 5*isCornerField(m.m) - futureMoves->movesNumber - 2*(!endgame)*isCOrXField(m.m);
|
m.evaluation = 5*isCornerField(m.m) - futureMoves->movesNumber - 2*(!endgame)*isCOrXField(m.m) + (endgame)*2*isEdgeMove(m.m) - (!endgame)*2*isEdgeMove(m.m);
|
||||||
#ifdef debugprint
|
#ifdef debugprint
|
||||||
printf("eval: %d, move: %d, %d\n", m.evaluation, m.m.turnRow, m.m.turnCol);
|
printf("eval: %d, move: %d, %d\n", m.evaluation, m.m.turnRow, m.m.turnCol);
|
||||||
#endif
|
#endif
|
||||||
|
@ -216,7 +150,7 @@ int main(void)
|
||||||
//treeRoot->nodeMove.turnRow = 0;
|
//treeRoot->nodeMove.turnRow = 0;
|
||||||
//treeRoot->nodeMove.turnCol = 0;
|
//treeRoot->nodeMove.turnCol = 0;
|
||||||
//buildTree(treeRoot, field, moves, 1, getEnemyChar(enemyc));
|
//buildTree(treeRoot, field, moves, 1, getEnemyChar(enemyc));
|
||||||
finalMove = nFindBestMove(field, moves, getEnemyChar(enemyc));
|
finalMove = findBestMove(field, moves, getEnemyChar(enemyc));
|
||||||
}
|
}
|
||||||
|
|
||||||
turn_row=finalMove.turnRow;
|
turn_row=finalMove.turnRow;
|
||||||
|
|
|
@ -83,7 +83,7 @@ fillMovesList(cell (*field)[fieldSize], movesList *moves, size_t row, size_t col
|
||||||
if (*ownCount && *enemyCount > 0)
|
if (*ownCount && *enemyCount > 0)
|
||||||
{
|
{
|
||||||
#ifdef debugprint
|
#ifdef debugprint
|
||||||
printf("BAM!\n");
|
printf("MOVE!\n");
|
||||||
#endif
|
#endif
|
||||||
moves->list[moves->movesNumber].turnRow = row+1;
|
moves->list[moves->movesNumber].turnRow = row+1;
|
||||||
moves->list[moves->movesNumber].turnCol = col+1;
|
moves->list[moves->movesNumber].turnCol = col+1;
|
||||||
|
|
Loading…
Reference in a new issue