Example #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);
    }
Example #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;
    }