Exemplo n.º 1
0
 public Intervals(MainModel main, InputViewVM input, Score.Score score)
 {
     this._main  = main;
     this._input = input;
     this._score = score;
     _random     = new Random();
     _timeLeft   = _time;
 }
Exemplo n.º 2
0
 public BoardDirector(IBoardStrategy strategy, int level, Score.Score score, Position spaceShipPosition, IList <Bullet> bullets)
 {
     _strategy          = strategy;
     _level             = level;
     _score             = score;
     _spaceShipPosition = spaceShipPosition;
     _bullets           = bullets;
 }
Exemplo n.º 3
0
        public override void Initialize()
        {
            heightmapKey  = "HM" + levelAsset;
            texturemapKey = "TM" + levelAsset;
            modelmapKey   = "MM" + levelAsset;
            scoremapKey   = "SM" + levelAsset;

            // Camera
            camStartPos = new Vector3(0.0f, 40.0f, 0.0f);
            camSpeed    = 50.0f;
            devCamOn    = true;
            cam         = new Camera.DevelopCamera(camStartPos, camSpeed, Game.GraphicsDevice);
            if (Game.Services.GetService(typeof(Camera.Camera)) == null)
            {
                Game.Services.AddService(typeof(Camera.Camera), cam);
            }

            //Add the level service
            if (Game.Services.GetService(typeof(States.Level)) == null)
            {
                Game.Services.AddService(typeof(States.Level), this);
            }
            else
            {
                Game.Services.RemoveService(typeof(States.Level));
                Game.Services.AddService(typeof(States.Level), this);
            }

            // Models
            models = new List <Models.LFModel>();

            //Set water
            waveKey       = "wave";
            baseWaterKey  = "water";
            baseWaterRowX = 10;
            baseWaterRowY = 10;
            amountWaves   = 400;

            skyTextureKey = "sky";

            if (this.timeScore == 0)
            {
                throw new NotImplementedException("Initialise the timeScore variable in Level's subclass.");
            }
            this.collectablesFound = 0;

            // Water
            waterLevel   = 4.5f;
            waterSizeMod = -3;

            worldMatrix = Matrix.CreateTranslation(0, 0, 0);
            //Create the terrain
            terrain = new Terrain(Game, heightmapKey, texturemapKey, this);
            Game.Components.Add(terrain);

            //Make a terrain service
            if (Game.Services.GetService(typeof(Terrain)) != null)
            {
                Game.Services.RemoveService(typeof(Terrain));
            }
            Game.Services.AddService(typeof(Terrain), terrain);

            score = new Score.Score(Game.Assets.Load <Texture2D>(scoremapKey), terrain);

            base.Initialize();
        }
Exemplo n.º 4
0
 public EnemyHardVisitor(Score.Score score) : base(score)
 {
     FileLogger.Log("Hard Visitor pattern: created");
 }
Exemplo n.º 5
0
        public override PlayerTask GetMove(SabberStoneCoreAi.POGame.POGame poGame)
        {
            Score.Score s = null;
            switch (poGame.CurrentPlayer.HeroClass)
            {
            case SabberStoneCore.Enums.CardClass.SHAMAN:
                s = midrScore;
                break;

            case SabberStoneCore.Enums.CardClass.WARRIOR:
                s = myScore;
                break;

            case SabberStoneCore.Enums.CardClass.MAGE:
                s = contrScore;
                break;

            default:
                s = myScore;
                break;
            }

            List <PlayerTask> options  = poGame.CurrentPlayer.Options();
            float             maxScore = Single.MinValue;
            PlayerTask        best     = options[0];

            foreach (PlayerTask task in options)
            {
                //for each task, that is not giving up or ending the turn
                if (task.PlayerTaskType != PlayerTaskType.CONCEDE && task.PlayerTaskType != PlayerTaskType.END_TURN)
                {
                    //simulate the choice of that task numSim times
                    try
                    {
                        Dictionary <PlayerTask, POGame.POGame> dic = poGame.Simulate(new List <PlayerTask> {
                            task
                        });
                        //set controller for the Scores
                        s.Controller = dic[task].CurrentPlayer;
                        //get the score with the rate function

                        if (s.Rate() > maxScore)
                        {
                            maxScore = s.Rate();
                            best     = task;
                        }
                    }
                    catch (Exception e)
                    {
                        continue;
                    }
                }
            }

            //Console.WriteLine(best.FullPrint());
            if (best == null)
            {
                best = options[0];
            }
            return(best);
        }
