Beispiel #1
0
        /// <summary>
        /// List of possible successor states.
        /// </summary>
        /// <param name="state"></param>
        /// <returns></returns>
        private Dictionary <int, State> Successors(State state)
        {
            Dictionary <int, State> succ = new Dictionary <int, State>(7);

            for (int i = 1; i <= 7; i++)
            {
                State s = state.Move(i);
                if (s != null)
                {
                    succ.Add(i, s);             // if move is valid add it to succ.
                }
            }
            return(succ);
        }
Beispiel #2
0
        public bool Turn(int move)
        {
            try
            {
                State state = GameState.Move(move);

                if (state == null)
                {
                    return(false);
                }

                GameState = state;
            }
            catch (Exception ex)
            {
                _Message.WriteLine(string.Format("Invalid move - {0}", ex.Message));
            }
            return(true);
        }