コード例 #1
0
    public override void OnMyMoveEvent(Board board, MoveChoiceCallback moveChoiceCallback)
    {
        if (!_hasInitialized)
        {
            _callback = moveChoiceCallback;
            return;
        }

        if (_isUsingStandaloneExecutable && board.LastMove == null)
        {
            //Benzene behaviour differs here. The standalones automatically play the first move but in benzene must send command 'genmove b' to get opening move.
            moveChoiceCallback(new Move(new Vector2Int((Settings.BoardDimensions.x) / 2, (Settings.BoardDimensions.y - 1) / 2)));
            return;
        }

        //Ensure states are consistent
        if (board.LastMove != null)
        {
            SolverParser.IssueCommand(BenzeneCommands.play(PlayerColours.White, board.LastMove));
        }

        var moveStr = SolverParser.IssueCommand(BenzeneCommands.genmove(PlayerColours.Black));
        var move    = BenzeneUtil.TryToParseMove(moveStr);

        moveChoiceCallback(move);
    }
コード例 #2
0
    public override void VisualizeMove()
    {
        if (!_isSelectingMove)
        {
            return;
        }


        base.VisualizeMove();

        if (_visualizedMove == _visualizedPatternForMove)
        {
            return;
        }

        if (_visualizedCounterMove != null)
        {
            if (_visualizedMove == null || _visualizedCounterMove.Location != _visualizedMove.Location)
            {
                _visualization.ClearSelectedMove(_visualizedCounterMove.Location);
                _visualization.ClearAllVCs();
                _virtualConnections.Clear();
            }
        }

        if (_visualizedMove == null)
        {
            _visualizedPatternForMove = null;
            VisualizeBrain();
            return;
        }
        //To get the countermove visualization we must actually play the white move and then get the black respones then undo them.
        SolverParser.IssueCommand(
            BenzeneCommands.play(PlayerColours.White, _visualizedMove));
        _visualizedCounterMove = BenzeneUtil.TryToParseMove(SolverParser.IssueCommand(
                                                                BenzeneCommands.genmove(PlayerColours.Black)));

        VisualizeBrain();

        for (int i = 0; i < 2; i++)
        {
            SolverParser.IssueCommand(
                BenzeneCommands.undo);
        }
        _visualization.SelectMove(_visualizedCounterMove.Location, TileState.Black);
        _visualizedPatternForMove = _visualizedMove;
    }
コード例 #3
0
    public void Initialize()
    {
        SolverParser.Main(Application.streamingAssetsPath + "/" + _defaultStrategyFile);
        var name         = SolverParser.IssueCommand(BenzeneCommands.name);
        var expectedName = (_isUsingStandaloneExecutable) ? "= jingyang" : "= JY";

        if (expectedName != name)
        {
            Debug.LogError("Failed to start jingyang player. Instead got: " + name);
            return;
        }
        if (!_isUsingStandaloneExecutable)
        {
            //Standalone executables automatically determine boardsize but benzene defaults to 13x13
            SolverParser.IssueCommand(BenzeneCommands.boardsize(new Vector2Int(9, 9)));
        }
        if (_callback != null)
        {
            _callback(new Move(new Vector2Int((Settings.BoardDimensions.x) / 2, (Settings.BoardDimensions.y - 1) / 2)));
        }
    }