コード例 #1
0
ファイル: RoleMgr.cs プロジェクト: YueLung/ai_gomoku
        public RoleMgr(Form1 view, GameDef.PlayerType player1, GameDef.PlayerType player2, GameDef.JudgeType judgeType)
        {
            Console.WriteLine($"Board is {GameDef.board_cell_length} x {GameDef.board_cell_length}");

            Model = new Model();
            View  = view;

            P1 = player1;
            P2 = player2;

            Random random = new Random();

            int num = random.Next(0, 2); //0、1

            GameDef.PlayerType blackPlayer = num == 0 ? P1 : P2;
            GameDef.PlayerType whitePlayer = num == 0 ? P2 : P1;

            //assume black chess order is first
            RoleOrderMap.Add(0, PlayerFactory.CreatePlayer(blackPlayer, View, Model, this, ChessType.Black));
            RoleOrderMap.Add(1, JudgeFactory.CreateJudge(judgeType, GameDef.BLACK_CHESS_JUDGE + "_" + blackPlayer.ToString(), View, Model, this, ChessType.Black));
            RoleOrderMap.Add(2, PlayerFactory.CreatePlayer(whitePlayer, View, Model, this, ChessType.White));
            RoleOrderMap.Add(3, JudgeFactory.CreateJudge(judgeType, GameDef.WHITE_CHESS_JUDGE + "_" + whitePlayer.ToString(), View, Model, this, ChessType.White));

            OrderNum        = 0;
            CurrentTurnRole = RoleOrderMap[OrderNum];
        }
コード例 #2
0
ファイル: RoleMgr.cs プロジェクト: YueLung/ai_gomoku
        public void ChangeComputerToPlay()
        {
            GameDef.PlayerType changeAIType = GameDef.PlayerType.HardAI;

            RoleOrderMap[OrderNum] = PlayerFactory.CreatePlayer(changeAIType, View, Model, this, CurrentTurnRole.GetChessType());

            int judgeOeder = OrderNum + 1;

            RoleOrderMap[judgeOeder].AppendName($" + {changeAIType.ToString()}");

            CurrentTurnRole = RoleOrderMap[OrderNum];
            CurrentTurnRole.onMyTurn();
        }
コード例 #3
0
ファイル: PlayerFactory.cs プロジェクト: YueLung/ai_gomoku
        public static Player CreatePlayer(GameDef.PlayerType type, Form1 view, Model model, RoleMgr roleMgr, ChessType chessType)
        {
            Console.WriteLine($"Create a {type.ToString()} Player. ChessType is {chessType}");

            switch (type)
            {
            case GameDef.PlayerType.Human1:
                return(new HumanPlayer("Human1 " + chessType, view, model, roleMgr, chessType));

                break;

            case GameDef.PlayerType.Human2:
                return(new HumanPlayer("Human2 " + chessType, view, model, roleMgr, chessType));

                break;

            case GameDef.PlayerType.EasyAI:
                return(new EasyComputerPlayer("EasyAI " + chessType, view, model, roleMgr, chessType));

                break;

            case GameDef.PlayerType.MediumAI:
                return(new MinMaxComputerPlayer("MediumAI " + chessType, view, model, roleMgr, chessType, 1));

                break;

            case GameDef.PlayerType.HardAI:
                return(new MinMaxComputerPlayer("HardAI " + chessType, view, model, roleMgr, chessType, 3));

                break;

            case GameDef.PlayerType.AI3X3:
                return(new AIComputer3X3Player("AI3X3 " + chessType, view, model, roleMgr, chessType));

                break;

            case GameDef.PlayerType.RandomAI:
                return(new RandomComputerPlayer("RandomAI " + chessType, view, model, roleMgr, chessType));

                break;

            default:
                return(null);

                break;
            }
        }