// Path: src/org/iaie/btree/BehavioralTree.java
// public class BehavioralTree extends Task{
//     
//        
//     /**
//      *
//      * @param name
//      */
//     public BehavioralTree(String name) {
//         super(name, null);
//     }
//     
//     @Override
//     public void addChild(Task task) {
//         if (this.children.isEmpty()) this.children.add(task);
//     }
//     
//     @Override
//     public Task getChild (int i) {
//         if (i == 0) return this.children.get(0);
//         else return null;
//     }
// 
//     @Override
//     public State run() {
//         try {
//             return this.children.get(0).run();
//         }
//         catch (Exception e) {
//             return State.ERROR;
//         }
//     }
// }
// 
// Path: src/org/iaie/btree/task/composite/Selector.java
// public class Selector<GameHandler> extends Composite {
// 
//     public Selector(String name) {
//         super(name, null);
//     }
//     
//     public Selector(String name, Task ... tasks) {
//         super(name, null);
//         this.addChildren(tasks);
//     }    
// 
//     @Override
//     public State run() {        
//         
//         for (int i = 0; i < this.children.size(); i++) {        
//             if (this.children.get(i).run() == State.SUCCESS) return State.SUCCESS;
//         }
//         
//         return State.FAILURE;
//     }
// }
// 
// Path: src/org/iaie/btree/task/composite/Sequence.java
// public class Sequence extends Composite {
//     
//     public Sequence(String name) {
//         super(name, null);
//     }
//     
//     public Sequence(String name, Task ... tasks) {
//         super(name, null);
//         this.addChildren(tasks);
//     }
// 
//     @Override
//     public State run() {
//         
//         for (int i = 0; i < this.children.size(); i++) {        
//             State result = this.children.get(i).run();
//             if (result == State.FAILURE) return State.FAILURE;
//             if (result == State.ERROR) return State.ERROR;
//         }
//         return State.SUCCESS;
//     }
// }
// 
// Path: src/org/iaie/btree/util/GameHandler.java
// public abstract class GameHandler {
//     protected Game connector; 
//     protected Player self;
//     
//     public GameHandler(Game bwapi, Player self) {
//         this.connector = bwapi;
//         this.self = self;
//     }
// }


import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.function.Predicate;
import org.iaie.btree.BehavioralTree;
import org.iaie.btree.task.composite.Selector;
import org.iaie.btree.task.composite.Sequence;
import org.iaie.btree.util.GameHandler;
import bwapi.BWEventListener;
import bwapi.Game;
import bwapi.Mirror;
import bwapi.Player;
import bwapi.Position;
import bwapi.Race;
import bwapi.Unit;
import bwapi.UnitType;
import bwapi.UpgradeType;
import bwta.BWTA;

		Sequence vehicleArmor = new Sequence("Research vehicle armor");
		vehicleArmor.addChild(new CheckResearch("Checks if it can be researched", gh, UpgradeType.Terran_Vehicle_Plating));
		vehicleArmor.addChild(new Research("Research", gh, UnitType.Terran_Armory, UpgradeType.Terran_Vehicle_Plating));
		//Research vehicle weapons (Armory)
		Sequence vehicleWeapons = new Sequence("Research vehicle weapons");
		vehicleWeapons.addChild(new CheckResearch("Checks if it can be researched", gh, UpgradeType.Terran_Vehicle_Weapons));
		vehicleWeapons.addChild(new Research("Research", gh, UnitType.Terran_Armory, UpgradeType.Terran_Vehicle_Weapons));
		//Research Caronte boosters (Machine shop)
		Sequence caronteBoosters = new Sequence("Research vehicle weapons");
		caronteBoosters.addChild(new CheckResearch("Checks if it can be researched", gh, UpgradeType.Charon_Boosters));
		caronteBoosters.addChild(new Research("Research", gh, UnitType.Terran_Machine_Shop, UpgradeType.Charon_Boosters));
		
		Selector<Sequence> selectorResearch = new Selector<>("Selector research", u238, caudecus, infantryArmor, 
																infantryWeapons, vehicleArmor, vehicleWeapons, caronteBoosters); 
		// --------------- END RESEARCH ---------------
		
		game.sendText("Secuencia reparar");
		// ----------- Repair sequence ---------		
		Sequence repair = new Sequence("Repair");
		repair.addChild(new FindDamageBuildings("Find damaged buildings", gh));
		repair.addChild(new FreeBuilder("Free worker", gh));
		repair.addChild(new RepairBuilding("Repair building", gh));
		// ------------- END REPAIR --------------------
		
		game.sendText("Secuencia CC");
		// ----------- CC managment -----------
		Sequence ccManage = new Sequence("CC managment");
		ccManage.addChild(new SelectCC("Select a CC", gh));
		// ----------- END CC managment
		

