public List <IA_Action> ComputeIAActions(HashSet <Tile> moveRangeTiles) { //Debug.Log ("moveRangeTiles.count = " + moveRangeTiles.Count); List <IA_Action> IAActionList = new List <IA_Action> (); foreach (Tile currentTile in moveRangeTiles) { IA_Action currentIA_Action = new IA_Action(currentTile, m_SpaceObjectSelected); foreach (Weapon currentWeapon in m_SpaceObjectSelected.GetWeaponController().GetEquipments()) { //Debug.Log("current tile = " + currentTile.gameObject.name); HashSet <Tile> attackRangeTiles = currentWeapon.ComputeAttackRange(currentTile); /*Debug.Log ("attackRangeTiles.count = " + attackRangeTiles.Count); * if(attackRangeTiles.Contains(GameObject.Find("Tile(2;6)").GetComponent<Tile>())) * Debug.Log ("OK");*/ List <SpaceObject> targets = currentWeapon.ComputeTargetInRange(attackRangeTiles); //Debug.Log ("targets.count = " + targets.Count); WeaponAction currentWeaponAction = ComputeWeaponAction(targets, currentWeapon); //Debug.Log("currentWeaponAction target = " + currentWeaponAction.m_Target.gameObject.name + " / current score = " + currentWeaponAction.m_Score); currentIA_Action.AddWeaponAction(currentWeaponAction); } //Debug.Log("intersection = " + currentIA_Action.m_WeaponIntersection); if (currentIA_Action.m_WeaponActionNumber > 0) { //Debug.Log("currentWeaponAction target = " + currentIA_Action.m_WeaponActions.m_Target.gameObject.name + " / current score = " + currentWeaponAction.m_Score); currentIA_Action.ComputeBestCombination(); IAActionList.Add(currentIA_Action); } } //Debug.Log("IAActionList.count = " + IAActionList.Count); return(IAActionList); }
public IA_Action(IA_Action actionToCopy) { m_WeaponActions = new List <WeaponAction>(); m_Combination = new int[actionToCopy.m_CombinationComplexity]; m_Tile = actionToCopy.m_Tile; m_SpaceObjectSelected = actionToCopy.m_SpaceObjectSelected; m_WeaponActionNumber = actionToCopy.m_WeaponActionNumber; m_WeaponActions = actionToCopy.m_WeaponActions; m_Combination = actionToCopy.m_Combination; m_CombinationComplexity = actionToCopy.m_CombinationComplexity; m_CombinationScore = actionToCopy.m_CombinationScore; }
public IA_Action RecoverBestIAAction(List <IA_Action> IAActionList) { //Debug.Log ("IAActionList.count = " + IAActionList.Count); IA_Action bestIA_Action = new IA_Action(); foreach (IA_Action currentIA_Action in IAActionList) { //Debug.Log("currentIA_Action target = " + currentIA_Action.m_SpaceObject.gameObject.name +" / score = " + currentIA_Action.m_CombinationScore); if (currentIA_Action.m_CombinationScore > bestIA_Action.m_CombinationScore || (currentIA_Action.m_CombinationScore == bestIA_Action.m_CombinationScore && currentIA_Action.m_CombinationComplexity > bestIA_Action.m_CombinationComplexity)) { //Debug.Log("new best action found"); bestIA_Action = new IA_Action(currentIA_Action); } } return(bestIA_Action); }