Program: 19945
Project: 19945
Buggy source:
/** 
 * Alustaa luokan muuttujat, lukee pelitilan tarvitsemat tiedot ja k�ynnist�� pelin.
 * @param GameActivity   Pelitilan aloittava aktiviteetti
 * @param DisplayMetrics N�yt�n tiedot
 * @param Context		 Ohjelman konteksti
 * @param WeaponManager  Osoitin WeaponManageriin
 */
public GameMode(GameActivity _gameActivity,DisplayMetrics _dm,Context _context,Hud _hud,WeaponManager _weaponManager){
  gameActivity=_gameActivity;
  hud=_hud;
  weaponManager=_weaponManager;
  halfOfScreenWidth=_dm.widthPixels / 2;
  halfOfScreenHeight=_dm.heightPixels / 2;
  mapWidth=1200;
  mapHeight=800;
  overBoundWidth=mapWidth + 700;
  overBoundHeight=mapHeight + 700;
  enemies=new ArrayList<Enemy>();
  enemyStats=new int[5][5];
  asteroids=new Obstacle[3];
  planets=new Obstacle[2];
  collectables=new Collectable[3];
  waves=new int[AMOUNT_OF_WAVES][AMOUNT_OF_ENEMIES_PER_WAVE];
  spawnPoints=new int[9][3][2];
  XmlReader reader=new XmlReader(_context);
  int[] enemyStatsTemp=reader.readEnemyRanks();
  int rank=0;
  for (int i=0; i < enemyStatsTemp.length; ++i) {
    rank=(int)(i / 5);
    enemyStats[rank][i - rank * 5]=enemyStatsTemp[i];
  }
  for (int j=0; j < AMOUNT_OF_WAVES; ++j) {
    for (int i=0; i < AMOUNT_OF_ENEMIES_PER_WAVE; ++i) {
      waves[j][i]=-1;
    }
  }
  player=new Player(40,15,this,hud);
  player.x=0;
  player.y=0;
  mothership=new Mothership(0);
  mothership.direction=160;
  mothership.x=100 * Options.scaleX;
  mothership.y=90 * Options.scaleY;
  turret1=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret1.x=135 * Options.scaleX;
  turret1.y=8 * Options.scaleY;
  turret1.state=Wrapper.FULL_ACTIVITY;
  turret2=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret2.x=280 * Options.scaleX;
  turret2.y=-45 * Options.scaleY;
  turret2.state=Wrapper.FULL_ACTIVITY;
  turret3=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret3.x=332 * Options.scaleX;
  turret3.y=84 * Options.scaleY;
  turret3.state=Wrapper.FULL_ACTIVITY;
  reader.readGameMode(this,_weaponManager);
  generateMap();
  startWave();
  wrapper=Wrapper.getInstance();
}

Fixed version (ground truth):
/** 
 * Alustaa luokan muuttujat, lukee pelitilan tarvitsemat tiedot ja k�ynnist�� pelin.
 * @param GameActivity   Pelitilan aloittava aktiviteetti
 * @param DisplayMetrics N�yt�n tiedot
 * @param Context		 Ohjelman konteksti
 * @param WeaponManager  Osoitin WeaponManageriin
 */
public GameMode(GameActivity _gameActivity,DisplayMetrics _dm,Context _context,Hud _hud,WeaponManager _weaponManager){
  gameActivity=_gameActivity;
  hud=_hud;
  weaponManager=_weaponManager;
  halfOfScreenWidth=_dm.widthPixels / 2;
  halfOfScreenHeight=_dm.heightPixels / 2;
  wrapper=Wrapper.getInstance();
  mapWidth=1200;
  mapHeight=800;
  overBoundWidth=mapWidth + 700;
  overBoundHeight=mapHeight + 700;
  enemies=new ArrayList<Enemy>();
  enemyStats=new int[5][5];
  asteroids=new Obstacle[3];
  planets=new Obstacle[2];
  collectables=new Collectable[3];
  waves=new int[AMOUNT_OF_WAVES][AMOUNT_OF_ENEMIES_PER_WAVE];
  spawnPoints=new int[9][3][2];
  XmlReader reader=new XmlReader(_context);
  int[] enemyStatsTemp=reader.readEnemyRanks();
  int rank=0;
  for (int i=0; i < enemyStatsTemp.length; ++i) {
    rank=(int)(i / 5);
    enemyStats[rank][i - rank * 5]=enemyStatsTemp[i];
  }
  for (int j=0; j < AMOUNT_OF_WAVES; ++j) {
    for (int i=0; i < AMOUNT_OF_ENEMIES_PER_WAVE; ++i) {
      waves[j][i]=-1;
    }
  }
  player=new Player(40,15,this,hud);
  player.x=0;
  player.y=0;
  mothership=new Mothership(0);
  mothership.direction=160;
  mothership.x=100 * Options.scaleX;
  mothership.y=90 * Options.scaleY;
  turret1=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret1.x=135 * Options.scaleX;
  turret1.y=8 * Options.scaleY;
  turret1.state=Wrapper.FULL_ACTIVITY;
  turret2=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret2.x=280 * Options.scaleX;
  turret2.y=-45 * Options.scaleY;
  turret2.state=Wrapper.FULL_ACTIVITY;
  turret3=new Ally(1000,0,0,0,AbstractAi.TURRET_AI,Ally.ALLY_TURRET,_weaponManager);
  turret3.x=332 * Options.scaleX;
  turret3.y=84 * Options.scaleY;
  turret3.state=Wrapper.FULL_ACTIVITY;
  reader.readGameMode(this,_weaponManager);
  generateMap();
  startWave();
}