示例#1
0
    private void UpdateCell(int row, int col, Game.CellType cell)
    {
        if (StopRendering)
        {
            return;
        }

        Button button = _board[row, col];

        button.onClick.RemoveAllListeners();
        button.onClick.AddListener(GetCellOnClick(row, col));

        Text text = button.GetComponentInChildren <Text>();

        switch (cell)
        {
        case Game.CellType.Blank:
            text.text = string.Empty;
            break;

        case Game.CellType.Circle:
            text.text = "O";
            break;

        case Game.CellType.Cross:
            text.text = "X";
            break;
        }
    }
示例#2
0
    public override void CollectObservations(VectorSensor sensor)
    {
        Game game = Main.GetGame();

        for (int row = 0; row < Game.MaxSize; ++row)
        {
            for (int col = 0; col < Game.MaxSize; ++col)
            {
                Game.CellType cell = game.Board[row, col];
                sensor.AddObservation(GetFeatureFromCell(cell));
            }
        }
    }
示例#3
0
    private int GetFeatureFromCell(Game.CellType cell)
    {
        // Invert the board state for Cross player so that it plays as Circle player.
        // This will train the model to connect '1's and block '-1's.
        switch (cell)
        {
        case Game.CellType.Circle:
            return(Player == Game.Player.PlayerCircle ? 1 : -1);

        case Game.CellType.Cross:
            return(Player == Game.Player.PlayerCircle ? -1 : 1);

        case Game.CellType.Blank:
            return(0);
        }

        // This cannot be reached.
        Debug.Assert(true);
        return(0);
    }