Example #1
0
    static void Main(string[] args)
    {
        string[] inputs;
        MyGame   game = new MyGame();

        // game loop
        while (true)
        {
            #region INIT_VALUES
            game.ResetMaxIngredient();

            List <Order> allOrders   = new List <Order>();
            int          actionCount = int.Parse(Console.ReadLine()); // the number of spells and recipes in play
            for (int i = 0; i < actionCount; i++)
            {
                int bonus = 0;
                if (i == 0 && game.IsFirstTurn)
                {
                    bonus = 3;
                }
                if (i == 1 && game.IsFirstTurn)
                {
                    bonus = 2;
                }
                if (i == 2 && game.IsFirstTurn)
                {
                    bonus = 1;
                }

                inputs = Console.ReadLine().Split(' ');
                int    actionId   = int.Parse(inputs[0]); // the unique ID of this spell or recipe
                string actionType = inputs[1];            // in the first league: BREW; later: CAST, OPPONENT_CAST, LEARN, BREW

                int delta0 = int.Parse(inputs[2]);        // tier-0 ingredient change
                int delta1 = int.Parse(inputs[3]);        // tier-1 ingredient change
                int delta2 = int.Parse(inputs[4]);        // tier-2 ingredient change
                int delta3 = int.Parse(inputs[5]);        // tier-3 ingredient change

                int price = int.Parse(inputs[6]);         // the price in rupees if this is a potion

                if (actionType.Equals(Global.BREW) && (price >= Global.MIN_PRICE || game.MyWitch.IsLastPotionToBrew()))
                {
                    if (game.MaxIngredient0 < Math.Abs(delta0))
                    {
                        game.MaxIngredient0 = Math.Abs(delta0);
                    }
                    if (game.MaxIngredient1 < Math.Abs(delta1))
                    {
                        game.MaxIngredient1 = Math.Abs(delta1);
                    }
                    if (game.MaxIngredient2 < Math.Abs(delta2))
                    {
                        game.MaxIngredient2 = Math.Abs(delta2);
                    }
                    if (game.MaxIngredient3 < Math.Abs(delta3))
                    {
                        game.MaxIngredient3 = Math.Abs(delta3);
                    }

                    // DebugLogs.WriteMaxIngredientsNeeded(game);
                }

                int  tomeIndex  = int.Parse(inputs[7]); // in the first two leagues: always 0; later: the index in the tome if this is a tome spell, equal to the read-ahead tax
                int  taxCount   = int.Parse(inputs[8]); // in the first two leagues: always 0; later: the amount of taxed tier-0 ingredients you gain from learning this spell
                bool castable   = inputs[9] != "0";     // in the first league: always 0; later: 1 if this is a castable player spell
                bool repeatable = inputs[10] != "0";    // for the first two leagues: always 0; later: 1 if this is a repeatable player spell

                Order o = new Order(actionId, actionType, delta0, delta1, delta2, delta3, price + bonus, tomeIndex, taxCount, castable, repeatable);

                allOrders.Add(o);
            }
            game.AddOrder(allOrders);

            game.MyWitch.MyInventory = new Inventory();
            inputs = Console.ReadLine().Split(' ');
            game.MyWitch.MyInventory.Ingredient0 = int.Parse(inputs[0]); // tier-0 ingredients in inventory
            game.MyWitch.MyInventory.Ingredient1 = int.Parse(inputs[1]);
            game.MyWitch.MyInventory.Ingredient2 = int.Parse(inputs[2]);
            game.MyWitch.MyInventory.Ingredient3 = int.Parse(inputs[3]);
            game.MyWitch.MyInventory.Score       = int.Parse(inputs[4]); // amount of rupees

            game.OpponentWitch.MyInventory = new Inventory();
            inputs = Console.ReadLine().Split(' ');
            game.OpponentWitch.MyInventory.Ingredient0 = int.Parse(inputs[0]); // tier-0 ingredients in inventory
            game.OpponentWitch.MyInventory.Ingredient1 = int.Parse(inputs[1]);
            game.OpponentWitch.MyInventory.Ingredient2 = int.Parse(inputs[2]);
            game.OpponentWitch.MyInventory.Ingredient3 = int.Parse(inputs[3]);
            game.OpponentWitch.MyInventory.Score       = int.Parse(inputs[4]); // amount of rupees
            #endregion


            // Write an action using Console.WriteLine()
            // To debug: Console.Error.WriteLine("Debug messages...");

            string action = game.WhatToDo();

            Console.WriteLine(action);

            game.NewTurn();
        }
    }