Skip to content
Permalink
Browse files

The followig bugs are fixed

- In the game manager, when two samurai plug the same hole,
  the list of holes were not properly updated.
- In the web page, detection of invalid actions was not appropriate
  as the variables for positions of agents were not correct.
  • Loading branch information
Takashi
Takashi committed Jan 1, 2020
1 parent e5ef030 commit 1c2468d5b9e64d1cfed2928aea8d6105ab69a331
Showing with 23 additions and 3 deletions.
  1. +4 −2 manager/field.cc
  2. +6 −0 players/Makefile
  3. BIN players/diggerPlayer
  4. +12 −0 players/diggerSamurai.cc
  5. +1 −1 webpage/dighere.js
@@ -181,8 +181,10 @@ Field::Field(const Field &prev, const int plans[],
} else {
// Plug a hole
auto h = find(holes.begin(), holes.end(), target);
if (holes.size() != 1) *h = *holes.rbegin();
holes.pop_back();
if (h != holes.end()) {
if (holes.size() != 1) *h = *holes.rbegin();
holes.pop_back();
}
}
NODIGPLUG:;
}
@@ -6,9 +6,12 @@ SIMPLEOBJECTS= $(BASICOBJECTS) greedySamurai.o snoopyDog.o
RANDOMOBJECTS= $(BASICOBJECTS) randomSamurai.o randomDog.o
TIMEOUTOBJECTS= $(BASICOBJECTS) timeoutSamurai.o randomDog.o
EXECUTABLES= simplePlayer randomPlayer timeoutPlayer
DIGGEROBJECTS= $(BASICOBJECTS) diggerSamurai.o randomDog.o

all: $(EXECUTABLES)

debugging: all diggerPlayer

simplePlayer: $(SIMPLEOBJECTS)
${CXX} -o $@ $^ $(LDFLAGS)

@@ -18,6 +21,9 @@ randomPlayer: $(RANDOMOBJECTS)
timeoutPlayer: $(TIMEOUTOBJECTS)
${CXX} -o $@ $^ $(LDFLAGS)

diggerPlayer: $(DIGGEROBJECTS)
${CXX} -o $@ $^ $(LDFLAGS)

-include ${OBJECTS:.o=.d}

.cc.o:
BIN +491 KB players/diggerPlayer
Binary file not shown.
@@ -0,0 +1,12 @@
#include "players.hh"
#include <algorithm>

int planSamurai(GameInfo &info) {
int id = info.id;
Cell pos = info.positions[id];
if (pos.x+1 < info.size) {
return 16+6;
} else {
return 16;
}
}
@@ -409,7 +409,7 @@ class GameState {
return "Dig by a dog";
if (plan >= 0) {
for (let b = 0; b != 4; b++) {
if (b.at == targetPos) {
if (prevGameState.agents[b].at == targetPos) {
return (plan < 8 ? "Moving to" : "Digging") +
" (" + targetPos.x + "," + targetPos.y +
") occupied by agent " + b;

0 comments on commit 1c2468d

Please sign in to comment.
You can’t perform that action at this time.