Exemple #1
0
        // Pause or unpause the game
        public void pauseUnpause()
        {
            paused = !paused;
            if (!paused)
            {
                // Change white agent if necessary
                switch (gui.getWhiteAgentType())
                {
                    case "Terminal Agent":
                        if (!(white is TerminalAgent))
                            white = new TerminalAgent("white", gui.readString);
                        break;
                    case "Graphics Agent":
                        if (!(white is GraphicsAgent))
                            white = new GraphicsAgent("white", gui.readSelectedMove);
                        break;
                    case "AI":
                        if (!(white is AiAgent && ((AiAgent)white).getDifficulty() == gui.getWhiteAIDiff()))
                            white = new AiAgent("white", gui.getWhiteAIDiff(), gui.putAiScore);
                        break;
                    case "PlaybackAgent":
                        int time = gui.getWhitePlaybackSleepTime();
                        if (!(white is PlaybackAgent && ((PlaybackAgent)white).getSleepTime() == time))
                            white = new PlaybackAgent("white", gui.getWhitePlaybackFileName(), time);
                        break;
                }

                // Set black agent
                switch (gui.getBlackAgentType())
                {
                    case "Terminal Agent":
                        if (!(black is TerminalAgent))
                            black = new TerminalAgent("black", gui.readString);
                        break;
                    case "Graphics Agent":
                        if (!(black is TerminalAgent))
                            black = new GraphicsAgent("black", gui.readSelectedMove);
                        break;
                    case "AI":
                        if (!(black is AiAgent && ((AiAgent)black).getDifficulty() == gui.getBlackAIDiff()))
                            black = new AiAgent("black", gui.getBlackAIDiff(), gui.putAiScore);
                        break;
                    case "Playback Agent":
                        int time = gui.getBlackPlaybackSleepTime();
                        if (!(black is PlaybackAgent && ((PlaybackAgent)black).getSleepTime() == time))
                            black = new PlaybackAgent("black", gui.getBlackPlaybackFileName(), time);
                        break;
                }
            }
        }
Exemple #2
0
        // --- Control functions ---
        // Start a new game
        public void start()
        {
            // Set white agent
            switch (gui.getWhiteAgentType())
            {
                case "Terminal Agent":
                    white = new TerminalAgent("white", gui.readString);
                    break;
                case "Graphics Agent":
                    white = new GraphicsAgent("white", gui.readSelectedMove);
                    break;
                case "AI":
                    white = new AiAgent("white", gui.getWhiteAIDiff(), gui.putAiScore);
                    break;
                case "Playback Agent":
                    white = new PlaybackAgent("white", gui.getWhitePlaybackFileName(), gui.getWhitePlaybackSleepTime());
                    break;
            }

            // Set black agent
            switch (gui.getBlackAgentType())
            {
                case "Terminal Agent":
                    black = new TerminalAgent("black", gui.readString);
                    break;
                case "Graphics Agent":
                    black = new GraphicsAgent("black", gui.readSelectedMove);
                    break;
                case "AI":
                    black = new AiAgent("black", gui.getBlackAIDiff(), gui.putAiScore);
                    break;
                case "Playback Agent":
                    black = new PlaybackAgent("black", gui.getBlackPlaybackFileName(), gui.getBlackPlaybackSleepTime());
                    break;
            }

            // Start main loop
            running = true;
            run();
        }