예제 #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 has_food  = food >= 1;
            var has_metal = metal >= 1;

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

            if (has_food && has_metal & 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 (!has_food && agent.get_inventoryFull())
                {
                    //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 need_metal = metal < 4;

            var has_food  = food >= 1;
            var has_tools = tools >= 1;
            var has_ore   = ore >= 1;

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

            if (has_food && has_ore && need_metal)
            {
                if (has_tools)
                {
                    //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 (!has_food && agent.get_inventoryFull())
                {
                    //make_room_for(agent, "food", 2);
                }
            }
        }
예제 #3
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 need_wood = wood < 4;

            var has_food  = food >= 1;
            var has_tools = tools >= 1;

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

            if (has_food && need_wood)
            {
                if (has_tools)
                {
                    //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 (!has_food && agent.get_inventoryFull())
                {
                    //make_room_for(agent, "food", 2);
                }
            }
        }