findMoves() now calls all other find(...)Moves()
This commit is contained in:
parent
976efce0fd
commit
27d563173e
|
@ -11,6 +11,18 @@ int iterDiagForwards(cell (*)[fieldSize], movesList *, size_t, size_t);
|
||||||
|
|
||||||
int iterDiagBackwards(cell (*)[fieldSize], movesList *, int, int);
|
int iterDiagBackwards(cell (*)[fieldSize], movesList *, int, int);
|
||||||
|
|
||||||
|
//adds all hotizontally-forward found moves to movesList
|
||||||
|
int findHorizontalForwardMoves(cell (*)[fieldSize], movesList *);
|
||||||
|
int findHorizontalBackwardMoves(cell (*)[fieldSize], movesList *);
|
||||||
|
int findVerticalForwardMoves(cell (*)[fieldSize], movesList *);
|
||||||
|
int findVerticalBackwardMoves(cell (*)[fieldSize], movesList *);
|
||||||
|
int findDiagonalTopLeftMoves(cell (*)[fieldSize], movesList *);
|
||||||
|
int findDiagonalBottomRightMoves(cell (*)[fieldSize], movesList *);
|
||||||
|
int findDiagonalBottomLeftMoves(cell (*)[fieldSize], movesList *);
|
||||||
|
int findDiagonalTopRightMoves(cell (*)[fieldSize], movesList *);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char enemyc = 0, ownc = 0;
|
char enemyc = 0, ownc = 0;
|
||||||
|
|
||||||
char
|
char
|
||||||
|
@ -286,3 +298,15 @@ findDiagonalTopRightMoves(cell (*field)[fieldSize], movesList *moves) {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
findMoves(cell (*field)[fieldSize], movesList *moves) {
|
||||||
|
return findHorizontalForwardMoves(field, moves) +
|
||||||
|
findHorizontalBackwardMoves(field, moves) +
|
||||||
|
findVerticalForwardMoves(field, moves) +
|
||||||
|
findVerticalBackwardMoves(field, moves) +
|
||||||
|
findDiagonalBottomRightMoves(field, moves) +
|
||||||
|
findDiagonalTopLeftMoves(field, moves) +
|
||||||
|
findDiagonalBottomLeftMoves(field, moves) +
|
||||||
|
findDiagonalTopRightMoves(field, moves);
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef PLAYERLIB_H
|
#ifndef PLAYERLIB_H
|
||||||
#define PLAYERLIB_H
|
#define PLAYERLIB_H
|
||||||
|
|
||||||
const int fieldSize=8;
|
const int fieldSize=8; // =fieldHeight=fieldWidth
|
||||||
|
|
||||||
extern char enemyc; //initially 0, contains char of enemy's stone
|
extern char enemyc; //initially 0, contains char of enemy's stone
|
||||||
extern char ownc;
|
extern char ownc;
|
||||||
|
@ -24,14 +24,6 @@ extern char getEnemyChar(char);
|
||||||
//reads the stateBuffer string into a 2d matrix
|
//reads the stateBuffer string into a 2d matrix
|
||||||
extern int readStateBuffer(char*, cell (*)[fieldSize]);
|
extern int readStateBuffer(char*, cell (*)[fieldSize]);
|
||||||
|
|
||||||
//adds all hotizontally-forward found moves to movesList
|
//iterates through field in all directions, stores moves into movesList
|
||||||
int findHorizontalForwardMoves(cell (*)[fieldSize], movesList *);
|
int findMoves(cell (*)[fieldSize], movesList *);
|
||||||
int findHorizontalBackwardMoves(cell (*)[fieldSize], movesList *);
|
|
||||||
int findVerticalForwardMoves(cell (*)[fieldSize], movesList *);
|
|
||||||
int findVerticalBackwardMoves(cell (*)[fieldSize], movesList *);
|
|
||||||
int findDiagonalTopLeftMoves(cell (*)[fieldSize], movesList *);
|
|
||||||
int findDiagonalBottomRightMoves(cell (*)[fieldSize], movesList *);
|
|
||||||
int findDiagonalBottomLeftMoves(cell (*)[fieldSize], movesList *);
|
|
||||||
int findDiagonalTopRightMoves(cell (*)[fieldSize], movesList *);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -65,20 +65,7 @@ int main(void)
|
||||||
readStateBuffer(state_buffer, field); //stateBuffer ist Pointer auf char, field ist Pointer auf struct cell[]
|
readStateBuffer(state_buffer, field); //stateBuffer ist Pointer auf char, field ist Pointer auf struct cell[]
|
||||||
movesList *moves = new movesList();
|
movesList *moves = new movesList();
|
||||||
|
|
||||||
findHorizontalForwardMoves(field, moves);
|
findMoves(field, moves);
|
||||||
findHorizontalBackwardMoves(field, moves);
|
|
||||||
findVerticalForwardMoves(field, moves);
|
|
||||||
findVerticalBackwardMoves(field, moves);
|
|
||||||
findDiagonalBottomRightMoves(field, moves);
|
|
||||||
findDiagonalTopLeftMoves(field, moves);
|
|
||||||
#ifdef debugprint
|
|
||||||
printf("BottomLeft\n");
|
|
||||||
#endif
|
|
||||||
findDiagonalBottomLeftMoves(field, moves);
|
|
||||||
#ifdef debugprint
|
|
||||||
printf("TopRight\n");
|
|
||||||
#endif
|
|
||||||
findDiagonalTopRightMoves(field, moves);
|
|
||||||
|
|
||||||
#ifdef debugprint
|
#ifdef debugprint
|
||||||
printf("\nZüge:\n");
|
printf("\nZüge:\n");
|
||||||
|
|
Loading…
Reference in a new issue