コード例 #1
0
        /// <summary>
        /// Converts board to neurel net training example.  Returns example corresopnding to normalized board (current player's checker color is blue, last player is green)
        /// </summary>
        /// <param name="lastPlayerToGo">Current Player which corresponds to last checker placed on board.</param>
        public static Example ToNormalizedExample(Board board, Checker lastPlayerToGo)
        {
            Debug.Assert(lastPlayerToGo != Checker.Empty);
            List<double> boardState = board.Cells.Cast<Checker>().Select(c=>Transform.ToNormalizedValue(c, lastPlayerToGo)).ToList();
            List<int> features = new List<int>();

            // 42 Input Units - Board State Only
            // return new Example(boardState);

            foreach (Checker checker in new List<Checker> { lastPlayerToGo, Board.Toggle(lastPlayerToGo) })
            {
                features.AddRange(board.LineOfX(checker));
                features.AddRange(board.LineOfX(checker, potential: true));
                features.AddRange(board.NumbersInColumns(checker));
                features.AddRange(board.NumbersInRows(checker));
                features.Add(board.NumberOnBoard(checker));
            }
            boardState.AddRange(features.Select(e => (double)e));

            // 40 Input Units - Features Only
            //return new Example(features.Select(e => (double)e).ToList());

            // 82 Input Units - Board State and Features
            return new Example(boardState);
        }
コード例 #2
0
        /// <summary>
        /// Converts board to neurel net training example.  Returns example corresopnding to normalized board (current player's checker color is blue, last player is green)
        /// </summary>
        /// <param name="lastPlayerToGo">Current Player which corresponds to last checker placed on board.</param>
        public static Example ToNormalizedExample(Board board, Checker lastPlayerToGo)
        {
            Debug.Assert(lastPlayerToGo != Checker.Empty);
            List <double> boardState = board.Cells.Cast <Checker>().Select(c => Transform.ToNormalizedValue(c, lastPlayerToGo)).ToList();
            List <int>    features   = new List <int>();

            // 42 Input Units - Board State Only
            // return new Example(boardState);

            foreach (Checker checker in new List <Checker> {
                lastPlayerToGo, Board.Toggle(lastPlayerToGo)
            })
            {
                features.AddRange(board.LineOfX(checker));
                features.AddRange(board.LineOfX(checker, potential: true));
                features.AddRange(board.NumbersInColumns(checker));
                features.AddRange(board.NumbersInRows(checker));
                features.Add(board.NumberOnBoard(checker));
            }
            boardState.AddRange(features.Select(e => (double)e));

            // 40 Input Units - Features Only
            //return new Example(features.Select(e => (double)e).ToList());

            // 82 Input Units - Board State and Features
            return(new Example(boardState));
        }