Skip to content

Commit 77222a3

Browse files
committed
Merged PR 27: Merge branch Dev into Master
Related work items: #159, #206, #28, #29, #33
2 parents f1929ba + 4aac677 commit 77222a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2710
-1085
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/.idea
2+
**/.vscode
3+
build-Pacman*

CppClient/Game/Game.pro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@ DISTFILES += \
4949
HEADERS += \
5050
ks/commands.h \
5151
ks/models.h \
52-
ai.h
52+
ai.h \
53+
simple_ai.h

CppClient/Game/ai.cpp

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,67 @@
11
#include "ai.h"
22

3-
#include <ctime>
43
#include <vector>
54
#include <iostream>
65

6+
#include "simple_ai.h"
7+
78
using namespace std;
89
using namespace koala::chillin::client;
910
using namespace ks::models;
1011
using namespace ks::commands;
1112

1213

13-
AI::AI(World *world): TurnbasedAI<World*>(world)
14+
AI::AI(World *world): RealtimeAI<World*>(world)
1415
{
15-
srand(time(0));
16+
simple_ai::ai = this;
1617
}
1718

1819
AI::~AI()
1920
{
20-
if (board)
21-
{
22-
for (int i = 0; i < world->height(); i++)
23-
delete[] board[i];
24-
delete[] board;
25-
}
2621
}
2722

2823
void AI::initialize()
2924
{
3025
cout << "initialize" << endl;
26+
27+
simple_ai::initialize(
28+
world->width(),
29+
world->height(),
30+
world->ref_scores()[mySide],
31+
world->ref_scores()[otherSide],
32+
world->ref_board(),
33+
world->ref_pacman(),
34+
&world->ref_ghosts()[0],
35+
world->ref_ghosts().size(),
36+
world->ref_constants(),
37+
mySide,
38+
otherSide,
39+
currentCycle,
40+
cycleDuration
41+
);
3142
}
3243

3344
void AI::decide()
3445
{
3546
cout << "decide" << endl;
36-
}
3747

38-
int AI::getRandInt(int start, int end)
39-
{
40-
return (rand() % (end - start + 1)) + start;
48+
simple_ai::decide(
49+
world->width(),
50+
world->height(),
51+
world->ref_scores()[mySide],
52+
world->ref_scores()[otherSide],
53+
world->ref_board(),
54+
world->ref_pacman(),
55+
&world->ref_ghosts()[0],
56+
world->ref_ghosts().size(),
57+
world->ref_constants(),
58+
mySide,
59+
otherSide,
60+
currentCycle,
61+
cycleDuration
62+
);
4163
}
4264

43-
4465
void AI::sendCommand(ks::KSObject *command)
4566
{
4667
BaseAI::sendCommand(command);

CppClient/Game/ai.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@
77
#include "ks/commands.h"
88

99

10-
class AI : public koala::chillin::client::TurnbasedAI<ks::models::World*>
10+
class AI : public koala::chillin::client::RealtimeAI<ks::models::World*>
1111
{
12-
private:
13-
int **board;
14-
int getRandInt(int start, int end);
15-
1612
public:
1713
AI(ks::models::World *world);
1814
~AI();

CppClient/Game/gamecfg.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"": "creating a new decision thread each time a snapshot of game is received from server",
1616
"create_new_thread": true,
1717
"agent_name": "0",
18-
"team_nickname": "BabyKnight",
18+
"team_nickname": "Team1",
1919
"token": "team_id1-xx"
2020
}
2121
}

CppClient/Game/ks/commands.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class KSObject
2828
namespace commands
2929
{
3030

31-
enum class ECommandDirection
31+
enum ECommandDirection
3232
{
3333
Up = 0,
3434
Right = 1,

CppClient/Game/ks/commands.ks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ _def = enum <byte>
99

1010

1111
[ChangePacmanDirection]
12-
_def = class
12+
_def = class
1313
direction = ECommandDirection
1414

1515

0 commit comments

Comments
 (0)