private void AIVSAI_Btn_Click(object sender, EventArgs e) { DisablePreviousActionBtn(); DisableChangeComputerPlayBtn(); DisableLoadBoardBtn(); GameDef.JudgeType judgeType = GameDef.JudgeType.Nomal; if (judgeType == GameDef.JudgeType.Debug) { EnableComputerNextBtn(); } else { DisableComputerNextBtn(); } RoleMgr = new RoleMgr(this, GameDef.PlayerType.EasyAI, GameDef.PlayerType.HardAI, judgeType); HomePanel.Visible = false; RoleMgr.Start(); }
public static RoleBase CreateJudge(GameDef.JudgeType type, String name, Form1 view, Model model, RoleMgr roleMgr, ChessType chessType) { Console.WriteLine($"Create a {type.ToString()} Judge. ChessType is {chessType}"); switch (type) { case GameDef.JudgeType.Nomal: return(new Judge(name, view, model, roleMgr, chessType)); break; case GameDef.JudgeType.Debug: return(new DebugJudge(name, view, model, roleMgr, chessType)); break; default: return(null); break; } }
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]; }