Example #1
0
        private void CreateGUI(object o)
        {
            TicTacToe        master = (TicTacToe)((object[])o)[0];
            ManualResetEvent w      = (ManualResetEvent)((object[])o)[1];

            master.gui = new TicTacToeGUI();
            w.Set();
            Application.Run(master.gui);
        }
Example #2
0
        public override Dictionary<QStateActionPair, QState> GetObservedStates(QState prevState, QAction action)
        {
            TicTacToe stateAfterMyMove = (TicTacToe)prevState.GetNewState(action);
            TicTacToe stateFromOpponentsView = new TicTacToe() { myMoves = stateAfterMyMove.yourMoves.ToList(), yourMoves = stateAfterMyMove.myMoves.ToList(), me = you, you = me, random = random, gui = gui, openSpaces = stateAfterMyMove.openSpaces.ToList(), score = stateAfterMyMove.score };
            TicTacToe stateNowFromOpponentsView = new TicTacToe() { myMoves = yourMoves.ToList(), yourMoves = myMoves.ToList(), me = you, you = me, random = random, gui = gui, openSpaces = openSpaces.ToList(), score = stateAfterMyMove.score };
            
            foreach (Point x in stateNowFromOpponentsView.myMoves)
                if (!stateFromOpponentsView.myMoves.Contains(x)) 
                    return new Dictionary<QStateActionPair, QState>() {
                        {new QStateActionPair(stateFromOpponentsView, new QAction_String(x.X + "," + x.Y)), stateNowFromOpponentsView}
                    };

            return new Dictionary<QStateActionPair, QState>();
        }
Example #3
0
        public override QState GetNewState(QAction action = null)
        {
            if (action.ToString() != "")
            {
                string[] point = action.ToString().Split(',');
                Point newPos = new Point(Convert.ToInt32(point[0]), Convert.ToInt32(point[1]));

                List<Point> newSpaces = openSpaces.ToList();
                newSpaces.Remove(newPos);

                List<Point> newMoves = myMoves.ToList();
                newMoves.Add(newPos);

                TicTacToe newState = new TicTacToe() { myMoves = newMoves, yourMoves = yourMoves.ToList(), me = me, you = you, random = random, gui = gui, openSpaces = newSpaces, score = score };

                // Pass all variables to new state
                return newState;
            }
            else return this;
        }