示例#1
0
        override public void Perform(BasicAgent agent, Market market)
        {
            var food       = agent.QueryInventory("food");
            var metal      = agent.QueryInventory("metal");
            var tools      = agent.QueryInventory("tools");
            var need_tools = tools < 4;

            var hasFood  = food >= 1;
            var hasMetal = metal >= 1;

            //_consume(agent, "money", 0.5);//cost of living/business
            Consume(agent, "food", 1);//cost of living

            if (hasFood && hasMetal & need_tools)
            {
                //convert all metal into tools
                Consume(agent, "metal", metal);
                Produce(agent, "tools", metal);
            }
            else
            {
                //fined $2 for being idle
                //_consume(agent, "money", 2);
                if (!hasFood && agent.GetInventoryFull())
                {
                    //make_room_for(agent, "food", 2); stub todo needed?
                }
            }
        }
示例#2
0
        override public void Perform(BasicAgent agent, Market market)
        {
            var food  = agent.QueryInventory("food");
            var tools = agent.QueryInventory("tools");
            var ore   = agent.QueryInventory("ore");

            if (ore > 4)
            {
                ore = 4;
            }
            var metal     = agent.QueryInventory("metal");
            var needMetal = metal < 4;

            var hasFood  = food >= 1;
            var hasTools = tools >= 1;
            var hasOre   = ore >= 1;

            //_consume(agent, "money", 0.5);//cost of living/business
            Consume(agent, "food", 1);//cost of living

            if (hasFood && hasOre && needMetal)
            {
                if (hasTools)
                {
                    //convert all ore into metal, consume 1 food, break tools with 10% chance
                    Consume(agent, "ore", ore);
                    Consume(agent, "food", 1);
                    Consume(agent, "tools", 1, 0.1);
                    Produce(agent, "metal", ore);
                }
                else
                {
                    //convert up to 2 ore into metal, consume 1 food
                    var max = agent.QueryInventory("ore");
                    if (max > 2)
                    {
                        max = 2;
                    }
                    Consume(agent, "ore", max);
                    Consume(agent, "food", 1);
                    Produce(agent, "metal", max);
                }
            }
            else
            {
                //fined $2 for being idle
                //_consume(agent, "money", 2);
                if (!hasFood && agent.GetInventoryFull())
                {
                    //make_room_for(agent, "food", 2);
                }
            }
        }
示例#3
0
        override public void Perform(BasicAgent agent, Market market)
        {
            var food     = agent.QueryInventory("food");
            var hasFood  = food >= 1;
            var work     = agent.QueryInventory("work");
            var needWork = work < 1;

            Consume(agent, "food", 1);
            //_consume(agent, "money", 0.5);//cost of living/business

            if (needWork)
            {
                Produce(agent, "work", 1);
            }
        }
示例#4
0
        override public void Perform(BasicAgent agent, Market market)
        {
            var wood     = agent.QueryInventory("wood");
            var tools    = agent.QueryInventory("tools");
            var food     = agent.QueryInventory("food");
            var needFood = food < 10;
            var work     = agent.QueryInventory("work");

            var hasWood  = wood >= 1;
            var hasTools = tools >= 1;
            var hasWork  = work >= 1;

            //_consume(agent, "money", 0.5);//cost of living/business

            if (needFood)
            {
                if (hasWood && hasTools && hasWork)
                {
                    //produce 4 food, consume 1 wood, break tools with 10% chance
                    Consume(agent, "wood", 1, 1);
                    Consume(agent, "tools", 1, 0.1);
                    Consume(agent, "work", 1, 1);
                    Produce(agent, "food", 6, 1);
                }
                else if (hasWood && !hasTools && hasWork)
                {
                    //produce 2 food, consume 1 wood
                    Consume(agent, "wood", 1, 1);
                    Consume(agent, "work", 1, 1);
                    Produce(agent, "food", 3, 1);
                }
                else //no wood
                {
                    //produce 1 food,
                    Produce(agent, "food", 1, 1);
                }
            }
            else
            {
                //fined $2 for being idle
                //_consume(agent, "money", 2);
            }
        }
示例#5
0
        override public void Perform(BasicAgent agent, Market market)
        {
            var food     = agent.QueryInventory("food");
            var tools    = agent.QueryInventory("tools");
            var wood     = agent.QueryInventory("wood");
            var needWood = wood < 4;

            var hasFood  = food >= 1;
            var hasTools = tools >= 1;

            //_consume(agent, "money", 0.5);//cost of living/business
            Consume(agent, "food", 1);//cost of living

            if (hasFood && needWood)
            {
                if (hasTools)
                {
                    //produce 2 wood, consume 1 food, break tools with 10% chance
                    Consume(agent, "food", 1);
                    Consume(agent, "tools", 1, 0.1);
                    Produce(agent, "wood", 2);
                }
                else
                {
                    //produce 1 wood, consume 1 food
                    Consume(agent, "food", 1);
                    Produce(agent, "wood", 1);
                }
            }
            else
            {
                //fined $2 for being idle
                //_consume(agent, "money", 2);
                if (!hasFood && agent.GetInventoryFull())
                {
                    //make_room_for(agent, "food", 2);
                }
            }
        }