// Path: src/org/iaie/btree/BehavioralTree.java
// public class BehavioralTree extends Task{
//     
//        
//     /**
//      *
//      * @param name
//      */
//     public BehavioralTree(String name) {
//         super(name, null);
//     }
//     
//     @Override
//     public void addChild(Task task) {
//         if (this.children.isEmpty()) this.children.add(task);
//     }
//     
//     @Override
//     public Task getChild (int i) {
//         if (i == 0) return this.children.get(0);
//         else return null;
//     }
// 
//     @Override
//     public State run() {
//         try {
//             return this.children.get(0).run();
//         }
//         catch (Exception e) {
//             return State.ERROR;
//         }
//     }
// }
// 
// Path: src/org/iaie/btree/task/composite/Selector.java
// public class Selector<GameHandler> extends Composite {
// 
//     public Selector(String name) {
//         super(name, null);
//     }
//     
//     public Selector(String name, Task ... tasks) {
//         super(name, null);
//         this.addChildren(tasks);
//     }    
// 
//     @Override
//     public State run() {        
//         
//         for (int i = 0; i < this.children.size(); i++) {        
//             if (this.children.get(i).run() == State.SUCCESS) return State.SUCCESS;
//         }
//         
//         return State.FAILURE;
//     }
// }
// 
// Path: src/org/iaie/btree/task/composite/Sequence.java
// public class Sequence extends Composite {
//     
//     public Sequence(String name) {
//         super(name, null);
//     }
//     
//     public Sequence(String name, Task ... tasks) {
//         super(name, null);
//         this.addChildren(tasks);
//     }
// 
//     @Override
//     public State run() {
//         
//         for (int i = 0; i < this.children.size(); i++) {        
//             State result = this.children.get(i).run();
//             if (result == State.FAILURE) return State.FAILURE;
//             if (result == State.ERROR) return State.ERROR;
//         }
//         return State.SUCCESS;
//     }
// }
// 
// Path: src/org/iaie/btree/util/GameHandler.java
// public abstract class GameHandler {
//     protected Game connector; 
//     protected Player self;
//     
//     public GameHandler(Game bwapi, Player self) {
//         this.connector = bwapi;
//         this.self = self;
//     }
// }


// Path: src/bot/Goliat.java
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.function.Predicate;
import org.iaie.btree.BehavioralTree;
import org.iaie.btree.task.composite.Selector;
import org.iaie.btree.task.composite.Sequence;
import org.iaie.btree.util.GameHandler;
import bwapi.BWEventListener;
import bwapi.Game;
import bwapi.Mirror;
import bwapi.Player;
import bwapi.Position;
import bwapi.Race;
import bwapi.Unit;
import bwapi.UnitType;
import bwapi.UpgradeType;
import bwta.BWTA;

		Sequence vehicleArmor = new Sequence("Research vehicle armor");
		vehicleArmor.addChild(new CheckResearch("Checks if it can be researched", gh, UpgradeType.Terran_Vehicle_Plating));
		vehicleArmor.addChild(new Research("Research", gh, UnitType.Terran_Armory, UpgradeType.Terran_Vehicle_Plating));
		//Research vehicle weapons (Armory)
		Sequence vehicleWeapons = new Sequence("Research vehicle weapons");
		vehicleWeapons.addChild(new CheckResearch("Checks if it can be researched", gh, UpgradeType.Terran_Vehicle_Weapons));
		vehicleWeapons.addChild(new Research("Research", gh, UnitType.Terran_Armory, UpgradeType.Terran_Vehicle_Weapons));
		//Research Caronte boosters (Machine shop)
		Sequence caronteBoosters = new Sequence("Research vehicle weapons");
		caronteBoosters.addChild(new CheckResearch("Checks if it can be researched", gh, UpgradeType.Charon_Boosters));
		caronteBoosters.addChild(new Research("Research", gh, UnitType.Terran_Machine_Shop, UpgradeType.Charon_Boosters));
		
		Selector<Sequence> selectorResearch = new Selector<>("Selector research", u238, caudecus, infantryArmor, 
																infantryWeapons, vehicleArmor, vehicleWeapons, caronteBoosters); 
		// --------------- END RESEARCH ---------------
		
		game.sendText("Secuencia reparar");
		// ----------- Repair sequence ---------		
		Sequence repair = new Sequence("Repair");
		repair.addChild(new FindDamageBuildings("Find damaged buildings", gh));
		repair.addChild(new FreeBuilder("Free worker", gh));
		repair.addChild(new RepairBuilding("Repair building", gh));
		// ------------- END REPAIR --------------------
		
		game.sendText("Secuencia CC");
		// ----------- CC managment -----------
		Sequence ccManage = new Sequence("CC managment");
		ccManage.addChild(new SelectCC("Select a CC", gh));
		// ----------- END CC managment
		

		game.sendText("Creando arboles");
