Exemple #1
0
        private ITreeNode MakeInventUpgradeTree(ITreeNode falseNode)
        {
            DelAction inventUpgrade = () => ai.InventUpgrade(activeState.activeSourceBuildingKind);
            ActionNode actionInventUpgrade = new ActionNode(inventUpgrade, this);
            GetPrice getUpgradePrice = () => { return GetPriceForMonasteryUpgrade(activeState.activeUpgradeKind, activeState.activeSourceBuildingKind);};
            ChangeSourcesActionNode addActionInventUpgrade = new ChangeSourcesActionNode(new ActionSource(inventUpgrade, getUpgradePrice), this);

            HasSourcesNode hasMoneyForUpgrade = new HasSourcesNode(actionInventUpgrade, addActionInventUpgrade, getUpgradePrice, map);
            CanHaveSourcesNode canHaveMoneyForUpgrade = new CanHaveSourcesNode(hasMoneyForUpgrade, falseNode, getUpgradePrice, map);
            DecisionBinaryNode hasSecondUpgrade = new DecisionBinaryNode(falseNode, canHaveMoneyForUpgrade, () => { return (activeState.activeUpgradeKind = map.GetPlayerMe().GetMonasteryUpgrade(activeState.activeSourceBuildingKind)) == UpgradeKind.SecondUpgrade; });
            DecisionBinaryNode everyTurnALotOfOneSource = new DecisionBinaryNode(hasSecondUpgrade, falseNode, () => { return ai.EveryTurnALotOfOneSource(60, false); });
            DecisionBinaryNode hasMonasteryWithFreeSlot = new DecisionBinaryNode(everyTurnALotOfOneSource, falseNode, ai.HasFreeSlotInMonastery);

            return hasMonasteryWithFreeSlot;
        }
Exemple #2
0
        private ITreeNode MakeBuildRoadTree(ITreeNode falseNode)
        {
            ActionNode actionBuildRoad = new ActionNode(() => ai.BuildRoad(activeState.activeRoad), this);
            ChangeSourcesActionNode addActionRoad = new ChangeSourcesActionNode(new ActionSource(() => ai.BuildRoad(activeState.activeRoad), PriceKind.BRoad), this);

            HasSourcesNode hasSourcesForRoad = new HasSourcesNode(actionBuildRoad, addActionRoad, PriceKind.BRoad, map);
            DecisionBinaryNode hasFreeTownPlace = new DecisionBinaryNode(hasSourcesForRoad, EA, () => { return ai.GetFreeTownPlaces().Count == 0; });
            ForBestRoadNode localRoot = new ForBestRoadNode(hasFreeTownPlace, falseNode, this);

            return localRoot;
        }
Exemple #3
0
        private ITreeNode MakeBuyLicenceTree(ITreeNode falseNode)
        {
            DelAction buyLicence = () => ai.BuyLicence(activeState.activeSourceKind);
            ActionNode actionBuyLicence = new ActionNode(buyLicence, this);
            GetPrice getLicencePrice = () => { return GetPriceForMarketLicence(activeState.activeLicenceKind, activeState.activeSourceKind);  };
            ChangeSourcesActionNode addActionBuyLicence = new ChangeSourcesActionNode(new ActionSource(buyLicence, getLicencePrice), this);

            HasSourcesNode hasMoneyForLicence = new HasSourcesNode(actionBuyLicence, addActionBuyLicence, getLicencePrice, map);
            CanHaveSourcesNode canHaveSourcesForLicence = new CanHaveSourcesNode(hasMoneyForLicence, falseNode, getLicencePrice, map);
            DecisionBinaryNode hasSecondLicence = new DecisionBinaryNode(falseNode, canHaveSourcesForLicence, () => { return (activeState.activeLicenceKind = map.GetPlayerMe().GetMarketLicence(activeState.activeSourceKind)) == LicenceKind.SecondLicence; });
            DecisionBinaryNode everyTurnALotOfOneSource = new DecisionBinaryNode(hasSecondLicence, falseNode, () => { return ai.EveryTurnALotOfOneSource(54, true); });
            DecisionBinaryNode hasMarketWithFreeSlot = new DecisionBinaryNode(everyTurnALotOfOneSource, falseNode, ai.HasFreeSlotInMarket);

            return hasMarketWithFreeSlot;
        }
