Ejemplo n.º 1
0
        public override void UpdateMoveStateForStep(string input, BotMoveState moveState)
        {
            var attckMove = moveState.AttacksAvailable[moveState.CurrentAttackMoveId - 1];
            var sufficientTradeTokensToWin = input == "1";

            if (sufficientTradeTokensToWin)
            {
                // target wins by virtue of spent trade tokens
                // bot spends none
                // target spends whats needed to tie (as defender wins)
                attckMove.TargetSpentMilitaryTradeTokensThisTurn = _powerDelta;
                attckMove.BotSpentMilitaryTradeTokensThisTurn    = 0;
                attckMove.BotIsWinning = false;
            }
            else
            {
                // bot wins
                // target spends no trade tokens
                // bot spends only what is needed to gain a +1 victory
                var botPowerLessTokens = attckMove.ComputedBotAttackPowerForTurn - moveState.TradeTokensAvailable[FocusType.Military];
                var botTokensRequired  = Math.Max(0, (attckMove.AttackTargetPowerWithoutTradeTokens + 1) - botPowerLessTokens);
                attckMove.TargetSpentMilitaryTradeTokensThisTurn = 0;
                attckMove.BotSpentMilitaryTradeTokensThisTurn    = botTokensRequired;
                attckMove.BotIsWinning = true;
            }
        }
        public void UpdateBaseEconomyGameStateForMove(BotMoveState movesState, BotGameState botGameStateService, int supportedCaravans)
        {
            var onRouteCaravans = 0;

            for (var tradecaravan = 0; tradecaravan < supportedCaravans; tradecaravan++)
            {
                var movingCaravan = movesState.TradeCaravansAvailable[tradecaravan];
                if (movingCaravan.CaravanDestinationType == CaravanDestinationType.CityState)
                {
                    if (!botGameStateService.CityStateDiplomacyCardsHeld.Contains(movingCaravan.CaravanCityStateDestination))
                    {
                        // TODO: add city state diplomacy card to city state diplomancy cards collection (if not visited)
                        botGameStateService.CityStateDiplomacyCardsHeld.Add(movingCaravan.CaravanCityStateDestination);
                    }
                }
                else if (movingCaravan.CaravanDestinationType == CaravanDestinationType.RivalCity)
                {
                    if (!botGameStateService.VisitedPlayerColors.Contains(movingCaravan.CaravanRivalCityColorDestination))
                    {
                        // TODO: add players diplomacy card (in order stated in rules) to rival diplomacy cards collection
                        botGameStateService.VisitedPlayerColors.Add(movingCaravan.CaravanRivalCityColorDestination);
                    }
                }
                else
                {
                    onRouteCaravans += 1;
                }
            }

            botGameStateService.SupportedCaravanCount = movesState.SupportedCaravanCount;
            botGameStateService.CaravansOnRouteCount  = onRouteCaravans;
            botGameStateService.TradeTokens           = new Dictionary <FocusType, int>(movesState.TradeTokensAvailable);
        }
        public override void UpdateMoveStateForStep(string input, BotMoveState moveState)
        {
            // TODO: we need natural wonders for game
            //       currently hard wired!

            var attckMove = moveState.AttacksAvailable[moveState.CurrentAttackMoveId - 1];

            switch (Convert.ToInt32(input))
            {
            case 1:
                moveState.ControlledNaturalWonders.Add("Mt. Everest");
                moveState.NaturalWonderTokensControlledThisTurn = 1;
                attckMove.HasStolenNaturalWonder = true;
                break;

            case 2:
                moveState.ControlledNaturalWonders.Add("Gran Mesa");
                moveState.NaturalWonderTokensControlledThisTurn = 1;
                attckMove.HasStolenNaturalWonder = true;
                break;

            default:
                moveState.NaturalWonderTokensControlledThisTurn = 0;
                break;
            }
        }
        public string BuildGeneralisedCultureMoveSummary(string currentSummary, BotMoveState movesState)
        {
            StringBuilder sb = new StringBuilder(currentSummary);

            if (movesState.CityControlTokensPlacedThisTurn > 0)
            {
                sb.Append($"I updated my game state to show that I placed {movesState.CityControlTokensPlacedThisTurn} control token(s) next to my cities on the board\n");
            }
            if (movesState.TerritroyControlTokensPlacedThisTurn > 0)
            {
                sb.Append($"I updated my game state to show that I placed {movesState.TerritroyControlTokensPlacedThisTurn} control token(s) next to my friendly territory on the board\n");
            }
            if (movesState.CultureTokensUsedThisTurn > 0)
            {
                sb.Append($"I updated my game state to show that I used {movesState.CultureTokensUsedThisTurn} culture trade token(s) I had available to me to facilitate this move\n");
            }
            if (movesState.CultureTokensUsedThisTurn < 0)
            {
                sb.Append($"I updated my game state to show that I recieved {Math.Abs(movesState.CultureTokensUsedThisTurn)} culture trade token(s) for not using all my available control token placements which I may use in the future\n");
            }
            if (movesState.NaturalResourceTokensControlledThisTurn > 0)
            {
                sb.Append($"I updated my game state to show that I controlled {movesState.NaturalResourceTokensControlledThisTurn} natural resources which I may use for future construction projects\n");
            }
            if (movesState.NaturalWonderTokensControlledThisTurn > 0)
            {
                sb.Append($"I updated my game state to show that I controlled the {string.Join(",", movesState.ControlledNaturalWonders)} natural wonder(s)\n");
                sb.Append($"As a result of controlling natural wonders on this turn I have recieved {movesState.NaturalWonderTokensControlledThisTurn} natural resources that I may use for future construction projects\n");
            }
            return(sb.ToString());
        }
