void NewPosition(MazewarInstance::Ptr m) //void NewPosition(MazewarInstance *m) { Loc newX(0); Loc newY(0); Direction dir(0); /* start on occupied square */ while (M->maze_[newX.value()][newY.value()]) { /* MAZE[XY]MAX is a power of 2 */ newX = Loc(random() & (MAZEXMAX - 1)); newY = Loc(random() & (MAZEYMAX - 1)); /* In real game, also check that square is unoccupied by another rat */ } /* prevent a blank wall at first glimpse */ if (!m->maze_[(newX.value())+1][(newY.value())]) dir = Direction(NORTH); if (!m->maze_[(newX.value())-1][(newY.value())]) dir = Direction(SOUTH); if (!m->maze_[(newX.value())][(newY.value())+1]) dir = Direction(EAST); if (!m->maze_[(newX.value())][(newY.value())-1]) dir = Direction(WEST); m->xlocIs(newX); m->ylocIs(newY); m->dirIs(dir); }
void __leftTurn(void) { M->dirIs(_leftTurn[MY_DIR]); updateView = TRUE; }
void __rightTurn(void) { M->dirIs(_rightTurn[MY_DIR]); updateView = TRUE; }
void __aboutFace(void) { M->dirIs(_aboutFace[MY_DIR]); updateView = TRUE; }