Program: 40153
Project: 40153
Buggy source:
public void gameLoop(){
  GlobalGameState.increasePastRounds();
  if (!checkIfPlayerWon().isEmpty()) {
    gameOver();
    return;
  }
  for (  PlayerHandler playerHandler : playerController.getPlayerHandlerList()) {
    updateRoundForPlayer(playerHandler);
    playerController.updatePlayerState();
  }
  Map<PlayerHandler,PlayerChoice> playerStatus=playerController.getPlayerStatus();
  for (  PlayerHandler playerHandler : playerStatus.keySet()) {
    PlayerChoice playerChoice=playerStatus.get(playerHandler);
    validateEvents(playerHandler,playerChoice);
  }
  playerStatus.clear();
  for (  PlayerHandler playerHandler : playerController.getPlayerHandlerList()) {
    List<RoundEvent> roundEvents=playerHandler.getRoundEvents();
    int collectedPoints=0;
    for (    RoundEvent roundEvent : roundEvents) {
switch (roundEvent) {
case DIED:
        playerHandler.getSnake().removeHead();
      break;
case MOVED:
    playerHandler.moveToNextPosition();
  break;
case CONFUSED:
collectedPoints++;
break;
case COLLISION_WITH_LEVEL:
collectedPoints--;
break;
case BIT_HIMSELF:
collectedPoints--;
break;
case BIT_AGENT:
collectedPoints++;
break;
case BIT_BY_PLAYER:
collectedPoints--;
break;
case CONSUMED_POINT:
collectedPoints++;
break;
}
}
if (collectedPoints <= 0) {
playerHandler.penalty();
if (collectedPoints <= -1) {
playerHandler.penalty();
}
}
}
playerController.removeDeadPlayer();
levelBoard.fillUpWithPoints(Config.MAX_POINTS_IN_LEVEL);
for (PlayerHandler playerHandler : playerController.getPlayerHandlerList()) {
playerHandler.endRound();
}
GlobalGameState.increasePastRounds();
updateGameBaordData();
}

Fixed version (ground truth):
public void gameLoop(){
  GlobalGameState.increasePastRounds();
  if (!checkIfPlayerWon().isEmpty()) {
    gameOver();
    return;
  }
  for (  PlayerHandler playerHandler : playerController.getPlayerHandlerList()) {
    updateRoundForPlayer(playerHandler);
    playerController.updatePlayerState();
  }
  Map<PlayerHandler,PlayerChoice> playerStatus=playerController.getPlayerStatus();
  for (  PlayerHandler playerHandler : playerStatus.keySet()) {
    PlayerChoice playerChoice=playerStatus.get(playerHandler);
    validateEvents(playerHandler,playerChoice);
  }
  playerStatus.clear();
  for (  PlayerHandler playerHandler : playerController.getPlayerHandlerList()) {
    List<RoundEvent> roundEvents=playerHandler.getRoundEvents();
    int collectedPoints=0;
    for (    RoundEvent roundEvent : roundEvents) {
switch (roundEvent) {
case DIED:
        playerHandler.kill();
      break;
case MOVED:
    playerHandler.moveToNextPosition();
  break;
case CONFUSED:
collectedPoints++;
break;
case COLLISION_WITH_LEVEL:
collectedPoints--;
break;
case BIT_HIMSELF:
collectedPoints--;
break;
case BIT_AGENT:
collectedPoints++;
break;
case BIT_BY_PLAYER:
collectedPoints--;
break;
case CONSUMED_POINT:
collectedPoints++;
break;
}
}
if (collectedPoints <= 0) {
playerHandler.penalty();
if (collectedPoints <= -1) {
playerHandler.penalty();
}
}
}
levelBoard.fillUpWithPoints(Config.MAX_POINTS_IN_LEVEL);
for (PlayerHandler playerHandler : playerController.getPlayerHandlerList()) {
playerHandler.endRound();
}
GlobalGameState.increasePastRounds();
updateGameBaordData();
playerController.removeDeadPlayer();
}