Shannon V. OKeets -> RE: Long Time Coming! (9/11/2009 11:31:35 PM)
|
quote:
ORIGINAL: GordianKnot quote:
ORIGINAL: yvesp quote:
ORIGINAL: HansHafen I am just scared the AI will be extremely hard to code and get right. WIF is so complex and any logical, methodical decision tree will be like a 300 year old Redwood at a minimum! The AI has to think point to point on the frontline, but also has to see in depth, behind the front lines for potential threats including armor, planes, Offensive chits etc. I want it to be possible, but I am concerned. AI script languages already exist. Lua comes to mind. No need to re-invent the wheel, IMO. Just my two cents there : I believe that Steve would do very good to only build the AIO inner architecture and leave the actual script writing to the community. He would gain some time this way. However, writing a script langage (and inner tables) adaptable enough for the scripts to be really useful is already in itself a daunting task... In effect, this is "just" creating a language and the compiler that goes with it... Yves Did you have a comment here? All I see is a copy of an earlier post. === As for writing a script language for the casual player to use "to write his own scripts", ... Have you stopped by a good book store and looked at the section on programming languages? Try to find a book there that is less than 100 pages. Then try to read the first 2 chapters. I have no interest in trying to teach inexperienced programmers how to program. Nor am I interested in writing the definitive book on LAIO (Language for AI Opponent), which I've created for MWIF's AIO. To do so would require at least another year of work. Just laying out the chapters and sketching in the content for each would be time consuming. To hope that the result would be practical and used by more than a few dozen people would be very optimistic. Here is an example of a simple script for setting up the units: =========== // **************************************************************************** // Persian setup script - last modified Nov. 26, 2008 // **************************************************************************** // Local variables for Priority rules // ****************************** CapitalDefensePriority: Integer OilwellDefensePriority: Integer BorderDefensePriority: Integer MarauderDefensePriority: Integer // ****************************** // Local variables for selecting Defense randomly // ****************************** MaxRandomNumber: Integer CaptialBottom: Integer OilwellBottom: Integer BorderBottom: Integer MarauderBottom: Integer RandomNumber: Integer // ****************************** // Local variables for Defenses rules // ******************************* MARSmall: Boolean Location1: Hex Location2: Hex Location3: Hex UnitSmall: Boolean TargetHex: Hex // **************************************************************************** // // Primary Rule for Persian Setup // // **************************************************************************** R.PrimaryRule // ******************************* // Set starting value for each defense // ******************************* CapitalDefensePriority = 80 OilwellDefensePriority = 60 BorderDefensePriority = 60 MarauderDefensePriority = 5 // ******************************* // Modify Defense Weight if current situation makes any defenses better or worse // ******************************* // Reinforcements might arrive // ******************************* IF PersianReinforcementMightArrive THEN (CapitalDefensePriority = CapitalDefensePriority + 25) AND (BorderDefensePriority = BorderDefensePriority + 20) // ******************************* // Defenders are might survive! // ******************************* IF WeakAttackingForce THEN (CapitalDefensePriority = CapitalDefensePriority + 25) AND (BorderDefensePriority = BorderDefensePriority +- 20) AND (MarauderDefensePriority = MarauderDefensePriority - 4) // ******************************* // Defenders are doomed // ******************************* IF OverwhelmingAttackingForce THEN (CapitalDefensePriority = CapitalDefensePriority - 25) AND (OilwellDefensePriority = OilwellDefensePriority + 20) AND (BorderDefensePriority = BorderDefensePriority - 20) AND (MarauderDefensePriority = MarauderDefensePriority + 5) // ******************************* // Bad weather means stay and fight // ******************************* IF BadWeather THEN (CapitalDefensePriority = CapitalDefensePriority + 5) AND (BorderDefensePriority = BorderDefensePriority + 5) // ******************************* // Set Bottoms for selecting a Defense randomly. The cut-off values (bottoms) // serve as the top of the defense that precedes it. // So, Capital Defense is from 0 to OilwellBottom; // OilwellDefense is from OilwellBottom to BorderBottom; // ******************************* MaxRandomNumber = CapitalDefensePriority OilwellBottom = MaxRandomNumber IF OilwellDefenseFeasible THEN Inc(MaxRandomNumber, OilwellDefensePriority) // ******************************* // BorderDefense is from BorderBottom to MarauderBottom; // ******************************* BorderBottom = MaxRandomNumber IF BorderDefenseFeasible THEN Inc(MaxRandomNumber, BorderDefensePriority) // ******************************* // MarauderDefense is from MarauderBottom to MaxRandomNumber. // ******************************* MarauderBottom = MaxRandomNumber IF MarauderDefenseFeasible THEN Inc(MaxRandomNumber, MarauderDefensePriority) // ******************************* // Generate a random number and use it to choose one setup // ******************************* RandomNumber = Random(1, MaxRandomNumber) IF RandomNumber > MarauderBottom THEN Setup = MarauderDefense ELSE IF RandomNumber > BorderBottom THEN Setup = BorderDefense ELSE IF RandomNumber > OilwellBottom THEN Setup = OilwellDefense ELSE Setup = CapitalDefense // **************************************************************************** // // Non-primary Rules for Persian Setup // // *************************************************************************** // // Rules that modify defense priorities // // *************************************************************************** R.BadWeather // ******************************* // Weather in Mediterranean is NOT Fine // ******************************* Return NOT (Weather.Mediterranean = Fine) R.PersianReinforcementMightArrive // ******************************* // Chance for Persian MIL to arrive? // ******************************* // ******************************* // LAIO function EstimatedImpulsesRemainingInTurn // Returns the estimated number of impulses remaining in the current turn // ******************************* Return (WeakAttackingForce OR EstimatedImpulsesRemainingInTurn <= 2) R.WeakAttackingForce // ******************************* // With the maximum estimated attack forces, possible for defenders to survive? // Odds <= 3:1 // ******************************* Return Max(Countries.ForEach(AtWarPersiaRoughEstimateOfAttackForce, C)) >= 9 R.OverwhelmingAttackingForce // ******************************* // Are the maximum estimated attack forces likely to take no losses? Odds >= 7:1 // ******************************* Return Max(Countries.ForEach(AtWarPersiaRoughEstimateOfAttackForce, C)) >= 21 R.AtWarPersiaRoughEstimateOfAttackForce // ******************************* // Make a rough estimate of air and land units likely to participate in an // attack against the defenders // The variable C is set when this rule is called // ******************************* IF C.AtWar(Persia) THEN Return Sum(C.Units.ForEach(UnitCloseToPersianBorder, Unit)) ELSE Return 0 R.UnitCloseToPersianBorder // ******************************* // Strength of Land or Air unit close to the Persian Border // The variable Unit is set when this rule is called // ******************************* IF Unit.Organized AND (Unit.InSupply OR Unit.CanBeInSupply) AND Unit.UnitType IN LandUnitSet AND Unit.HexDist(Persia) <= 4 THEN Return Unit.Attack ELSE IF Unit.Organized AND (Unit.InSupply OR Unit.CanBeInSupply) AND Unit.UnitType IN AirUnitSet AND Unit.Range(Teheran) <= 4 THEN Return Unit.Tact ELSE Return 0 // **************************************************************************** // // End of rules used to modify defense priority // Beginning of feasible defense rules // // **************************************************************************** R.BorderDefenseFeasible // ******************************* // Border defense // // Feasible given A and B and C // A) No Risk of paradrop on the capital // B) No Risk of a two front land advance on the capital // C) No Risk of having the land unit flipped // ******************************* Return (NOT ParadropThreatToTeheran) AND (NOT TwoFrontLandAdvance) AND (NOT SetupHasThreatOfLandUnitDisorganized(BorderDefense)) R.OilwellDefenceFeasible // ******************************* // Oil well defense // // Feasible given A and either B or C // A) JapanInterferenceInPersiaPossible // B) Risk of paradrop on the oil wells // C) Risk of invasion on the oil wells // ******************************* Return JapanInterferenceInPersiaPossible AND (ParadropThreatToOilwells OR InvasionThreatToOilwells) R.MarauderDefenseFeasible // ******************************* // Marauder defense // // Feasible given A or B // A) Chance to conquer Iraq // B) Chance to overrun a disorganized unit // ******************************* Return ChanceToConquerIraq OR ChanceToOverrunDisorganizedUnit R.JapanInterferenceInPersiaPossible // ******************************* // JapanInterferenceInPersiaPossible // // IF A and B // A) Japan plans to send units to Perisa immediately // B) Japan is at war with attacking country or prepared to declare war on it // ******************************* Return JapanReadyToSendUnitsToPersia AND JapanWarWithPersianAggressor R.JapanReadyToSendUnitsToPersia // ******************************* // LAIO function Preparations(X, Action) // Checks if the country X is plans to take do Action // ******************************* IF Preparations(Japan, MasterPlanFightForOilwellsInPersia)) = False THEN Return False Else // ******************************* // Can Japan send a unit to Persia? // ******************************* // Loop over all TRS/AMPH // ******************************* Return (MajorTransportAvailable OR // ******************************* // Loop over all TRS/AMPH/SCS // ******************************* MinorTransportAvailable) R.MajorTransportAvailable // ******************************* // Does Japan have a corps capable transport available? // ******************************* UnitSmall = False // Unit is corps size Return Japan.Units.FirstThat(TransportAvailable, Transport) R.MinorTransportAvailable // ******************************* // Does Japan have a division capable transport available? // ******************************* UnitSmall=True // Unit is division size Return Japan.LandUnits.FirstThat(TransportAvailable, Transport) R.TransportAvailable // ******************************* // Transport's type is TRS or AMPH (or SCS if the unit transport is a DIV); // Transport is in supply, organized, and in // the Persian Gulf or within range of it // The variable Transport is set when this rule is called // ******************************* IF (NOT UnitSmall) AND (((Transport.UnitType = AMPH) AND (NOT (Unit.UnitType IN [HQA, ARM, MECH, ART]))) OR (Transport.UnitType = TRS)) AND Transport.Organized AND (Transport.InSupply OR Transport.CanBeInSupply) AND ((Transport.SeaArea = PersianGulf) OR Transport.Range(PersianGulf)) THEN Return Japan.FirstThat(TransportUnitAvailable, U) ELSE IF UnitSmall AND (((Transport.UnitType = AMPH) AND (NOT Unit.UnitType IN [HQA, ARM, MECH, ART])) OR (Transport.UnitType = TRS) OR (Option.SCSTransport AND (Transport.UnitType = SCS) AND (Unit.UnitType IN InfantrySet) AND (NOT (Unit.UnitType IN MotorizedSet)))) AND Transport.Organized AND (Transport.InSupply OR Transport.CanBeInSupply) AND ((Transport.SeaArea = PersianGulf) OR (Transport.Range(PersianGulf)) THEN Return Japan.FirstThat(TransportUnitAvailable, U) ELSE Return False R.TransportUnitAvailable // ******************************* // Can any land unit be transported? // The variable Unit is set when this rule is called // ******************************* Return ((Unit.Hex IN [PersianGulf.CoastalHex]) OR (Transport.Cargo = Unit)) AND Unit.Organized AND (Unit.Small = UnitSmall) AND Unit.CooperatesWith(Transport) AND (Unit.InSupply OR Unit.CanBeInSupply) R.JapanWarWithPersianAggressor // ******************************* // Japan being at war with a country with which Persia is at war or Japan // willing to declare war on same // ******************************* Return Countries.FirstThat(CountryAtWarPersiaAndJapan, C) R.CountryAtWarPersiaAndJapan // ******************************* // Country war with Persia and either at war with Japan or soon to be at war // with Japan // ******************************* Return C.AtWar(Persia) AND (C.AtWar(Japan) OR // ******************************* // LAIO function Preparations(X, Action, Y) // Checks if the country X is prepared to take Action against country Y // ******************************* Preparations(Japan, ImminentWar, C)) R.SetupHasThreatOfLandUnitDisorganized(GivenSetup) // ******************************* // Check if any unit in a setup has the threat of being disorganized // The variable GivenSetup is an argument when this rule is called // ******************************* // LAIO function SetupUnits(GivenSetup) // Returns all units in GivenSetup // ******************************* Return SetupUnits(GivenSetup).ForEach(LocationsGroundStrikeThreat, TargetUnit) R.LocationsGroundStrikeThreat // ******************************* // Checks if any of a unit's locations in a setup has the risk of being ground // struck // The variables GivenSetup and TargetUnit are set when this rule is called // ******************************* // LAIO function SetupLocations(GivenSetup, TargetUnit) // Returns all possible hexes where TargetUnit can be placed in GivenSetup // ******************************* Return SetupLocations(GivenSetup, TargetUnit).FirstThat(NoGroundStrikeThreat, TargetHex) R.NoGroundStrikeThreat // ******************************* // If No Threat of having TargetUnit ground struck // The variable Location is set when this rule is called // ******************************* Return NOT GroundStrikeThreat R.GroundStrikeThreat // ******************************* // Threat of having TargetUnit ground struck in TargetHex // LAIO function Product multiplies probabilities of failure. // ******************************* Return Product(Countries.ForEach(AtWarPersiaGroundStrike, C) <= .70 R.AtWarPersiaGroundStrike // ******************************* // Countries at war with Persia and a ground strike is possible // The variable C is set when this rule is called // ******************************* IF C.AtWar(Persia) THEN Return Product(C.Units.ForEach(GroundStrikePossible, AttackUnit)) ELSE Return 1 R.GroundStrikePossible // ******************************* // Ground strike possible // The variables AttackUnit, TargetUnit, and TargetHex are set before this rule // is called // ******************************* IF AttackUnit.Organized AND (AttackUnit.InSupply OR AttackUnit.CanBeInSupply) AND AttackUnit.CanGroundStrike AND AttackUnit.Range(TargetHex) THEN Return ProbUnsuccesfulGroundStrike(AttackUnit) ELSE Return 1 R.ProbUnsuccesfulGroundStrike // ******************************* // Chance of unsuccesful ground strike // The variables AttackUnit, TargetUnit, and TargetHex are set before this rule // is called // ******************************* // Probability ground strike(s) fail; there are 2 when target unit is surprised // ******************************* IF TargetUnit.SurprisedBy(AttackUnit) THEN Return ((10 - AttackUnit.Tact(TargetHex))/10) * ((10 - AttackUnit.Tact(TargetHex))/10) ELSE Return (10 - AttackUnit.Tact(TargetHex))/10 R.TwoFrontLandAdvance // ******************************* // Threat of a two front land advance on the capital // ******************************* // Land units on both sides of the Caspian Sea // ******************************* Return (ThreatNWBorder AND ThreatNEBorder) OR // ******************************* // Land units on one side of the Caspian Sea and also in Iraq, close to the // Persian border // ******************************* ((ThreatNWBorder OR ThreatNEBorder) AND ThreatWestBorder) R.ThreatNWBorder // ******************************* // Enemy land unit on the border close to the west side of the Caspian Sea // ******************************* // We only need to find a single qualified unit for the threat to be real // ******************************* Return Countries.FirstThat(AtWarPersiaGroundInvasionNW, C) R.AtWarPersiaGroundInvasionNW // ******************************* // Countries at war with Persia - ground invasion NW // The variable C is set when this rule is called // ******************************* IF C.AtWar(Persia) THEN Return C.Units.FirstThat(AttackerAvailableNW, Unit) ELSE Return False R.AttackerAvailableNW // ******************************* // Enemy land unit on the NW border, and close enough to reach Teheran // The variable Unit is set when this rule is called // ******************************* Return FastUnitAvailable AND LandUnitNWBorder R.FastUnitAvailable // ******************************* // Fast moving landunit available // ******************************* Return Unit.Organized AND (Unit.InSupply OR Unit.CanBeInSupply) AND (Unit.UnitType IN LandUnitSet) AND // ******************************* // Possible for unit to reach Teheran in 2 moves // ******************************** Unit.ImpulsesToReach(Teheran) <= 2 R.LandUnitNWBorder // ******************************* // Enemy land unit on the NW border // ******************************* // Any unit within 5 hexes of the border hex (71, 77) // ******************************* Return Unit.HexDist(71, 77) <= 5 R.ThreatNEBorder // ******************************* // Enemy land unit on the border close to the east side of the Caspian Sea // ******************************* // We only need to find a single qualified unit for the threat to be real // ******************************* Return Countries.FirstThat(AtWarPersiaGroundInvasionNE, C) R.AtWarPersiaGroundInvasionNE // ******************************* // Countries at war with Persia - ground invasion NE // The variable C is set when this rule is called // ******************************* IF C.AtWar(Persia) THEN Return C.Units.FirstThat(AttackerAvailableNE, Unit) ELSE Return False R.AttackerAvailableNE // ******************************* // Enemy land unit on the NE border, and close enough to reach Teheran // The variable Unit is set when this rule is called // ******************************* Return FastUnitAvailable AND LandUnitNEBorder R.LandUnitNEBorder // ******************************* // Enemy land unit on the NE border // ******************************* Return Unit.HexDist(71, 83) <= 5 R.ThreatWestBorder // ******************************* // Land unit in Iraq, close to Persian border // ******************************* // We only need to find a single qualified unit for the threat to be real // ******************************* Return Countries.FirstThat(AtWarPersiaGroundInvasionWest, C) R.AtWarPersiaGroundInvasionWest // ******************************* // Countries at war with Persia - ground invasion west // The variable C is set when this rule is called // ******************************* IF C.AtWar(Persia) THEN Return C.Units.FirstThat(AttackerAvailableWest, Unit) ELSE Return False R.AttackerAvailableWest // ******************************* // Enemy land unit on the west border, and close enough to reach Teheran // The variable Unit is set when this rule is called // ******************************* Return FastUnitAvailable AND LandUnitWestBorder R.LandUnitWestBorder // ******************************* // Enemy land unit on the Iraq border // ******************************* // Any hex in that is within two hexes of the Iraqi-Persian border // ******************************* Return (Unit.Hex IN Iraq) AND (Unit.HexDist(Persia) <= 2) R.InvasionThreatToOilwells // ******************************* // Invasion threat to oil wells (which are all in coastal hexes) // ******************************* // Only when weather in Mediterranean is rain or fine // ******************************* Return (Weather.Mediterranean IN [Fine, Rain]) AND // ******************************* // Loop over all TRS/AMPH // ******************************* (MajorInvasionAvailable OR // ******************************* // Loop over all USSR TRS/AMPH/SCS // ******************************* MinorInvasionAvailable) R.MajorInvasionAvailable // ******************************* // Major invasion available // ******************************* MARSmall = False // ******************************* // We only need to find a single qualified unit for the threat to be real // ******************************* Return Countries.FirstThat(AtWarPersiaTRSAvailable, C) R.AtWarPersiaTRSAvailable // ******************************* // Countries at war with Persia - TRS available // The variable C is set when this rule is called // ******************************* IF C.AtWar(Persia) OR CooperatesWithCountryAtWarPersia(C) THEN Return C.Units.FirstThat(TRSAvailable, Transport) ELSE Return False R.CooperatesWithCountryAtWarPersia // ******************************* // Does a country cooperate with any country // that is at war with Persia? // The variable C is set when this rule is called // ******************************* Return Countries.FirstThat(NotAtWarPersiaButCooperates, C2, C) R.NotAtWarPersiaButCooperates // ******************************* // Country not a war with Persia but Cooperates with that is // The variable C2, C and set when this rule is called // ******************************* Return NOT C2.AtWar(Persia) AND C2.Cooperates(C) R.MinorInvasionAvailable // ******************************* // Major invasion available // ******************************* MARSmall = True Return Countries.FirstThat(AtWarPersiaDivisionTransportAvailable, C) R.AtWarPersiaDivisionTransportAvailable // ******************************* // Countries at war with Persia - division transport available // The variable C is set when this rule is called // ******************************* IF C.AtWar(Persia) OR CooperatesWithCountryAtWarPersia(C) THEN Return C.Units.FirstThat(DivisionTransportAvailable, Transport) ELSE Return False R.TRSAvailable // ******************************* // TRS/AMPH is available and in the sea area or within range of it // The variable Transport is set when this rule is called // ******************************* // Transport's type is TRS/AMPH; Transport is in supply, organized, and in // the Persian Gulf or within range of it with the sea box >= 2 // ******************************* IF (Transport.UnitType IN [TRS, AMPH]) AND Transport.Organized AND (Transport.InSupply OR Transport.CanBeInSupply) AND (((Transport.SeaArea = PersianGulf) AND (Transport.SeaBox >= 2)) OR (Transport.Range(PersianGulf) AND (Transport.Movement >= PersianGulf.Box2))) THEN Return Countries.FirstThat(AtWarPersiaInvadingUnitAvailable, C) ELSE Return False R.AtWarPersiaInvadingUnitAvailable // ******************************* // Countries at war with Persia - invading unit available // The variable C is set when this rule is called // ******************************* IF C.AtWar(Persia) THEN Return C.Units.FirstThat(InvadingUnitAvailable, Unit) ELSE Return False R.InvadingUnitAvailable // ***************************** // Land unit available, on a coastal hex or stacked with TRS/AMPH, and the unit // can also be carried by the available transport // The variable Unit is set when this rule is called // ******************************* // Non-MAR can only invade from AMPH if option AmphibiousUnits is used // ******************************* IF Option.AmphibiousUnits AND (NOT (Unit.UnitType IN MarineSet)) AND (Transport.UnitType = TRS) THEN Return False // ******************************* // Land unit is coastal hex Persian Gulf/stacked with TRS and unit is in supply, // is organized Infantry, and small matches MARSmall // ******************************* ELSE IF (Unit.Hex IN [PersianGulf.CoastalHex] OR Transport.Cargo = Unit) AND Unit.Organized AND (Unit.Small = MARSmall) AND (Unit.UnitType IN InfantrySet) AND (NOT (Unit.UnitType IN MotorizedSet) AND Unit.CooperatesWith(Transport) AND (Unit.InSupply OR Unit.CanBeInSupply) THEN Return True ELSE Return False R.DivisionTransportAvailable // ******************************* // TRS/AMPH/SCS is available and in sea area or within range of it // ******************************* // Transport's type is TRS or AMPH or SCS; transport is in supply, organized, // and in the Persian Gulf or within range of it with the sea box >= 3 // The variable Transport is set when this rule is called // ******************************* IF ((Transport.UnitType IN [TRS, AMPH]) OR ((Transport.UnitType = SCS) AND Option.SCSInvasion)) AND Transport.Organized AND (((Transport.SeaArea = PersianGulf) AND (Transport.SeaBox >= 3)) OR (Transport.Range(PersianGulf) AND (Transport.Movement >= PersianGulf.Box3))) AND (Transport.InSupply OR Transport.CanBeInSupply) THEN Return Countries.FirstThat(AtWarPersiaInvadingUnitAvailable, C) ELSE Return False R.ParadropThreatToOilwells // ******************************* // Paradrop threat to oil wells // ******************************* // Only if the weather in the Mediterranean zone is neither storm nor blizzard // ******************************* Return (NOT (Weather.Mediterranean IN [Storm, Blizzard])) AND Countries.FirstThat(AtWarPersiaATROilWells, C) R.AtWarPersiaATROilWells // ******************************* // Loop over all countries at war with Persia – ATR // The variable C is set when this rule is called // ******************************* IF C.AtWar(Persia) THEN Return C.Units.FirstThat(ATROilwells, ATR) ELSE Return False R.ATROilWells // ***************************** // Para unit available that can be carried by an ATR within range of an oil well // ******************************* Location1 = (80, 77) Location2 = (82, 78) Location3 = (84, 79) Return ATRAvailable AND (ATR.WithinRange(Location1) OR ATR.WithinRange(Location2) OR ATR.WithinRange(Location3)) R.ParadropThreatToTeheran // ******************************* // Paradrop threat to Teheran // ******************************* // Only if the weather in the Mediterranean zone is neither storm nor blizzard // ******************************* IF Weather.Mediterranean IN [Storm, Blizzard] THEN Return False // ******************************* // Loop over all attacking nations ATR // ******************************* ELSE Return Countries.FirstThat(AtWarPersiaATRTeheran, C) R.AtWarPersiaATRTeheran // ******************************* // ATR's range gets it to within 3 hexes of Teheran // The variable C is set when this rule is called // ******************************* IF C.AtWar(Persia) THEN Return C.Units.FirstThat(ATRCloseTeheran, ATR) ELSE Return False R.ATRCloseTeheran // ******************************* // ATR can land a unit within 3 hexes of Teheran // The variable ATR is set when this rule is called // ******************************* Return ATRAvailable AND ATR.Range > (ATR.HexDist(Teheran) - 3) R.ATRAvailable // ******************************* // Air transport available // ******************************* // Unit is a ATR, organized, in supply, and has range to reach the target // ******************************* IF (ATR.UnitType = ATR) AND ATR.Organized AND (ATR.InSupply OR ATR.CanBeInSupply) THEN Return Countries.FirstThat(AtWarPersiaParaAvailable, C2) ELSE Return False R.AtWarPersiaParaAvailable // ******************************* // Para unit available for ATR // The variable C2 is set when this rule is called // ******************************* IF C2.AtWar(Persia) THEN Return C2.Units.FirstThat(ParaAvailable, Para) ELSE Return False R.ParaAvailable // ******************************* // Para available // ******************************* // Para is a PARA, organized, in supply, and within movement range of ATR's hex // ******************************* Return (Para.UnitType = PARA) AND Para.Organized AND (Para.InSupply OR Para.CanBeInSupply) AND Para.MovementRange(ATR.Hex) Para.CooperatesWith(ATR) R.ChanceToOverrunDisorganizedUnit // **************************************************************************** // Chance to overrun a disorganized unit // // IF A, B, C, D AND E // A) There is a disorganized Allied naval/air/supply unit(s) without a land // unit guarding it // B) The Persian CAV can reach it in one impulse // C) The axis major power controlling Persia is at war with allied major power // that controls the disorganized unit // D) The Persian CAV can enter the country/territory that the disorganized unit // is located in // E) The Allies can’t move or rail a unit to protect the disorganized unit // **************************************************************************** Return Allied.Units.ForEach(ChanceToOverrun, U) R.ChanceToOverrun // ******************************* // Chance to overrun Unit? // ******************************* Return Unit.Disrupted AND (Unit.UnitType IN (Air, Naval, SupplyUnit)) AND Persia.BorderHexes.FirstThat(UnitWithinFourHexes, Hex, Unit) AND PersianCavCanReachDisorganizedUnitHex AND (Persia.AtWar(Unit.Country) OR Persia.ControllingMajorPower.AtWar(Unit.Country) AND (NOT Allied.Units.FirstThat(LandUnitProtectingHex, Hex, Unit)) AND (NOT AlliedUnitCanMoveToThreatenedHex(Unit.Hex)) AND MinorCountryUnitsCanEnter(Persia, Unit.Hex.Country) THEN R.AlliedUnitCanMoveToThreatenedHex // ******************************* // Checks if the Allies can move a land unit to a threaded hex one impulse // The variable Hex is set when this rule is called // ******************************* TargetHex = Hex Return Allied.Units.FirstThat(UnitCanBeMovedToTargetHex, U) R.LandUnitProtectingHex // ******************************* // Checks if a the land unit are in the same hex // The variable Hex, Unit are set when this rule is called // ******************************* Return Hex = Unit.Hex R.UnitWithinFourHexes // ******************************* // Checks if a the distance between two hexes are 4 or less // The variable Hex, Unit are set when this rule is called // ******************************* Return HexDist(Hex, Unit.Hex) <= 4 R.PersianCavCanReachDisorganizedUnitHex // ******************************* // Checks if the Persian 3-4 CAV can reach a Hex from any Persian border hex // The variable UnitHex is set when this rule is called // ******************************* Return Peria.BorderHexes.FirstThat(CanReachDisorganizedUnit, Hex, UnitHex) R.CanReachDisorganizedUnit // ******************************* // Checks if the Persian 3-4 CAV can reach Hex X from Hex Y in one impulse // The variable Hex, UnitHex are set when this rule is called // ******************************* // Temporarily assign a location for specific Persian unit // ******************************* Persia.Unit(3-4 CAV).Hex = Hex // ******************************* // Can the Persian CAV reach the disrupted unit hex from the // temporary location in one impulse? // ******************************* Return Persia.Unit(3-4 CAV).ImpulsesToReach(UnitHex.Hex) = 1 R.ChanceToConquerIraq // ******************************* // Chance to conquer Iraq // // IF A, B, C, D AND E // A) Iraq is controlled/conquered by the Allies // B) There is no allied unit in Baghdad // C) the Persian CAV can reach Baghdad in one impulses // D) Major power controlling Persia is at war with Major power controlling Iraq // E) The Allies can’t move or rail a unit to Baghdad // ******************************* Return (Iraq.Side = sdAllied) AND (NOT AlliedUnitInBaghdad) AND PossibleForPersianCAVToReachBaghdad AND Persia.ControllingMajorPower.AtWar(Iraq.ControllingMajorPower) AND (NOT AlliedUnitCanBeMovedToBaghdad) THEN R.AlliedUnitInBaghdad // ******************************* // Check if Baghdad is occupied by an Allied unit // ******************************* Return MapStacks(Baghdad).FirstThat(AlliedUnit, U) R.AlliedUnit // ******************************* // Check if unit is controlled by the Allied side // ******************************* Return U.Side = adAllied R.PossibleForPersianCAVToReachBaghdad // ******************************* // Possible for Persian CAV to reach Baghdad in 1 moves // ******************************* Return (Persia.Unit(CAV (3-4)).ImpulsesToReach(Baghdad) = 1) R.AlliedUnitCanMoveToBaghdad // ******************************* // Checks if the Allies can move a unit to Baghdad in one impulse // ******************************* TargetHex = Baghdad Return Allied.Units.FirstThat(UnitCanMoveToTargetHex, U) R.UnitCanMoveToTargetHex // ******************************* // Can a unit be moved to TargetHex in one impules // TargetHex is an input parameter to this rule. // ******************************* IF Unit.Organized AND (Unit.InSupply OR Unit.CanBeInSupply) AND (Unit.UnitType IN LandUnitSet) AND Unit.ImpulsesToReach(TargetHex) = 1 THEN Return True ELSE IF Unit.Organized AND Unit.UnitType IN LandUnitSet AND RailMovePossible(Unit, TargetHex) AND (RailDist(Unit.Hex, TargetHex) <= 60) THEN Return True ELSE Return False // **************************************************************************** // // End of rules; Beginning of setups. // // **************************************************************************** [Setup BorderDefense] // ******************************* // Border Defense // ******************************* // NW attack // ******************************* 1 CAV (3-4), (72,78) OR 1 CAV (3-4), (73,77) OR 1 CAV (3-4), (74,79) OR // ******************************* // NE attack // ******************************* 1 CAV (3-4), Bandar Shah [Setup OilwellDefense] // ******************************* // Oil Well Defense // ******************************* 1 CAV (3-4), Bandar Shah OR 1 CAV (3-4), (82,78) OR 1 CAV (3-4), (83,78) [Setup CapitalDefense] // ******************************* // Capital Defense // ******************************* 1 CAV (3-4), Teheran [Setup MarauderDefense] // ******************************* // Marauder Defense // ******************************* // Iraq attack // ******************************* 1 CAV (3-4), (75,74) OR // ******************************* // Overrunning a disorganized unit // Border Hexes 2 space appart if possible // ******************************* 1 CAV (3-4), (81,76) OR // Swamp E of Bandar Shaput 1 CAV (3-4), (79,76) OR 1 CAV (3-4), (77,75) OR 1 CAV (3-4), (75,74) OR 1 CAV (3-4), (73,75) OR 1 CAV (3-4), (72,75) OR 1 CAV (3-4), (71,74) OR 1 CAV (3-4), (69,74) OR 1 CAV (3-4), (70,75) OR 1 CAV (3-4), (70,76) OR 1 CAV (3-4), (72,78) OR 1 CAV (3-4), (73,83) OR // Swamp hex 2 hex NE Bandar Shah 1 CAV (3-4), (71,84) OR 1 CAV (3-4), (71,85) OR 1 CAV (3-4), (72,88) OR 1 CAV (3-4), (73,89) OR 1 CAV (3-4), (75,89) OR 1 CAV (3-4), (77,89) OR 1 CAV (3-4), (79,89) OR 1 CAV (3-4), (80,90) OR 1 CAV (3-4), (82,89) OR 1 CAV (3-4), (84,89) OR 1 CAV (3-4), (86,90) OR 1 CAV (3-4), (88,89) ===========
|
|
|
|