Beispiel #1
0
 public abstract void GetUsedInstrumentSlotInd(Game game, Resource receivedReceource, int points, OnInstrumentsToUseSelected onComplete);      // -1 if not using any.
Beispiel #2
0
 public override void GetUsedInstrumentSlotInd(Game game, Resource receivedReceource, int points, OnInstrumentsToUseSelected onComplete)
 {
     _turnView.SelectPlayer(game, _model);
     _turnView.ShowSelectInstruments(_model, receivedReceource, points);
     while (true)
     {
         System.Threading.Thread.Sleep(SleepTime);
         if (_turnView.SelectingInstrumentsDone)
         {
             onComplete(_turnView.InstrumentSlot0Used, _turnView.InstrumentSlot1Used, _turnView.InstrumentSlot2Used,
                        _turnView.Instrument4OnceUsed, _turnView.Instrument3OnceUsed, _turnView.Instrument2OnceUsed);
             return;
         }
     }
 }
    public override void GetUsedInstrumentSlotInd(Game game, Resource receivedReceource, int points, OnInstrumentsToUseSelected onComplete)
    {
        bool useSlot0     = !_model.InstrumentsSlot1Used && _model.InstrumentsCountSlot1 > 0;
        bool useSlot1     = !_model.InstrumentsSlot2Used && _model.InstrumentsCountSlot2 > 0;
        bool useSlot2     = !_model.InstrumentsSlot3Used && _model.InstrumentsCountSlot3 > 0;
        bool useOnceSlot4 = _model.Top4Instruments != null && !_model.Top4Instruments.Card.TopUsed;
        bool useOnceSlot3 = _model.Top3Instruments != null && !_model.Top3Instruments.Card.TopUsed;
        bool useOnceSlot2 = _model.Top2Instruments != null && !_model.Top2Instruments.Card.TopUsed;

        useSlot0     &= GetRandomBool();
        useSlot1     &= GetRandomBool();
        useSlot2     &= GetRandomBool();
        useOnceSlot4 &= GetRandomBool();
        useOnceSlot3 &= GetRandomBool();
        useOnceSlot2 &= GetRandomBool();
        onComplete(useSlot0, useSlot1, useSlot2, useOnceSlot4, useOnceSlot3, useOnceSlot2);
    }
Beispiel #4
0
    public override void GetUsedInstrumentSlotInd(Game game, Resource receivedRecource, int points, OnInstrumentsToUseSelected onComplete)
    {
        int decision = GetDecisionInd(DecisionType.SelectInstruments, game, _model, _instrumentsDecider, null, points, receivedRecource, WhereToGo.None);

        int availableSlot1Instruments = _model.InstrumentsSlot1Used ? 0 : _model.InstrumentsCountSlot1;
        int availableSlot2Instruments = _model.InstrumentsSlot2Used ? 0 : _model.InstrumentsCountSlot2;
        int availableSlot3Instruments = _model.InstrumentsSlot3Used ? 0 : _model.InstrumentsCountSlot3;
        int availableTop4Instruments  = (_model.Top4Instruments != null && !_model.Top4Instruments.Card.TopUsed) ? 4 : 0;
        int availableTop3Instruments  = (_model.Top3Instruments != null && !_model.Top3Instruments.Card.TopUsed) ? 3 : 0;
        int availableTop2Instruments  = (_model.Top2Instruments != null && !_model.Top2Instruments.Card.TopUsed) ? 2 : 0;

        bool useSlot1     = availableSlot1Instruments > 0;
        bool useSlot2     = availableSlot2Instruments > 0;
        bool useSlot3     = availableSlot3Instruments > 0;
        bool useOnceSlot4 = availableTop4Instruments > 0;
        bool useOnceSlot3 = availableTop3Instruments > 0;
        bool useOnceSlot2 = availableTop2Instruments > 0;

        int cost = Game.GetResourceCost(receivedRecource);
        int receivedFromDices    = points / cost;
        int notUsedPoints        = points - receivedFromDices * cost;
        int maxInstrumentsPoints = availableSlot1Instruments + availableSlot2Instruments + availableSlot3Instruments
                                   + availableTop4Instruments + availableTop3Instruments + availableTop2Instruments;

        int pointsForDecision;

        switch (decision)
        {
        default:
        case 0: pointsForDecision = 0; break;

        case 1: pointsForDecision = cost - notUsedPoints; break;

        case 2: pointsForDecision = 2 * cost - notUsedPoints; break;

        case 3: pointsForDecision = 3 * cost - notUsedPoints; break;
        }

        int currPoints = maxInstrumentsPoints;

        if (availableTop4Instruments > 0 && pointsForDecision <= currPoints - availableTop4Instruments)
        {
            currPoints  -= availableTop4Instruments;
            useOnceSlot4 = false;
        }
        if (availableTop3Instruments > 0 && pointsForDecision <= currPoints - availableTop3Instruments)
        {
            currPoints  -= availableTop3Instruments;
            useOnceSlot3 = false;
        }
        if (availableTop2Instruments > 0 && pointsForDecision <= currPoints - availableTop2Instruments)
        {
            currPoints  -= availableTop2Instruments;
            useOnceSlot2 = false;
        }
        if (availableSlot1Instruments > 0 && pointsForDecision <= currPoints - availableSlot1Instruments)
        {
            currPoints -= availableSlot1Instruments;
            useSlot1    = false;
        }
        if (availableSlot2Instruments > 0 && pointsForDecision <= currPoints - availableSlot2Instruments)
        {
            currPoints -= availableSlot2Instruments;
            useSlot2    = false;
        }
        if (availableSlot3Instruments > 0 && pointsForDecision <= currPoints - availableSlot3Instruments)
        {
            currPoints -= availableSlot3Instruments;
            useSlot3    = false;
        }


        onComplete(useSlot1, useSlot2, useSlot3, useOnceSlot4, useOnceSlot3, useOnceSlot2);
    }
