choose random move
send move
This commit is contained in:
parent
48400b8ce2
commit
7dede72f8f
|
@ -6,6 +6,8 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
//for seeding rng with cummrent time
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include <mcp.h>
|
#include <mcp.h>
|
||||||
|
|
||||||
|
@ -24,6 +26,7 @@ send_move(int row, int col)
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int done = 0;
|
int done = 0;
|
||||||
|
srandom(time(NULL));
|
||||||
|
|
||||||
while (!done) {
|
while (!done) {
|
||||||
int turn_row = 0;
|
int turn_row = 0;
|
||||||
|
@ -77,14 +80,32 @@ int main(void)
|
||||||
#endif
|
#endif
|
||||||
findDiagonalTopRightMoves(field, moves);
|
findDiagonalTopRightMoves(field, moves);
|
||||||
|
|
||||||
|
#ifdef debugprint
|
||||||
printf("\nZüge:\n");
|
printf("\nZüge:\n");
|
||||||
for (unsigned int i=0; i<moves->movesNumber; ++i)
|
for (unsigned int i=0; i<moves->movesNumber; ++i)
|
||||||
{
|
{
|
||||||
printf("%d,%d\n",moves->list[i].turnRow,moves->list[i].turnCol);
|
printf("%d,%d\n",moves->list[i].turnRow,moves->list[i].turnCol);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(!moves->movesNumber)
|
||||||
|
{
|
||||||
|
turn_row=0;
|
||||||
|
turn_col=0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int r = rand() % moves->movesNumber;
|
||||||
|
turn_row=moves->list[r].turnRow;
|
||||||
|
turn_col=moves->list[r].turnCol;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef debugprint
|
||||||
|
printf("======================\nGewählter Zug: %d,%d\n======================\n", turn_row, turn_col);
|
||||||
|
#endif
|
||||||
|
|
||||||
// 3. Return result
|
// 3. Return result
|
||||||
//send_move(turn_row, turn_col);
|
send_move(turn_row, turn_col);
|
||||||
//for(int i=0; i<fieldSize; ++i)
|
//for(int i=0; i<fieldSize; ++i)
|
||||||
// delete [] field[i];
|
// delete [] field[i];
|
||||||
delete [] field;
|
delete [] field;
|
||||||
|
|
Loading…
Reference in a new issue