Ejemplo n.º 5
0
        public override MoveStepActionData ExecuteAction(BotMoveState moveState)
        {
            var watertext = moveState.CanMoveOnWater ? "counting through water tiles where needed" : "avoiding counting through water tiles";

            return(new MoveStepActionData($"Please build me 1 new friendly city on a legal space that is within {moveState.BaseCityDistance} spaces of my friendly territory, {watertext}, using the following priority order;\nAdjacent to the most natural wonder and/or resource tokens\nA space with a barbarian spawn point\nHighest defense",
                                          new List <string>()));
        }
        public override void UpdateMoveStateForStep(string input, BotMoveState moveState)
        {
            // TODO: variance on the applicable types - currently hardwired for lvl 1 & 2

            var attckMove = moveState.AttacksAvailable[moveState.CurrentAttackMoveId - 1];

            switch (input)
            {
            case "1":
                attckMove.AttackTargetType = AttackTargetType.Barbarian;
                break;

            case "2":
                attckMove.AttackTargetType = AttackTargetType.RivalCity;
                break;

            case "3":
                attckMove.AttackTargetType = AttackTargetType.RivalControlToken;
                break;

            case "4":
                attckMove.AttackTargetType = AttackTargetType.CityState;
                break;

            case "5":
                attckMove.AttackTargetType = AttackTargetType.RivalCapitalCity;
                break;
            }
        }
Ejemplo n.º 7
0
        public override bool ShouldExecuteAction(BotMoveState moveState)
        {
            var attckMove = moveState.AttacksAvailable[moveState.CurrentAttackMoveId - 1];

            return(attckMove.BotIsWinning && (attckMove.AttackTargetType == AttackTargetType.RivalCity ||
                                              (attckMove.AttackTargetType == AttackTargetType.RivalCapitalCity && moveState.FriendlyCityCount > moveState.BotPurchasedWonders.Count)));
        }
Ejemplo n.º 8
0
        public override void UpdateMoveStateForStep(string input, BotMoveState moveState)
        {
            var attckMove = moveState.AttacksAvailable[moveState.CurrentAttackMoveId - 1];

            moveState.FriendlyCitiesAddedThisTurn++;
            moveState.TradeTokensAvailable[FocusType.Military] -= attckMove.BotSpentMilitaryTradeTokensThisTurn;
        }