Beispiel #5
0
    public override void GetUsedInstrumentSlotInd(Game game, Resource receivedRecource, int points, OnInstrumentsToUseSelected onComplete)
    {
        int availableSlot1Instruments = _model.GetAvailableInstruments(0);
        int availableSlot2Instruments = _model.GetAvailableInstruments(1);
        int availableSlot3Instruments = _model.GetAvailableInstruments(2);
        int availableTop4Instruments  = _model.GetAvailableOnceInstruments(0);
        int availableTop3Instruments  = _model.GetAvailableOnceInstruments(1);
        int availableTop2Instruments  = _model.GetAvailableOnceInstruments(2);

        bool useSlot1     = availableSlot1Instruments > 0;
        bool useSlot2     = availableSlot2Instruments > 0;
        bool useSlot3     = availableSlot3Instruments > 0;
        bool useOnceSlot4 = availableTop4Instruments > 0;
        bool useOnceSlot3 = availableTop3Instruments > 0;
        bool useOnceSlot2 = availableTop2Instruments > 0;

        int        cost = Game.GetResourceCost(receivedRecource);
        int        receivedFromDices = points / cost;
        List <int> optionInds        = new List <int> ();

        int notUsedPoints        = points - receivedFromDices * cost;
        int maxInstrumentsPoints = availableSlot1Instruments + availableSlot2Instruments + availableSlot3Instruments
                                   + availableTop4Instruments + availableTop3Instruments + availableTop2Instruments;

        optionInds.Add(0);           // Option to add 0 resource.
        if (maxInstrumentsPoints >= cost - notUsedPoints)
        {
            optionInds.Add(1);              // Option to add 1 resource.
        }
        if (maxInstrumentsPoints >= 2 * cost - notUsedPoints)
        {
            optionInds.Add(2);              // Option to add 2 resources.
        }
        if (maxInstrumentsPoints >= 3 * cost - notUsedPoints)
        {
            optionInds.Add(3);              // Option to add max and not less than 3 resources.
        }
        int[] inputs = new int[GetResourceFromInstrumentsInputsCount];
        int   i      = 0;

        inputs [i] = game.TurnInd; i++;
        inputs [i] = cost; i++;
        inputs [i] = Indicator(receivedRecource == Resource.Food); i++;
        inputs [i] = Indicator(receivedRecource == Resource.Forest); i++;
        inputs [i] = Indicator(receivedRecource == Resource.Clay); i++;
        inputs [i] = Indicator(receivedRecource == Resource.Stone); i++;
        inputs [i] = Indicator(receivedRecource == Resource.Gold); i++;
        inputs [i] = availableSlot1Instruments + availableSlot2Instruments + availableSlot3Instruments; i++;
        inputs [i] = availableTop4Instruments + availableTop3Instruments + availableTop2Instruments; i++;
        inputs [i] = _model.GetResourceCount(receivedRecource); i++;

        int decision = _resourceFromInstrumentsDecider.GetDecision(inputs, optionInds);
        int pointsForDecision;

        switch (decision)
        {
        default:
        case 0: pointsForDecision = 0; break;

        case 1: pointsForDecision = cost - notUsedPoints; break;

        case 2: pointsForDecision = 2 * cost - notUsedPoints; break;

        case 3: pointsForDecision = 3 * cost - notUsedPoints; break;
        }

        int currPoints = maxInstrumentsPoints;

        if (availableTop4Instruments > 0 && pointsForDecision <= currPoints - availableTop4Instruments)
        {
            currPoints  -= availableTop4Instruments;
            useOnceSlot4 = false;
        }
        if (availableTop3Instruments > 0 && pointsForDecision <= currPoints - availableTop3Instruments)
        {
            currPoints  -= availableTop3Instruments;
            useOnceSlot3 = false;
        }
        if (availableTop2Instruments > 0 && pointsForDecision <= currPoints - availableTop2Instruments)
        {
            currPoints  -= availableTop2Instruments;
            useOnceSlot2 = false;
        }
        if (availableSlot1Instruments > 0 && pointsForDecision <= currPoints - availableSlot1Instruments)
        {
            currPoints -= availableSlot1Instruments;
            useSlot1    = false;
        }
        if (availableSlot2Instruments > 0 && pointsForDecision <= currPoints - availableSlot2Instruments)
        {
            currPoints -= availableSlot2Instruments;
            useSlot2    = false;
        }
        if (availableSlot3Instruments > 0 && pointsForDecision <= currPoints - availableSlot3Instruments)
        {
            currPoints -= availableSlot3Instruments;
            useSlot3    = false;
        }

        onComplete(useSlot1, useSlot2, useSlot3, useOnceSlot4, useOnceSlot3, useOnceSlot2);
    }