public static List <PD_MacroAction> ShareKnowledge_Positive_Now( PD_Game game, PD_AI_PathFinder pathFinder, List <PD_MacroAction> allMacros ) { #if DEBUG if (game.GQ_IsInState_ApplyingMainPlayerActions() == false) { throw new System.Exception("wrong state."); } #endif var shareKnowledgeMacros_ExecutableNow = allMacros.FindAll( x => x.Is_TypeOf_ShareKnowledge_Any() && x.Is_ExecutableNow() == true ); if (shareKnowledgeMacros_ExecutableNow.Count > 0) { List <PD_MacroAction> positiveShareKnowledgeMacros = new List <PD_MacroAction>(); foreach (var macro in shareKnowledgeMacros_ExecutableNow) { List <PD_Action> walkSequence = macro.Actions_All.CustomDeepCopy(); walkSequence.RemoveAt(walkSequence.Count - 1); double walkSequenceValue = PD_AI_CardEvaluation_Utilities .Calculate_ListOfPlayerActions_Effect_On_Percent_AbilityToCureDiseases( game, walkSequence, true ); if (walkSequenceValue < 0) { continue; } PD_Action lastCommand = macro.Find_LastCommand(); double exchangeValue = PD_AI_CardEvaluation_Utilities .Calculate_PlayerAction_Effect_On_Percent_AbilityToCureDiseases( game, lastCommand, true ); if (exchangeValue > 0.0) { positiveShareKnowledgeMacros.Add(macro); } } if (positiveShareKnowledgeMacros.Count > 0) { return(positiveShareKnowledgeMacros); } } return(new List <PD_MacroAction>()); }
public static List <PD_MacroAction> TakePosition_Positive_NextRound( PD_Game game, PD_AI_PathFinder pathFinder, List <PD_MacroAction> allMacros ) { int numberOfStepsUntilEndOfNextRound = 4 + game.GQ_RemainingPlayerActions_ThisRound(); var takePosition_NextRound = allMacros.FindAll( x => x.Is_TypeOf_TakePositionFor_ShareKnowledge_Any() && x.Is_ExecutableNow() == false && x.Count_Total_Length() <= numberOfStepsUntilEndOfNextRound ); if (takePosition_NextRound.Count > 0) { List <PD_MacroAction> takePosition_Positive_NextRound = new List <PD_MacroAction>(); // find all take position macros that would have a positive outcome (ability to cure) foreach (var macro in takePosition_NextRound) { List <PD_Action> walkSequence = macro.Actions_All; double walkSequenceValue = PD_AI_CardEvaluation_Utilities .Calculate_ListOfPlayerActions_Effect_On_Percent_AbilityToCureDiseases( game, walkSequence, true ); if (walkSequenceValue < 0) { continue; } var lastCommand = macro.NonExecutable_ShareKnowledge_Action; double exchangeValue = PD_AI_CardEvaluation_Utilities .Calculate_PlayerAction_Effect_On_Percent_AbilityToCureDiseases( game, lastCommand, true ); if (exchangeValue > 0.0) { takePosition_Positive_NextRound.Add(macro); } } if (takePosition_Positive_NextRound.Count > 0) { return(takePosition_Positive_NextRound); } } return(new List <PD_MacroAction>()); }
public static List <PD_MacroAction> TakePosition_Positive_NextRound_OtherPlayerWithinFourSteps( PD_Game game, PD_AI_PathFinder pathFinder, List <PD_MacroAction> allMacros ) { int numberOfStepsUntilEndOfNextRound = 4 + game.GQ_RemainingPlayerActions_ThisRound(); var takePosition_NextRound = allMacros.FindAll( x => x.Is_TypeOf_TakePositionFor_ShareKnowledge_Any() && x.Is_ExecutableNow() == false && x.Count_Total_Length() <= numberOfStepsUntilEndOfNextRound ); if (takePosition_NextRound.Count > 0) { List <PD_MacroAction> takePosition_Positive_NextRound = new List <PD_MacroAction>(); // find all take position macros that would have a positive outcome (ability to cure) foreach (var macro in takePosition_NextRound) { List <PD_Action> walkSequence = macro.Actions_All; double walkSequenceValue = PD_AI_CardEvaluation_Utilities .Calculate_ListOfPlayerActions_Effect_On_Percent_AbilityToCureDiseases( game, walkSequence, true ); if (walkSequenceValue < 0) { continue; } var lastCommand = macro.NonExecutable_ShareKnowledge_Action; double exchangeValue = PD_AI_CardEvaluation_Utilities .Calculate_PlayerAction_Effect_On_Percent_AbilityToCureDiseases( game, lastCommand, true ); if (exchangeValue > 0.0) { takePosition_Positive_NextRound.Add(macro); } } if (takePosition_Positive_NextRound.Count > 0) { // find all of them that could be executed by the other player in one turn (4 steps) List <PD_MacroAction> executableByOtherPlayerInOneTurn = new List <PD_MacroAction>(); foreach (var macro in takePosition_Positive_NextRound) { if ( macro.NonExecutable_ShareKnowledge_Action.GetType() == typeof(PA_ShareKnowledge_GiveCard) ) { PA_ShareKnowledge_GiveCard action = (PA_ShareKnowledge_GiveCard)macro.NonExecutable_ShareKnowledge_Action; int destination = action.CityCardToGive; int otherPlayer = action.OtherPlayer; int otherPlayerLocation = game.GQ_PlayerLocation(otherPlayer); int distanceFromOtherPlayer = pathFinder.GetPrecalculatedShortestDistance( game, game.GQ_ResearchStationCities(), destination, otherPlayerLocation ); if (distanceFromOtherPlayer < 4) { executableByOtherPlayerInOneTurn.Add(macro); } } else if ( macro.NonExecutable_ShareKnowledge_Action.GetType() == typeof(PA_ShareKnowledge_TakeCard) ) { PA_ShareKnowledge_TakeCard action = (PA_ShareKnowledge_TakeCard)macro.NonExecutable_ShareKnowledge_Action; int destination = action.CityCardToTake; int otherPlayer = action.OtherPlayer; int otherPlayerLocation = game.GQ_PlayerLocation(otherPlayer); int distanceFromOtherPlayer = pathFinder.GetPrecalculatedShortestDistance( game, game.GQ_ResearchStationCities(), destination, otherPlayerLocation ); if (distanceFromOtherPlayer < 4) { executableByOtherPlayerInOneTurn.Add(macro); } } } if (executableByOtherPlayerInOneTurn.Count > 0) { return(executableByOtherPlayerInOneTurn); } } } return(new List <PD_MacroAction>()); }