Exemplo n.º 6
0
        public override void Initialize()
        {
            heightmapKey = "HM" + levelAsset;
            texturemapKey = "TM" + levelAsset;
            modelmapKey = "MM" + levelAsset;
            scoremapKey = "SM" + levelAsset;

            // Camera
            camStartPos = new Vector3(0.0f, 40.0f, 0.0f);
            camSpeed = 50.0f;
            devCamOn = true;
            cam = new Camera.DevelopCamera(camStartPos, camSpeed, Game.GraphicsDevice);
            if (Game.Services.GetService(typeof(Camera.Camera)) == null)
                Game.Services.AddService(typeof(Camera.Camera), cam);

            //Add the level service
            if (Game.Services.GetService(typeof(States.Level)) == null) {
                Game.Services.AddService(typeof(States.Level), this);
            } else {
                Game.Services.RemoveService(typeof(States.Level));
                Game.Services.AddService(typeof(States.Level), this);
            }

            // Models
            models = new List<Models.LFModel>();

            //Set water
            waveKey = "wave";
            baseWaterKey = "water";
            baseWaterRowX = 10;
            baseWaterRowY = 10;
            amountWaves = 400;

            skyTextureKey = "sky";

            if (this.timeScore == 0) {
                throw new NotImplementedException("Initialise the timeScore variable in Level's subclass.");
            }
            this.collectablesFound = 0;

            // Water
            waterLevel = 4.5f;
            waterSizeMod = -3;

            worldMatrix = Matrix.CreateTranslation(0, 0, 0);
            //Create the terrain
            terrain = new Terrain(Game, heightmapKey, texturemapKey, this);
            Game.Components.Add(terrain);

            //Make a terrain service
            if (Game.Services.GetService(typeof(Terrain)) != null)
                Game.Services.RemoveService(typeof(Terrain));
            Game.Services.AddService(typeof(Terrain), terrain);

            score = new Score.Score(Game.Assets.Load<Texture2D>(scoremapKey), terrain);

            base.Initialize();
        }
Exemplo n.º 7
0
 public EnemyVisitorBase(Score.Score score)
 {
     Score = score;
 }
Exemplo n.º 8
0
 public void SetScoringMethod(Score.Score method)
 {
     Score = method;
 }
Exemplo n.º 9
0
 public EnemyMediumVisitor(Score.Score score) : base(score)
 {
     FileLogger.Log("Medium Visitor pattern: created");
 }
