Esempio n. 1
0
    void StartGame()
    {
        Map map = new Map();

        map.whitePlayer            = new Gamer();
        map.whitePlayer.map        = map;
        map.whitePlayer.camp       = Camp.White;
        map.blackPlayer            = new Gamer();
        map.blackPlayer.map        = map;
        map.blackPlayer.camp       = Camp.Black;
        map.whitePlayer.controller = new GameLocalPlayerController();

        UBotAIController BotAI = new UBotAIController();

        map.blackPlayer.controller = BotAI;

        //设置AI
        BotAI.Net.PutWeights(new List <double>(LoadBestWeightsFromFileForUse()[0]));

        board.InitMap(map);
        _gameMap = map;


        _started = true;
        _learn   = false;
        _inited  = true;
    }
Esempio n. 2
0
    public void InitStart()
    {
        History          = new List <Command>();
        ChessTypeFactory = new Dictionary <EChessType, Type>();
        ChessTypeFactory[EChessType.Ju]    = typeof(UChess_Ju);
        ChessTypeFactory[EChessType.Ma]    = typeof(UChess_Ma);
        ChessTypeFactory[EChessType.Xiang] = typeof(UChess_Xiang);
        ChessTypeFactory[EChessType.Shi]   = typeof(UChess_Shi);
        ChessTypeFactory[EChessType.Shuai] = typeof(UChess_Shuai);
        ChessTypeFactory[EChessType.Pao]   = typeof(UChess_Pao);
        ChessTypeFactory[EChessType.Bing]  = typeof(UChess_Bing);


        //创建玩家和AI
        if (!learn)
        {
            RedGamer            = new UPlayer();
            RedGamer.Chessboard = this;
            RedGamer.name       = "小明";
            RedGamer.Camp       = ECampType.Red;
            RedGamer.Attach(new ULocalPlayerController());
            UPlayer.LocalPlayer = RedGamer as UPlayer;

            BlackGamer            = new UBot();
            BlackGamer.Chessboard = this;
            BlackGamer.name       = "魔王";
            BlackGamer.Camp       = ECampType.Black;
            UBotAIController BotAI = new UBotAIController();
            BlackGamer.Attach(BotAI);

            //设置AI
            BotAI.Net.PutWeights(new List <double>(UGameEngine.LoadBestWeightsFromFileForUse()[0]));
        }
        else
        {
            RedGamer            = new UBot();
            RedGamer.Chessboard = this;
            RedGamer.name       = "小明";
            RedGamer.Camp       = ECampType.Red;
            RedGamer.Attach(new UBotAIController());
            UPlayer.LocalPlayer = RedGamer as UPlayer;

            BlackGamer            = new UBot();
            BlackGamer.Chessboard = this;
            BlackGamer.name       = "魔王";
            BlackGamer.Camp       = ECampType.Black;
            BlackGamer.Attach(new UBotAIController());
        }

        Init();
    }