randomEnemy funcionando
[xYpjg3TdSw.git] / migrando / RandomEnemy.cpp
blobd9d0222e98d0c5c8475d0a684dd36798ea749ce5
1 #include "RandomEnemy.h"
2 #include "Board.h"
4 #include <cstdio>
6 void RandomEnemy::move(Board *board, int& fromX, int& fromY, int& toX, int& toY)
8 _board = board;
10 Board::MoveList moveList;
11 rep(i, 8)
12 rep(j, 8)
13 _board->moves(_player, i, j, moveList);
15 int choice = rand() % moveList.size();
18 printf("choice: %i\n", choice);
19 reps(i, moveList) {
20 printf("%i: (%i, %i) -> (%i, %i)\n", i, INDEX_X(moveList[i].first), INDEX_Y(moveList[i].first)
21 , INDEX_X(moveList[i].second), INDEX_Y(moveList[i].second));
22 fflush(stdout);
23 } //*/
25 fromX = INDEX_X(moveList[choice].first);
26 fromY = INDEX_Y(moveList[choice].first);
27 toX = INDEX_X(moveList[choice].second);
28 toY = INDEX_Y(moveList[choice].second);