コード例 #1
0
        public void Run()
        {
            CurrentGame = new GameCore();

            Game.StartGame(CurrentGame);

            CurrentGame.TurnCompleted += Game_TurnCompleted;
            CurrentGame.GameClosed    += Game_GameClosed;

            mapStateOutput  = new MapStateOutput();
            messageOutput   = new MessageOutput(Console.BufferWidth);
            gameStateOutput = new GameStateOutput();
            InputMap        = new InputMapper();

            CurrentGame.StartGame();
            gameRunning = true;

            while (gameRunning)
            {
                ConsoleKeyInfo input = Console.ReadKey(true);

                var action = InputMap.GetActionForKey(input);

                if (action != null)
                {
                    action();
                }
            }
        }
コード例 #2
0
        public GameStateOutput Predict(IEnumerable <GameStateOutput> gameStates, int index)
        {
            var currentState = gameStates.ElementAt(index);

            if (index <= 1)
            {
                return(currentState);
            }

            var score = from r in gameStates.ElementAt(index - 1).ScorePredictions.Find(Constants.MappingTablePredctionName).Bind(x => x.Result)
                        from s in currentState.ScorePredictions.Find(Constants.MappingTablePredctionName).Map(x => x.Score)
                        select r == Result.Lose
                        ? (s == Score.Tiger ? Score.Dragon : Score.Tiger)
                        : s;

            GameStateOutput newState = currentState;

            return(score.Match(x =>
            {
                return new GameStateOutput
                (
                    index,
                    currentState.ActualScore,
                    currentState.BetScore,
                    currentState.ScorePredictions.Select(p => (p.Value.Name, p.Value.Score))
                    .Append((Constants.SameDiffPredictionName, x))
                    //.Append((Constants.InvertedSameDiffPredictionName, Helper.InvertScoreMapper(x)))
                );
            }, () => currentState));
        }