Skip to content
Browse files

Adjusted the unit tests. All 38 succeed.

Adjusted the game_init to work according to the input pattern.
Adjusted the shot ammo decrease in action_shoot.
Renamed the test input file.
  • Loading branch information...
1 parent 87b994c commit 5f6cd18a269d2f60093891258799c87bd26b3b53 @mpolitzer committed May 6, 2012
Showing with 13 additions and 12 deletions.
  1. +5 −4 bind.c
  2. +4 −4 game.c
  3. 0 in.txt → teste.in
  4. +4 −4 teste.pl
View
9 bind.c
@@ -175,8 +175,8 @@ static foreign_t consult_position(term_t X, term_t Y)
if (!PL_is_variable(X) || !PL_is_variable(Y))
return FALSE;
- if (!PL_unify_integer(X, player.x)) return FALSE;
- if (!PL_unify_integer(Y, player.y)) return FALSE;
+ if (!PL_unify_integer(X, player.x + 1)) return FALSE;
+ if (!PL_unify_integer(Y, player.y + 1)) return FALSE;
return TRUE;
}
@@ -196,8 +196,8 @@ static foreign_t consult_direction(term_t Dir)
static foreign_t consult_goal(term_t X, term_t Y)
{
- if (!PL_unify_integer(X, GI.goal_x)) return FALSE;
- if (!PL_unify_integer(Y, GI.goal_y)) return FALSE;
+ if (!PL_unify_integer(X, GI.goal_x + 1)) return FALSE;
+ if (!PL_unify_integer(Y, GI.goal_y + 1)) return FALSE;
return TRUE;
}
@@ -277,6 +277,7 @@ static foreign_t action_shoot(void)
if(player.ammo == 0)
return FALSE;
+ player.ammo--;
game_update_points(ACTION_SHOOT);
while(game_check_border(x, y))
View
8 game.c
@@ -134,10 +134,10 @@ void game_update_points(int action)
void game_init(void)
{
- GI.goal_x = 18;
- GI.goal_y = 17;
- player.x = 3;
- player.y = 3;
+ GI.goal_x = 17;
+ GI.goal_y = 16;
+ player.x = 2;
+ player.y = 2;
player.ammo = 30;
player.antidotes = 1;
player.direction = DIR_E;
View
0 in.txt → teste.in
File renamed without changes.
View
8 teste.pl
@@ -12,8 +12,8 @@
test(sense_zombies_3) :- sense_zombies(N), assertion(N==3).
test(sense_station_0,fail) :- sense_station.
test(sense_hospital_1) :- sense_hospital.
-test(sense_antidote_0) :- sense_antidote(N), assertion(N==0).
-test(sense_ammo_0) :- sense_ammo(N), assertion(N==0).
+test(sense_antidote_0,fail) :- sense_antidote(N), assertion(N==0).
+test(sense_ammo_0,fail) :- sense_ammo(N), assertion(N==0).
test(sense_hit_0,fail) :- sense_hit.
test(action_turn_north) :- action_turn_right, action_turn_right, action_turn_right.
@@ -22,7 +22,7 @@
test(sense_zombies_2) :- sense_zombies(N), assertion(N==2).
test(action_move_forward) :- action_move_forward.
test(consult_bites_2) :- consult_bites(N), assertion(N==2).
-test(consult_ammo_29) :- consult_ammo(N), asssertion(N==29).
+test(consult_ammo_29) :- consult_ammo(N), assertion(N==29).
test(action_use_antidote) :- action_use_antidote.
test(consult_antidotes_0) :- consult_antidotes(N), assertion(N==0).
test(consult_bites_0) :- consult_bites(N), assertion(N==0).
@@ -42,7 +42,7 @@
test(action_grab) :- action_grab.
test(consult_ammo_31) :- consult_ammo(N), assertion(N==31).
-test(action_shoot) :- action_shoot.
+test(action_shoot,fail) :- action_shoot.
test(sense_hit_0,fail) :- sense_hit.
:- end_tests(test).

0 comments on commit 5f6cd18

Please sign in to comment.
Something went wrong with that request. Please try again.