Exemple #4
0
        private ITreeNode MakeBuildFortTree()
        {
            DelAction buildFort = () => ai.BuildFort(activeState.activeTown, activeState.activeTownPos);
            ActionNode actionBuildFort = new ActionNode(buildFort, this);
            ChangeSourcesActionNode addActionBuildFort = new ChangeSourcesActionNode(new ActionSource(buildFort, PriceKind.BFort), this);

            HasSourcesNode haveSourcesForFort = new HasSourcesNode(actionBuildFort, addActionBuildFort, PriceKind.BFort, map);

            DecisionBinaryNode existHexaWithFitnessMore = new DecisionBinaryNode(haveSourcesForFort, EA, () => { return ai.ExistHexaWithFitnessMore(0.4f, activeState.activeTown.GetIHexa(activeState.activeTownPos)); });
            DecisionBinaryNode existPlayerWithFitnessMore = new DecisionBinaryNode(haveSourcesForFort, existHexaWithFitnessMore, () => { return ai.ExistPlayerWithFitnessMore(0.25f); });
            DecisionBinaryNode existFreePlaceForRoad = new DecisionBinaryNode(existPlayerWithFitnessMore, haveSourcesForFort, ai.ExistFreePlaceForRoad);
            DecisionBinaryNode hasFortAlready = new DecisionBinaryNode(EA, existFreePlaceForRoad, () => { return map.GetPlayerMe().GetBuildingCount(Building.Fort) > 0; });
            CanHaveSourcesNode canHaveSourcesForFort = new CanHaveSourcesNode(hasFortAlready, EA, PriceKind.BFort, map);

            DecisionBinaryNode hasSourcesLess16 = new DecisionBinaryNode(canHaveSourcesForFort, EA, () => activeState.activeTown.GetIHexa(activeState.activeTownPos).GetStartSource() <= 16);

            DecisionBinaryNode hasPointsMore18 = new DecisionBinaryNode(hasSourcesLess16, EA, () => { return true; });

            return hasPointsMore18;
        }
Exemple #5
0
        private ITreeNode MakeBuildMonasteryTree()
        {
            ActionNode actionBuildMonastery = new ActionNode(() => ai.BuildMonastery(activeState.activeTown, activeState.activeTownPos), this);
            ChangeSourcesActionNode addActionMonastery = new ChangeSourcesActionNode(new ActionSource(() => ai.BuildMonastery(activeState.activeTown, activeState.activeTownPos), PriceKind.BMonastery), this);

            HasSourcesNode hasSourcesForMonastery = new HasSourcesNode(actionBuildMonastery, addActionMonastery, PriceKind.BMonastery, map);

            DecisionBinaryNode hasFort = new DecisionBinaryNode(hasSourcesForMonastery, EA, () => map.GetPlayerMe().GetBuildingCount(Building.Fort) > 0);
            DecisionBinaryNode hasMonastery = new DecisionBinaryNode(hasFort, hasSourcesForMonastery, () => map.GetPlayerMe().GetBuildingCount(Building.Monastery) > 0);

            DecisionBinaryNode hasMonasteryWithFreeSlot = new DecisionBinaryNode(EA, hasMonastery, ai.HasFreeSlotInMonastery);
            DecisionBinaryNode everyTurnALotOfOneSource = new DecisionBinaryNode(hasMonasteryWithFreeSlot, EA, () => { return ai.EveryTurnALotOfOneSource(60, false); });
            CanHaveSourcesNode canHaveSourcesForMonastery = new CanHaveSourcesNode(everyTurnALotOfOneSource, EA, PriceKind.BMonastery, map);

            DecisionBinaryNode hasSourcesLess16 = new DecisionBinaryNode(canHaveSourcesForMonastery, EA, () => activeState.activeTown.GetIHexa(activeState.activeTownPos).GetStartSource() <= 16);

            return hasSourcesLess16;
        }
Exemple #6
0
        private ITreeNode MakeActionStealSources(ITreeNode falseNode)
        {
            DelAction stealSources = () => { return ai.StealSources(activeState.activePlayer); };
            ActionNode actionStealSources = new ActionNode(stealSources, this);
            ChangeSourcesActionNode addActionStealSources = new ChangeSourcesActionNode(new ActionSource(stealSources, PriceKind.AStealSources), this);

            HasSourcesNode haveSourcesForStealSources = new HasSourcesNode(actionStealSources, addActionStealSources, PriceKind.AStealSources, map);
            DecisionBinaryNode enoughFitness = new DecisionBinaryNode(haveSourcesForStealSources, falseNode, () => { return Fitness.GetFitness(activeState.activePlayer) > 0.35; });
            ForBestPlayerNode forEachPlayerNode = new ForBestPlayerNode(enoughFitness, falseNode, this);
            CanHaveSourcesNode canHaveSourcesForStealSources = new CanHaveSourcesNode(forEachPlayerNode, falseNode, PriceKind.AStealSources, map);
            return canHaveSourcesForStealSources;
        }
Exemple #7
0
        private ITreeNode MakeActionShowParade()
        {
            DelAction showParade = () => { return ai.ActionShowParade(); };
            ActionNode actionShowParade = new ActionNode(showParade, this);
            ChangeSourcesActionNode addActionShowParade = new ChangeSourcesActionNode(new ActionSource(showParade, PriceKind.AParade), this);

            HasSourcesNode haveSourcesForParade = new HasSourcesNode(actionShowParade, addActionShowParade, PriceKind.AParade, map);
            DecisionBinaryNode existFreePlaceForRoad = new DecisionBinaryNode(EA, haveSourcesForParade, ai.ExistFreePlaceForRoad);
            CanHaveSourcesNode canHaveSourcesForParade = new CanHaveSourcesNode(existFreePlaceForRoad, EA, PriceKind.AParade, map);

            return canHaveSourcesForParade;
        }