Ejemplo n.º 9
0
        public BotMoveState CreateBasicMilitaryMoveState(BotGameState botGameStateCache, int baseRange, int basePower, int baseMaxTargetrPower, int noOfAttacks, int baseReinforcments, int baseReinforcemenstCost, int baseBarbarianBonus)
        {
            var _moveState = new BotMoveState();

            _moveState.BaseAttackPower             = basePower;
            _moveState.BaseAttackRange             = baseRange;
            _moveState.BaseMaxTargetPower          = baseMaxTargetrPower;
            _moveState.BaseReinforcementCount      = baseReinforcments;
            _moveState.BaseReinforcementAttackCost = baseReinforcemenstCost;
            _moveState.BaseBarbarianAttackBonus    = baseBarbarianBonus;

            _moveState.ActiveFocusBarForMove        = botGameStateCache.ActiveFocusBar;
            _moveState.TradeTokensAvailable         = new Dictionary <FocusType, int>(botGameStateCache.TradeTokens);
            _moveState.BotPurchasedWonders          = new List <WonderCardModel>(botGameStateCache.BotPurchasedWonders);
            _moveState.AllPurchasedWonders          = new List <WonderCardModel>(botGameStateCache.BotPurchasedWonders);
            _moveState.CityStatesDiplomacyCardsHeld = new List <CityStateModel>(botGameStateCache.CityStateDiplomacyCardsHeld);
            _moveState.ConqueredCityStateTokensHeld = new List <CityStateModel>(botGameStateCache.ConqueredCityStateTokensHeld);
            _moveState.ControlledNaturalWonders     = new List <string>(botGameStateCache.ControlledNaturalWonders);

            _moveState.FriendlyCityCount = botGameStateCache.FriendlyCityCount;

            for (int tc = 0; tc < noOfAttacks; tc++)
            {
                _moveState.AttacksAvailable.Add(tc, new AttackTargetMoveState());
            }
            return(_moveState);
        }
        /// <summary>
        /// Update move state with visited rival cities
        /// </summary>
        /// <param name="input">The code for the rival cities visited specified by the user</param>
        public override void UpdateMoveStateForStep(string input, BotMoveState moveState)
        {
            // TODO: what if the bot visited more than 1?

            var movingCaravan = moveState.TradeCaravansAvailable[moveState.CurrentCaravanIdToMove - 1];

            switch (Convert.ToInt32(input))
            {
            case 1:
                movingCaravan.CaravanRivalCityColorDestination = "Red";
                break;

            case 2:
                movingCaravan.CaravanRivalCityColorDestination = "Green";
                break;

            case 3:
                movingCaravan.CaravanRivalCityColorDestination = "Blue";
                break;

            default:
                movingCaravan.CaravanRivalCityColorDestination = "White";
                break;
            }

            var smallestpile = _smallestTradeTokenPileResolver.ResolveSmallestTokenPile(moveState.ActiveFocusBarForMove, moveState.TradeTokensAvailable);

            moveState.SmallestTradeTokenPileType          = smallestpile;
            movingCaravan.SmallestTradeTokenPileType      = smallestpile;
            moveState.TradeTokensAvailable[smallestpile] += BaseTradeTokensForRivalCityVisit;
        }
        public override bool ShouldExecuteAction(BotMoveState moveState)
        {
            // we only want to ask the user to place a wonder token on city if the bot can afford to purchase one in first plce
            // we only want to ask the user to place a wonder token on city if we have a city that has no wonders

            if (moveState.FriendlyCityCount <= moveState.BotPurchasedWonders.Count)
            {
                return(false);
            }

            var diplomacyPointsAvailable     = moveState.CityStatesDiplomacyCardsHeld.Count(x => x.Type == FocusType.Industry);
            var naturalWonderPointsAvailable = (moveState.ControlledNaturalWonders.Count * 2);
            var resourcePointsAvailable      = (moveState.NaturalResourcesToSpend * 2);
            var tradeTokensAvailable         = moveState.TradeTokensAvailable[FocusType.Industry];

            var productionPoints   = (moveState.BaseProductionPoints + diplomacyPointsAvailable + naturalWonderPointsAvailable + resourcePointsAvailable + tradeTokensAvailable);
            var unlockedWonders    = moveState.ActiveWonderCardDecks.UnlockedWonderCards.Select(x => x.Value);
            var cheapestWonderCost = unlockedWonders.Min(x => x.Cost);

            if (productionPoints >= cheapestWonderCost)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 12
0
        public override bool ShouldExecuteAction(BotMoveState moveState)
        {
            var totalTokensPlaced = moveState.CityControlTokensPlacedThisTurn + moveState.TerritroyControlTokensPlacedThisTurn;

            return((totalTokensPlaced > 0) &&
                   (moveState.NaturalResourceTokensControlledThisTurn < totalTokensPlaced));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Update move state with which natural natural wonders were controlled this turn
        /// </summary>
        /// <param name="input">The code for the natural wonders visited specified by the user</param>
        /// <param name="moveState">The current move state to work from</param>
        public override void UpdateMoveStateForStep(string input, BotMoveState moveState)
        {
            // TODO: we need natural wonders for game
            //       currently hard wired!
            //       bit of a hack for multiple just now to avoid a request loop - fine for 2 just now

            switch (Convert.ToInt32(input))
            {
            case 1:
                moveState.ControlledNaturalWonders.Add("Mt. Everest");
                moveState.NaturalWonderTokensControlledThisTurn = 1;
                break;

            case 2:
                moveState.ControlledNaturalWonders.Add("Gran Mesa");
                moveState.NaturalWonderTokensControlledThisTurn = 1;
                break;

            case 3:
                moveState.ControlledNaturalWonders.Add("Gran Mesa");
                moveState.ControlledNaturalWonders.Add("Mt. Everest");
                moveState.NaturalWonderTokensControlledThisTurn = 2;
                break;

            default:
                moveState.NaturalWonderTokensControlledThisTurn = 0;
                break;
            }
        }
        public override MoveStepActionData ExecuteAction(BotMoveState moveState)
        {
            var maxPlacements = moveState.BaseCityControlTokensToBePlaced + moveState.TradeTokensAvailable[FocusType.Culture];

            return(new MoveStepActionData($"Please place {maxPlacements} control tokens on spaces adjacent to any of my cities using the following placement priority rules:\nNatural wonder\nResource token\nVacant barbarian spawn point\nAdjacent to the most cities\nAdjacent to city closest to maturity\nHighest terrain difficulty\nFor each token that cannot be placed, I will recieve 1 culture trade token to be used in the future",
                                          new List <string>()));
        }
        public override MoveStepActionData ExecuteAction(BotMoveState moveState)
        {
            var caravanRef = _ordinalSuffixResolver.GetOrdinalSuffixWithInput(moveState.CurrentCaravanIdToMove);

            return(new MoveStepActionData($"Please remove my {caravanRef} trade caravan from the city and return it to my supply in preperation for its next journey",
                                          new List <string>()));
        }
        public string BuildGeneralisedIndustryMoveSummary(string currentSummary, BotMoveState moveState)
        {
            StringBuilder sb = new StringBuilder(currentSummary);

            if (moveState.WonderPurchasedThisTurn != null)
            {
                sb.Append($"I updated my game state to show that I purchased the world wonder {moveState.WonderPurchasedThisTurn.Name}, the token of which you placed on my stongest free city\n");
                sb.Append($"I facilitated this move with the following production capacity breakdown;\n");
                sb.Append($"Focus card base capacity: {moveState.BaseProductionPoints} production points\n");
                sb.Append($"Industry diplomacy cards retained bonus: {moveState.CityStatesDiplomacyCardsHeld.Count} held diplomacy cards worth {moveState.CityStatesDiplomacyCardsHeld.Count} production points\n");
                sb.Append($"Natural wonder resources retained bonus: {moveState.ControlledNaturalWonders.Count} held natural wonders worth {moveState.ControlledNaturalWonders.Count * 2} production points\n");
                sb.Append($"Natural resources points : {moveState.NaturalResourcesToSpend} held worth {moveState.NaturalResourcesToSpend * 2} production points, of which we spent {moveState.NaturalResourcesSpentThisTurn} resources\n");
                sb.Append($"Industry trade token points : {moveState.TradeTokensAvailable[FocusType.Industry]} held worth {moveState.TradeTokensAvailable[FocusType.Industry]} production points of which we spent {moveState.IndustryTokensUsedThisTurn} trade tokens\n");
                sb.Append($"Total production capacity available before purchase: {moveState.ComputedProductionCapacityForTurn} production points\n");
            }
            else
            {
                sb.Append($"I was unable to purchase a world wonder on this turn for the following reasons;\n");
                if (moveState.FriendlyCityCount <= moveState.BotPurchasedWonders.Count)
                {
                    sb.Append($"I do not have enough friendly cities without existing wonder tokens\n");
                }
                else
                {
                    sb.Append($"I do not have enough production capacity to purchase any of the unlocked wonders\n");
                }
            }

            if (moveState.HasPurchasedCityThisTurn)
            {
                sb.Append($"I updated my game state to show that I build 1 new city of which you placed on the board in a legal space\n");
            }

            return(sb.ToString());
        }
        public override MoveStepActionData ExecuteAction(BotMoveState moveState)
        {
            var options = Array.ConvertAll(Enumerable.Range(0, _reinforementsavailable + 1).ToArray(), ele => ele.ToString());

            return(new MoveStepActionData("How many control tokens did you manage to reinforce on the board?",
                                          options));
        }
        public override MoveStepActionData ExecuteAction(BotMoveState moveState)
        {
            var maxPlacements = moveState.BaseTerritoryControlTokensToBePlaced;

            return(new MoveStepActionData($"Please place {maxPlacements} control tokens on spaces adjacent to any of my friendly territory using the following placement priority rules:\nNatural wonder\nResource token\nVacant barbarian spawn point\nAdjacent to the most cities\nAdjacent to city closest to maturity\nHighest terrain difficulty",
                                          new List <string>()));
        }
Ejemplo n.º 19
0
 public override MoveStepActionData ExecuteAction(BotMoveState moveState)
 {
     return(new MoveStepActionData($"If the defending rival has {_powerDelta} miltary trade token(s) to spend in order to turn defeat into victory, please do so now.\nDid the defending rival have these trade tokens available to turn the tides of battle?",
                                   new List <string>()
     {
         "1. Yes", "2. No"
     }));
 }
Ejemplo n.º 20
0
        public override void UpdateMoveStateForStep(string input, BotMoveState moveState)
        {
            var attckMove = moveState.AttacksAvailable[moveState.CurrentAttackMoveId - 1];

            bool targetIdentified = input == "1";

            attckMove.IsTargetWithinRange = targetIdentified;
        }
Ejemplo n.º 21
0
        public override MoveStepActionData ExecuteAction(BotMoveState moveState)
        {
            var maxControlTokensToBePlaced = moveState.BaseCityControlTokensToBePlaced + moveState.TradeTokensAvailable[FocusType.Culture];
            var options = Array.ConvertAll(Enumerable.Range(0, maxControlTokensToBePlaced + 1).ToArray(), ele => ele.ToString());

            return(new MoveStepActionData("How many control tokens did you manage to place next to my cities on the board?",
                                          options));
        }
 public override MoveStepActionData ExecuteAction(BotMoveState moveState)
 {
     return(new MoveStepActionData("Did you manage to place my new city on the board legally?",
                                   new List <string>()
     {
         "1. Yes", "2. No"
     }));
 }
 public void UpdateBaseIndustryGameStateForMove(BotMoveState moveState, BotGameState botGameStateService)
 {
     botGameStateService.WonderCardDecks             = moveState.ActiveWonderCardDecks;
     botGameStateService.BotPurchasedWonders         = new List <WonderCardModel>(moveState.BotPurchasedWonders);
     botGameStateService.TradeTokens                 = new Dictionary <FocusType, int>(moveState.TradeTokensAvailable);
     botGameStateService.FriendlyCityCount          += moveState.FriendlyCitiesAddedThisTurn;
     botGameStateService.ControlledNaturalResources -= moveState.NaturalResourcesSpentThisTurn;
 }
        public override MoveStepActionData ExecuteAction(BotMoveState moveState)
        {
            var maxControlTokensToBePlaced = moveState.BaseTerritoryControlTokensToBePlaced;
            var options = Array.ConvertAll(Enumerable.Range(0, maxControlTokensToBePlaced + 1).ToArray(), ele => ele.ToString());

            return(new MoveStepActionData("How many control tokens did you manage to place next to my friendly territory on the board?",
                                          options));
        }
        public void UpdateBaseCultureGameStateForMove(BotMoveState movesState, BotGameState botGameStateService)
        {
            var totalTokensPlacedThisTurn = movesState.CityControlTokensPlacedThisTurn + movesState.TerritroyControlTokensPlacedThisTurn;

            botGameStateService.ControlledSpaces           += totalTokensPlacedThisTurn;
            botGameStateService.ControlledNaturalResources += (movesState.NaturalResourceTokensControlledThisTurn + movesState.NaturalWonderTokensControlledThisTurn);
            botGameStateService.ControlledNaturalWonders    = new List <string>(movesState.ControlledNaturalWonders);
            botGameStateService.TradeTokens = new Dictionary <FocusType, int>(movesState.TradeTokensAvailable);
        }
        public override bool ShouldExecuteAction(BotMoveState moveState)
        {
            var maxPlacements = moveState.BaseReinforcementCount;
            var attackcost    = moveState.AttacksAvailable.Count(x => x.Value.IsTargetWithinRange) * moveState.BaseReinforcementAttackCost;

            _reinforementsavailable = maxPlacements - attackcost;
            _reinforementsavailable = Math.Max(0, _reinforementsavailable);
            return(_reinforementsavailable > 0);
        }
Ejemplo n.º 27
0
        public override MoveStepActionData ExecuteAction(BotMoveState moveState)
        {
            var preplaced           = moveState.NaturalResourceTokensControlledThisTurn + moveState.NaturalWonderTokensControlledThisTurn;
            var maxTokensToBePlaced = (moveState.CityControlTokensPlacedThisTurn + moveState.TerritroyControlTokensPlacedThisTurn) - preplaced;
            var options             = Array.ConvertAll(Enumerable.Range(0, maxTokensToBePlaced + 1).ToArray(), ele => ele.ToString());

            return(new MoveStepActionData("How many natural resources did I manage to take control of this turn?",
                                          options));
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Take in the number of control tokens the user managed to place on the board next to bot cities
        /// Update move state with how many culture tokens were used to facilitate placements
        /// Update move state with how many culture tokens were recieved due to unused placements
        /// Update move state control tokens placed counter
        /// </summary>
        /// <param name="input">The number of control tokens placed next to cities</param>
        /// <param name="moveState">The current move state to work from & update</param>
        public override void UpdateMoveStateForStep(string input, BotMoveState moveState)
        {
            var cityControlTokensPlaced   = Convert.ToInt32(input);
            var cultureTokensUsedThisTurn = cityControlTokensPlaced - moveState.BaseCityControlTokensToBePlaced;

            moveState.CultureTokensUsedThisTurn = cultureTokensUsedThisTurn;
            moveState.TradeTokensAvailable[FocusType.Culture] -= cultureTokensUsedThisTurn;
            moveState.CityControlTokensPlacedThisTurn          = cityControlTokensPlaced;
        }
        private WonderCardModel GetWonderToPurchase(BotMoveState moveState)
        {
            var availableWonders   = moveState.ActiveWonderCardDecks.UnlockedWonderCards.Select(x => x.Value);
            var cheapestWonderCost = availableWonders.Min(x => x.Cost);
            var wondersToPurchase  = availableWonders.Where(x => x.Cost == cheapestWonderCost).ToList();
            var wonderToPurchase   = wondersToPurchase.ElementAt(_randomService.Next(wondersToPurchase.Count - 1));

            return(wonderToPurchase);
        }
        public override void UpdateMoveStateForStep(string input, BotMoveState moveState)
        {
            var attckMove    = moveState.AttacksAvailable[moveState.CurrentAttackMoveId - 1];
            var smallestpile = _smallestTradeTokenPileResolver.ResolveSmallestTokenPile(moveState.ActiveFocusBarForMove, moveState.TradeTokensAvailable);

            moveState.SmallestTradeTokenPileType = smallestpile;
            moveState.TradeTokensAvailable[moveState.SmallestTradeTokenPileType] += 1;
            moveState.TradeTokensAvailable[FocusType.Military] -= attckMove.BotSpentMilitaryTradeTokensThisTurn;
        }