Example #1
0
    protected override void Start()
    {
        width = (int)Mathf.Sqrt(pieces.Length);
        base.Start();

        boardSituation = new PieceType[pieces.Length];
        for (int i = 0; i < pieces.Length; i++)
        {
            pieces[i].index = i;
        }

        policyValueNet = new GobangPolicyValueNet(width);
        mctsPlayer     = new MCTSPlayer(policyValueNet);
        board          = new GobangBoard(width, 5);
    }
Example #2
0
        public GobangPiece(int pixelx, int pixely)
        {
            board                = GobangBoard.Instance();
            this.pieceRadius     = 15;
            this.judgeRadius     = 15;
            this.pieceWinRadius  = 20;
            this.pieceFrameColor = Color.Black;

            Point Point = new Point();

            //判断是否点击在规定范围内
            if (!ConvertxyToXY(pixelx, pixely, out Point))
            {
                return;
            }
            this.pieceX = Point.X;
            this.pieceY = Point.Y;

            //判断棋子状态类型
            if (lastState == BaseBoard.boardType.Blank || lastState == BaseBoard.boardType.White)
            {
                this.state = BaseBoard.boardType.Black;
            }
            else if (lastState == BaseBoard.boardType.Black)
            {
                this.state = BaseBoard.boardType.White;
            }
            else
            {
                return;
            }

            //下棋
            if (!board.SetState(this.pieceX, this.pieceY, this.state))
            {
                this.state = BaseBoard.boardType.Blank;
                return;
            }

            lastState = this.state;
        }