Skip to content

Commit b2c7f85

Browse files
committed
Removing my stuff from DM1.cpp - just in case.
1 parent f2206bd commit b2c7f85

File tree

1 file changed

+19
-74
lines changed

1 file changed

+19
-74
lines changed

DecisionMaker1.cpp

+19-74
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ Move DECISION_MAKER::get_player_move(Info my_info,
4444
// return Move (my_move)
4545
//
4646
// where
47-
// |--------------+------+-------+----+------+----------+------------+------------+-------------|
48-
// | my_move | LEFT | RIGHT | UP | DOWN | SHOOT_UP | SHOOT_DOWN | SHOOT_LEFT | SHOOT_RIGHT |
49-
// | Actual value | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
50-
// |--------------+------+-------+----+------+----------+------------+------------+-------------|
47+
// |--------------+---------+----------+-------+---------+----------+------------+------------+-------------|
48+
// | my_move | GO_LEFT | GO_RIGHT | GO_UP | GO_DOWN | SHOOT_UP | SHOOT_DOWN | SHOOT_LEFT | SHOOT_RIGHT |
49+
// | Actual value | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
50+
// |--------------+---------+----------+-------+---------+----------+------------+------------+-------------|
5151

5252
// Make sure your difficulty table is filled each time if you are using
5353
// it.
@@ -58,63 +58,8 @@ Move DECISION_MAKER::get_player_move(Info my_info,
5858
/*************************************/
5959
/* PUT YOUR CODE IN THIS FUNCTION */
6060
/*************************************/
61-
Position posn = my_info.curr_posn;
62-
int d, i, j, safe_dirn, opposite_dirn;
63-
// bool is_coming_at_me;
64-
// for (d = 0; d <= 3; ++d){
65-
// d = RIGHT;
66-
bullet_info curr_bullet;
67-
for (d = 0; d <= 3; d++){
68-
posn = my_info.curr_posn;
69-
for (i = 1; i <= BULLET_SPEED; i++){
70-
posn.go_in_direction (Direction (d));
71-
switch (d){
72-
case UP:
73-
safe_dirn = RIGHT;
74-
opposite_dirn = DOWN;
75-
break;
76-
case DOWN:
77-
safe_dirn = RIGHT;
78-
opposite_dirn = UP;
79-
break;
80-
case RIGHT:
81-
safe_dirn = UP;
82-
opposite_dirn = LEFT;
83-
break;
84-
case LEFT:
85-
safe_dirn = UP;
86-
opposite_dirn = RIGHT;
87-
break;
88-
}
89-
// Enemy Tank's bullets
90-
for (j = 0; j < my_info.enemy_bullets.size (); j++){
91-
curr_bullet = my_info.enemy_bullets[j];
92-
if (curr_bullet.posn == posn && curr_bullet.dirn == Direction (opposite_dirn)){
93-
// Move away!
94-
// cout << "Try to dodge" << endl;
95-
return Move (safe_dirn);
96-
}
97-
}
98-
// MGs' bullets
99-
for (j = 0; j < my_info.machine_gun_bullets.size (); j++){
100-
curr_bullet = my_info.machine_gun_bullets[j];
101-
if (curr_bullet.posn == posn && curr_bullet.dirn == Direction (opposite_dirn)){
102-
// Move away!
103-
// cout << "Try to dodge" << endl;
104-
return Move (safe_dirn);
105-
}
106-
}
107-
}
108-
}
109-
110-
// return Move (SHOOT_UP);
111-
// if (my_info.opp_tank.shortest_distance < 3 and !my_info.can_shoot_at_enemy_tank){
112-
// switch (my_info.opp_tank.initial_move.dirn)
113-
// }
114-
115-
116-
117-
return get_best_move_for(calculate_best_action_plan(AGGRESSIVE));
61+
// return Move (SHOOT_RIGHT);
62+
return get_best_move_for(calculate_best_action_plan(GREEDY));
11863

11964
}
12065

@@ -193,7 +138,7 @@ void DECISION_MAKER::DMinitializer(ID my_id, ID enemy_id)
193138
// | GO_TO_NEAREST_GOLD_WEIGHT | ATTACK_ENEMY_FALCON_WEIGHT | ATTACK_ENEMY_TANK_WEIGHT | DEFEND_YOUR_FALCON_WEIGHT |
194139
// |---------------------------+----------------------------+--------------------------+---------------------------|
195140

196-
set_weightage_table(AGGRESSIVE, 0, 100, 10, 0);
141+
set_weightage_table(AGGRESSIVE, 0, 50, 50, 0);
197142
set_weightage_table(DEFENSIVE, 20, 1, 5, 50);
198143
set_weightage_table(GREEDY, 100, 15, 10, 0);
199144
set_weightage_table(CUSTOMIZED, 0, 0, 100, 0);
@@ -314,19 +259,19 @@ int DECISION_MAKER::calculate_best_action_plan(int strategy)
314259
switch(strategy)
315260
{
316261
case AGGRESSIVE:
317-
// if(my_info.opp_tank.shortest_distance + 3 < my_info.opp_falcon.shortest_distance)
318-
// return ATTACK_ENEMY_TANK;
319-
// else
320-
// {
321-
// return ATTACK_ENEMY_FALCON;
322-
// }
323-
// break;
262+
if(my_info.opp_tank.shortest_distance + 3 < my_info.opp_falcon.shortest_distance)
263+
return ATTACK_ENEMY_TANK;
264+
else
265+
{
266+
return ATTACK_ENEMY_FALCON;
267+
}
268+
break;
324269
case DEFENSIVE:
325-
// if(opp_info.opp_tank.shortest_distance < opp_info.opp_falcon.shortest_distance)
326-
// return ATTACK_ENEMY_TANK;
327-
// else
328-
// return DEFEND_MY_FALCON;
329-
// break;
270+
if(opp_info.opp_tank.shortest_distance < opp_info.opp_falcon.shortest_distance)
271+
return ATTACK_ENEMY_TANK;
272+
else
273+
return DEFEND_MY_FALCON;
274+
break;
330275
case GREEDY:
331276
case CUSTOMIZED:
332277
float action_score[4];

0 commit comments

Comments
 (0)