@@ -19,29 +19,63 @@ namespace simple_ai {
1919AI *ai;
2020
2121
22- void move (int bananaId, int dir)
22+ const int CELL_EMPTY = ECell::Empty;
23+ const int CELL_FOOD = ECell::Food;
24+ const int CELL_SUPER_FOOD = ECell::SuperFood;
25+ const int CELL_WALL = ECell::Wall;
26+
27+ const int DIR_UP = EDirection::Up;
28+ const int DIR_RIGHT = EDirection::Right;
29+ const int DIR_DOWN = EDirection::Down;
30+ const int DIR_LEFT = EDirection::Left;
31+
32+
33+ void changePacmanDirection (int dir)
2334{
24- ai->sendCommand (&move);
35+ ChangePacmanDirection changeDir;
36+ changeDir.direction ((ECommandDirection) dir);
37+ ai->sendCommand (&changeDir);
2538}
2639
40+ void changeGhostDirection (int id, int dir)
41+ {
42+ ChangeGhostDirection changeDir;
43+ changeDir.id (id);
44+ changeDir.direction ((ECommandDirection) dir);
45+ ai->sendCommand (&changeDir);
46+ }
47+
48+
2749void initialize (
28- int width, int height, int myScore, int otherScore, int ** board,
29- Banana myBananas[], int myBananasCount, Banana otherBananas [], int otherBananasCount ,
30- PowerUp powerups[], int powerupsCount, int enter_score ,
50+ int width, int height, int myScore, int otherScore, std::vector<std::vector<ECell>>& board,
51+ Pacman& Pacman, Ghost ghosts [], int ghostsCount ,
52+ Constants& constants ,
3153 string mySide, string otherSide, int currentCycle, float cycleDuration)
3254{
3355}
3456
3557
3658void decide (
37- int width, int height, int myScore, int otherScore, int ** board,
38- Banana myBananas[], int myBananasCount, Banana otherBananas [], int otherBananasCount ,
39- PowerUp powerups[], int powerupsCount, int enter_score ,
59+ int width, int height, int myScore, int otherScore, std::vector<std::vector<ECell>>& board,
60+ Pacman& Pacman, Ghost ghosts [], int ghostsCount ,
61+ Constants& constants ,
4062 string mySide, string otherSide, int currentCycle, float cycleDuration)
4163{
42-
64+ // Write your own AI code here
65+ if (mySide == " Pacman" )
66+ {
67+ changePacmanDirection (DIR_UP);
68+ }
69+ else if (mySide == " Ghost" )
70+ {
71+ for (int i = 0 ; i < ghostsCount; i++)
72+ {
73+ Ghost ghost = ghosts[i];
74+ changeGhostDirection (ghost.id (), DIR_UP);
75+ }
76+ }
4377}
4478
4579}
4680
47- #endif // SIMPLE_AI_H
81+ #endif // SIMPLE_AI_H
0 commit comments