Skip to contents

Walks a tsr_game (from tsr_play_game()) and computes per-ply evaluation context using the S3 evaluation core: win probability before/after each move, the move's delta, the best alternative move, regret, and flags for missed wins / missed blocks / turning points.

Usage

tsr_analyze_game(game, method = c("heuristic", "rollout"), n = 200L)

Arguments

game

A tsr_game object.

method

One of "heuristic" (default) or "rollout". Passed to the underlying tsr_win_prob() / tsr_rate_moves().

n

Integer. Rollouts when method = "rollout".

Value

A tibble, one row per ply, with columns: ply, player, cell, i, j, k, l, win_prob_before, win_prob_after, delta, best_cell, best_delta, regret, is_best, missed_win, missed_block, is_turning_point.

Details

A turning point is a ply with abs(delta) >= 0.15.

Examples

# \donttest{
g <- tsr_play_game("greedy", "random", seed = 2L) # a short, decisive game
tsr_analyze_game(g)
#> # A tibble: 17 × 17
#>      ply player  cell     i     j     k     l win_prob_before win_prob_after
#>    <int>  <int> <int> <int> <int> <int> <int>           <dbl>          <dbl>
#>  1     1      1     1     0     0     0     0          0.5            0.533 
#>  2     2      2    86     1     1     1     1          0.467          0.5   
#>  3     3      1     4     3     0     0     0          0.5            0.550 
#>  4     4      2   210     1     0     1     3          0.450          0.463 
#>  5     5      1     2     1     0     0     0          0.537          0.731 
#>  6     6      2   202     1     2     0     3          0.269          0.279 
#>  7     7      1    13     0     3     0     0          0.721          0.772 
#>  8     8      2     9     0     2     0     0          0.228          0.255 
#>  9     9      1    10     1     2     0     0          0.745          0.878 
#> 10    10      2   167     2     1     2     2          0.122          0.145 
#> 11    11      1    14     1     3     0     0          0.855          0.937 
#> 12    12      2   144     3     3     0     2          0.0634         0.0676
#> 13    13      1    16     3     3     0     0          0.932          0.975 
#> 14    14      2    25     0     2     1     0          0.0247         0.0278
#> 15    15      1     8     3     1     0     0          0.972          0.988 
#> 16    16      2   104     3     1     2     1          0.0121         0.0129
#> 17    17      1     6     1     1     0     0          0.987          1     
#> # ℹ 8 more variables: delta <dbl>, best_cell <int>, best_delta <dbl>,
#> #   regret <dbl>, is_best <lgl>, missed_win <lgl>, missed_block <lgl>,
#> #   is_turning_point <lgl>
# }