Skip to content

Commit

Permalink
Fixed a bug with the bot test hardness replacing the files of round 0…
Browse files Browse the repository at this point in the history
… with those of round 1
  • Loading branch information
unknown authored and unknown committed Jun 12, 2016
1 parent 2adeb28 commit 28359ed
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions Game Engine/Bomberman/TestHarness/TestHarnesses/Bot/BotHarness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public override void StartGame(GameMap gameState)

public override void NewRoundStarted(GameMap gameState)
{
_currentRound = gameState.CurrentRound;
WriteRoundFiles(gameState);
if (!PlayerEntity.Killed)
{
RunBotAndGetNextMove();
Expand All @@ -83,9 +85,7 @@ public override void RoundComplete(GameMap gameMap, int round)
{
base.RoundComplete(gameMap, round);

_currentRound = round;
ClearPreviousRoundFiles();
WriteRoundFiles(gameMap);
ClearRoundFiles();
}

public override void GameEnded(GameMap gameMap)
Expand Down Expand Up @@ -157,14 +157,14 @@ private void RunBotAndGetNextMove()
PublishCommand(command);
}

private void ClearPreviousRoundFiles()
private void ClearRoundFiles()
{
var dir = Path.Combine(PreviousWorkingDirectory, Settings.Default.StateFileName);
var dir = Path.Combine(CurrentWorkingDirectory, Settings.Default.StateFileName);

if(File.Exists(dir))
File.Delete(dir);

dir = Path.Combine(PreviousWorkingDirectory, Settings.Default.MapFileName);
dir = Path.Combine(CurrentWorkingDirectory, Settings.Default.MapFileName);

if (File.Exists(dir))
File.Delete(dir);
Expand Down Expand Up @@ -234,14 +234,5 @@ public string CurrentWorkingDirectory
return Path.Combine(roundPath, PlayerEntity.Key.ToString(CultureInfo.InvariantCulture));
}
}

public string PreviousWorkingDirectory
{
get
{
var roundPath = Path.Combine(WorkDir, (_currentRound - 1).ToString(CultureInfo.InvariantCulture));
return Path.Combine(roundPath, PlayerEntity.Key.ToString(CultureInfo.InvariantCulture));
}
}
}
}

0 comments on commit 28359ed

Please sign in to comment.