// Add each possible state in the currentNode.sons list. public void createSons() { // Tested SimulatedPlanetWars simpw = this.getSim(); for (Planet myPlanet : simpw.MyPlanets()) { // avoid planets with only one ship if (myPlanet.NumShips() <= 1) continue; // We create a son for each of the possible situations for (Planet notMyPlanet : simpw.NotMyPlanets()) { // Create simulation environment for this son SimulatedPlanetWars simpw2 = new SimulatedPlanetWars(simpw); int value = Helper.Dcalculation(myPlanet, notMyPlanet); simpw2.IssueOrder(myPlanet, notMyPlanet); simpw2.simulateGrowth(); simpw2.simulateFirstBotAttack(); simpw2.simulateGrowth(); MyNode son; if (this.isRoot()) { son = new MyNode(this, simpw2, value, myPlanet, notMyPlanet); } else { son = new MyNode( this, simpw2, value, this.getSource(), this.getDest()); // We only need to know from where to where we want to send our // ships to get the best turn } this.addSon(son); } } }