コード例 #1
0
 public NextMovesCalculator(IPredictionBuilder predictionBuilder, IGetMoveWeight getMoveWeight)
 {
     _predictionBuilder = predictionBuilder;
     _getMoveWeight     = getMoveWeight;
 }
コード例 #2
0
        public void SetUp()
        {
            _moves = new List <List <Move> >
            {
                new List <Move>
                {
                    new Move
                    {
                        StartingPoint = new Cell {
                            X = 0, Y = 1
                        },
                        EndingPoint = new Cell {
                            X = 1, Y = 2
                        }
                    }
                }
            };

            _beats = new List <List <Move> >
            {
                new List <Move>
                {
                    new Move
                    {
                        StartingPoint = new Cell {
                            X = 0, Y = 1
                        },
                        EndingPoint = new Cell {
                            X = 2, Y = 3
                        }
                    }
                }
            };

            _beatCalc = new Mock <IPossibleBeatsCalc>();
            _beatCalc.Setup(beat => beat.GetPossibleBeats(It.IsAny <CellState[, ]>(), It.IsAny <Team>())).Returns(_beats);

            _moveCalc = new Mock <IPossibleMovesCalc>();
            _moveCalc.Setup(move => move.GetPossibleMoves(It.IsAny <CellState[, ]>(), It.IsAny <Team>())).Returns(_moves);

            _weigher = new Mock <IGetMoveWeight>();
            _weigher.Setup(w =>
                           w.CalculateMoveWeight(It.IsAny <List <Move> >(), It.IsAny <CellState[, ]>(), It.IsAny <CellState[, ]>(), It.IsAny <Team>(), true)).Returns((1, 1));

            string jsonData   = @"{
                'team': 'w',
                'field': [
                    ['.', 'b', '.', 'b', '.', 'b', '.', 'b'],
                    ['b', '.', 'b', '.', 'b', '.', 'b', '.'],
                    ['.', 'b', '.', 'b', '.', 'b', '.', 'b'],
                    ['.', '.', '.', '.', '.', '.', '.', '.'],
                    ['.', '.', '.', '.', '.', '.', '.', '.'],
                    ['w', '.', 'w', '.', 'w', '.', 'w', '.'],
                    ['.', 'w', '.', 'w', '.', 'w', '.', 'w'],
                    ['w', '.', 'w', '.', 'w', '.', 'w', '.']
                ] 
            }";
            var    boardModel = JsonConvert.DeserializeObject <BoardModel>(jsonData);

            board = boardModel.ConvertToArray();

            _predictionBuilder = new PredictionBuilder(_beatCalc.Object, _moveCalc.Object, _weigher.Object);
        }