Exemple #8
0
        private ITreeNode MakeActionCaptureHexa()
        {
            ITreeNode falseNode = EA;

            DelAction captureHexa = () => { return ai.ActionCaptureHexa(activeState.activeHexa); };
            ActionNode actionCaptureHexa = new ActionNode(captureHexa, this);
            ChangeSourcesActionNode addActionCaptureHexa = new ChangeSourcesActionNode(new ActionSource(captureHexa, PriceKind.ACaptureHexa), this);

            HasSourcesNode haveSourcesForCaptureHexa = new HasSourcesNode(actionCaptureHexa, addActionCaptureHexa, PriceKind.ACaptureHexa, map);

            DecisionBinaryNode isFitnessMoreThan = new DecisionBinaryNode(haveSourcesForCaptureHexa, falseNode, () => { return 0.30 < Fitness.GetFitness(map.GetPlayerMe(), activeState.activeHexa); });
            CanHaveSourcesNode canHaveSourcesForCaptureHexa = new CanHaveSourcesNode(isFitnessMoreThan, falseNode, PriceKind.ACaptureHexa, map);

            return canHaveSourcesForCaptureHexa;
        }
Exemple #9
0
        public ITreeNode MakeBuildTownTree(ITreeNode falseNode)
        {
            ITreeNode actionBuildTown = new ActionNode(() => ai.BuildTown(activeState.activeTown.GetTownID()), this);
            ChangeSourcesActionNode addActionTown = new ChangeSourcesActionNode(new ActionSource(() => ai.BuildTown(activeState.activeTown.GetTownID()), PriceKind.BTown), this);

            HasSourcesNode haveSourcesForTown = new HasSourcesNode(actionBuildTown, addActionTown /* back to for each */, PriceKind.BTown, map);
            ForBestTownPlaceNode localRoot = new ForBestTownPlaceNode(haveSourcesForTown, falseNode, this);

            return localRoot;
        }
Exemple #10
0
        public ITreeNode MakeBuildSourceBuildingTree(ITreeNode falseNode)
        {
            DelAction buildSourceBuilding = () => ai.BuildSourceBuilding(activeState.activeTown, activeState.activeTownPos);
            ActionNode actionBuildSourceBuilding = new ActionNode(buildSourceBuilding, this);
            ChangeSourcesActionNode addMillAction = new ChangeSourcesActionNode(new ActionSource(buildSourceBuilding, PriceKind.BMill), this);
            ChangeSourcesActionNode addStepherdAction = new ChangeSourcesActionNode(new ActionSource(buildSourceBuilding, PriceKind.BStepherd), this);
            ChangeSourcesActionNode addQuarryAction = new ChangeSourcesActionNode(new ActionSource(buildSourceBuilding, PriceKind.BQuarry), this);
            ChangeSourcesActionNode addSawAction = new ChangeSourcesActionNode(new ActionSource(buildSourceBuilding, PriceKind.BSaw), this);
            ChangeSourcesActionNode addMineAction = new ChangeSourcesActionNode(new ActionSource(buildSourceBuilding, PriceKind.BMine), this);

            DecisionBinaryNode isThatMill = new DecisionBinaryNode(addMillAction, addStepherdAction, () => { return activeState.activeTown.GetIHexa(activeState.activeTownPos).GetKind() == HexaKind.Cornfield; });
            DecisionBinaryNode isThatSaw = new DecisionBinaryNode(addSawAction, isThatMill, () => { return activeState.activeTown.GetIHexa(activeState.activeTownPos).GetKind() == HexaKind.Forest; });
            DecisionBinaryNode isThatQuarry = new DecisionBinaryNode(addQuarryAction, isThatSaw, () => { return activeState.activeTown.GetIHexa(activeState.activeTownPos).GetKind() == HexaKind.Stone; });
            DecisionBinaryNode isThatMine = new DecisionBinaryNode(addMineAction, isThatQuarry, () => { return activeState.activeTown.GetIHexa(activeState.activeTownPos).GetKind() == HexaKind.Mountains; });

            HasSourcesNode haveSourcesForSourceBuilding = new HasSourcesNode(actionBuildSourceBuilding, isThatMine, () => { return GetPriceForSourceBuilding(activeState.activeTown, activeState.activeTownPos); }, map);
            DecisionBinaryNode hasPlayerTargetSourceKind = new DecisionBinaryNode(haveSourcesForSourceBuilding, EA, () => { return ai.GetSourceNormal()[(int)activeState.activeTown.GetIHexa(activeState.activeTownPos).GetKind()] == 0; });
            DecisionBinaryNode localRoot = new DecisionBinaryNode(haveSourcesForSourceBuilding, hasPlayerTargetSourceKind, () => activeState.activeTown.GetIHexa(activeState.activeTownPos).GetStartSource() >= 12);

            return localRoot;
        }