private BombDecisionTree DisarmingDecisionTree(LearningModel model, string idBomb, Disarming step1, Disarming step2, Disarming step3)
        {
            switch (int.Parse(idBomb))
            {
            case 1:
                _typeBomb = BombTypes.Ball;
                break;

            case 2:
                _typeBomb = BombTypes.Demolition;
                break;

            case 3:
                _typeBomb = BombTypes.DemolitionExplosive;
                break;

            case 4:
                _typeBomb = BombTypes.Explosive;
                break;

            case 5:
                _typeBomb = BombTypes.Mine;
                break;
            }

            var result = model.Model.Predict(new BombDecisionTree
            {
                bomb = _typeBomb,
                FirstStageDisarming  = step1,
                SecondStageDisarming = step2,
                ThirdStageDisarming  = step3
            });

            return(result);
        }
Exemplo n.º 2
0
        public static IBomb CreateBomb(BombTypes bombType)
        {
            switch (bombType)
            {
            case BombTypes.Demolition:
                return(new DemolitionBomb());

            case BombTypes.Explosive:
                return(new ExplosiveBomb());

            case BombTypes.DemolitionExplosive:
                return(new DemolitionExplosiveBomb());

            case BombTypes.Ball:
                return(new BallBomb());

            case BombTypes.Mine:
                return(new Mine());

            default:
                return(null);
            }
        }
        public async Task <Tuple <Disarming, Disarming, Disarming> > GetDisarmingProcedure(int beepsLevel)
        {
            await _learnTreeTask;
            var   result = new Disarming[3];

            switch (beepsLevel)
            {
            case 1:
                _typeBomb = BombTypes.Ball;
                break;

            case 2:
                _typeBomb = BombTypes.Demolition;
                break;

            case 3:
                _typeBomb = BombTypes.DemolitionExplosive;
                break;

            case 4:
                _typeBomb = BombTypes.Explosive;
                break;

            case 5:
                _typeBomb = BombTypes.Mine;
                break;
            }

            var _result = _model.Model.Predict(new BombDecisionTree
            {
                bomb = _typeBomb
            });
            var _resultStr = _result.ToString();

            if (String.Compare(_resultStr, "true") == 1)
            {
                switch (beepsLevel)
                {
                case 0:
                    result[0] = Disarming.CutControlWire;
                    result[1] = Disarming.CutYellowWire;
                    result[2] = Disarming.CutRedWire;
                    break;

                case 1:
                    result[0] = Disarming.CutBlueWire;
                    result[1] = Disarming.CutGreenWire;
                    result[2] = Disarming.CutRedWire;
                    break;

                case 2:
                    result[0] = Disarming.CutGreenWire;
                    result[1] = Disarming.CutControlWire;
                    result[2] = Disarming.CutYellowWire;
                    break;

                case 3:
                    result[0] = Disarming.CutRedWire;
                    result[1] = Disarming.CutGreenWire;
                    result[2] = Disarming.CutBlueWire;
                    break;

                case 4:
                    result[0] = Disarming.CutRedWire;
                    result[1] = Disarming.CutGreenWire;
                    result[2] = Disarming.CutBlueWire;
                    break;
                }
            }

            return(Tuple.Create(result[0], result[1], result[2]));
        }