Ejemplo n.º 1
0
    protected virtual void considerSell()
    {
        int ammountResource = Inventory[(int)Role];

        if (ammountResource <= 1)
        {
            return;
        }

        RTMarket resourceMarket = ((VillageSim)(Simulation.SimInstance)).Markets[(int)Role];

        // last price comes with how long it took to find. 0 trade days mean lower price.
        int searchDelay;
        //decimal resourcePrice = resourceMarket.getLastPrice(out searchDelay);

        decimal resourcePrice = resourceMarket._getLastPrice(out searchDelay) + 0.5m;

        // // old random offset from last price
        // int randomNum = rnd.Next(-3, 9);
        // if(randomNum < -1) {
        //     randomNum = -1;
        // }

        // random number cycles
        int randomNum = currentCycleValue - cycleOffset;

        currentCycleValue = (currentCycleValue + 1) % cycleSize;

        // decimal randomPrice = decimal.Divide(randomNum, 20) + resourcePrice - searchDelay*0.5m;
        decimal randomPrice = decimal.Divide(randomNum, 5) + resourcePrice - searchDelay * 0.5m;

        if (randomPrice < 0.2m)
        {
            randomPrice = 0.2m;
        }
        resourceMarket.placeOffer(this, ammountResource, randomPrice);
    }