Exemplo n.º 10
0
        public override PlayerTask GetMove(SabberStoneCoreAi.POGame.POGame poGame)
        {
            //Rnd = new Random();
            PlayerTask        option;
            List <PlayerTask> options = poGame.CurrentPlayer.Options();



            /*
             * POGame.POGame gameClone = poGame.getCopy();//
             * List<PlayerTask> new_options = gameClone.CurrentPlayer.Options();//
             * int num = new_options.Count-1; //第幾種												 //sim.Add();
             * PlayerTask action = new_options[num];//
             *
             *
             * Console.WriteLine("----------一開始有------------");
             * foreach (PlayerTask a in new_options)
             * {
             *      Console.WriteLine(a);
             * }
             * Console.WriteLine("----------一開始有------------");
             * Console.WriteLine("共" + new_options.Count + "種選擇");
             * Console.WriteLine();
             *
             *
             * Console.WriteLine("-----------執行第" + num + "項後-----------");
             * Dictionary<PlayerTask, POGame.POGame> dic = gameClone.Simulate(new List<PlayerTask> { action });
             * Console.WriteLine("-----------執行第" + num + "項後-----------");
             * Console.WriteLine();
             *
             * gameClone = dic[action];//更新遊戲狀態
             *
             * List<PlayerTask> newnew_options = gameClone.CurrentPlayer.Options();
             *
             *
             * Console.WriteLine("----------最後有------------");
             * foreach (PlayerTask a in newnew_options)
             * {
             *      Console.WriteLine(a);
             * }
             * Console.WriteLine("----------最後有------------");
             * Console.WriteLine("共" + newnew_options.Count + "種選擇");
             * Console.WriteLine();
             *
             *
             * option = options[0];
             */
            //Program.game_percentage();

            Score.Score s = null;
            s = myScore;
            int r = Rnd.Next(options.Count);

            option = options[r];


            //	List<PlayerTask> sim = new List<PlayerTask>();
            //	sim.Add(option);
            //poGame.Simulate(sim);
            //result = my_Score(option);

            Dictionary <PlayerTask, POGame.POGame> dic = poGame.Simulate(new List <PlayerTask> {
                option
            });

            s.Controller = dic[option].CurrentPlayer;

            int initialPlayer = poGame.CurrentPlayer.PlayerId;

            if (s.Controller.Opponent.Hero.Health < 1)
            {
                won_num++;
            }
            Console.WriteLine("目前贏" + won_num + "場");


            //	Console.WriteLine(s.Rate());

            /*
             * for (int i = 0; i < options.Count; i++)
             * {
             *
             *
             *
             *      Console.WriteLine("-----------^-----------");
             *      Console.WriteLine("-----------" + options[i] + "----------");   //列出該回合所有可能的行動
             *
             * //	result = my_Score(options[i]);
             *      //is_change.Add(result);
             *      Console.WriteLine("得" + s.Rate() + "分");
             *      Console.WriteLine("-----------ˇ------------");
             *      Console.WriteLine();
             *
             * }*/
            /*
             * foreach(int change in is_change)
             * {
             *      Console.WriteLine(change);
             * }
             */
            foreach (PlayerTask option1 in options)
            {
                Console.WriteLine(option1);
            }
            Console.WriteLine("共" + options.Count + "種選擇");

            Console.WriteLine("選第" + r + "個");
            return(option);
        }
Exemplo n.º 11
0
        public override PlayerTask GetMove(SabberStoneCoreAi.POGame.POGame poGame)
        {
            DateTime start = DateTime.Now;

            List <PlayerTask> options = poGame.CurrentPlayer.Options();
            PlayerTask        t       = options[0];

            //thisMoveSeconds = Rnd.Next((int)remainingTurnSeconds / 10, (int)remainingTurnSeconds/5);//一手秒隨機
            //thisMoveSeconds = 10;

            Score.Score s = null;
            s = myScore;

            totalTime = 8;
            if (options.Count >= 20)
            {
                totalTime = totalTime * 1;
            }
            else if (options.Count < 20 && options.Count >= 10)
            {
                totalTime = totalTime * 0.75;
            }
            else if (options.Count < 10 && options.Count >= 5)
            {
                totalTime = totalTime * 0.5;
            }
            else if (options.Count < 5)
            {
                totalTime = totalTime * 0.25;
            }
            else
            {
                //
            }


            if (options.Count == 1)
            {
                t = options[0];
            }
            else
            {
                //t = do_MCTS.do_MCTS.GetBestAction_second(poGame, remainingSeconds / (Math.Max(options.Count - actionCount, 1)));
                //Console.WriteLine("動作有:" + options.Count + "個");
                t = do_MCTS.do_MCTS.GetBestAction_second(poGame, totalTime);
                //t = do_MCTS.do_MCTS.GetBestAction_second(poGame, thisMoveSeconds);
                //t = do_MCTS.do_MCTS.GetBestAction_iteration(poGame, 30);
            }

            double seconds = (DateTime.Now - start).TotalSeconds;            //這次動作幾秒

            //totalSecond += seconds;

            if (t.PlayerTaskType == PlayerTaskType.END_TURN)
            {
                //Console.WriteLine( "此回合共" + totalSecond + "秒");
                //totalSecond = 0;
                remainingSeconds = 15;
                actionCount      = 0;
            }
            else
            {
                remainingSeconds -= seconds;
                actionCount++;
            }

            /*
             * if (t.PlayerTaskType == PlayerTaskType.END_TURN)
             * {
             *      Console.WriteLine( "此回合共" + totalSecond + "秒");
             *      totalSecond = 0;
             *      remainingTurnSeconds = 75;
             *
             * }
             * else
             * {
             *
             *      remainingTurnSeconds -= seconds;
             *
             * }
             */

            return(t);
        }