## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ## ----setup-------------------------------------------------------------------- library(mergeGridR) ## ----launch, eval = FALSE----------------------------------------------------- # run_drop_number() ## ----static-export, eval = FALSE---------------------------------------------- # out <- file.path(tempdir(), "mergeGridR-static.html") # export_static_app(out, overwrite = TRUE) ## ----merge-formula, echo = FALSE---------------------------------------------- data.frame( component_size = 2:5, multiplier = 2 ^ ((2:5) - 1) ) ## ----new-game----------------------------------------------------------------- state <- new_game(seed = 42) state$board state$next_tiles ## ----preview-config----------------------------------------------------------- three_preview <- new_game(game_config(next_count = 3), seed = 42) three_preview$next_tiles ## ----drop--------------------------------------------------------------------- state <- drop_tile(state, column = 3) state$board state$score state$last_drop ## ----continue-game, eval = FALSE---------------------------------------------- # state <- continue_game(state) # state$continues_remaining ## ----three-tile-merge--------------------------------------------------------- state <- new_game(seed = 1) state$board[1, 1] <- 2L state$board[1, 2] <- 2L state$next_tiles <- c(2L, 2L, 2L) merged <- drop_tile(state, column = 1) merged$board merged$score merged$last_drop[c("created", "component_sizes")] ## ----autoplay-move------------------------------------------------------------ move <- autoplay_move( merged, strategy = "growth_lookahead", depth = 2, beam_width = 5, seed = 10 ) move[c("column", "strategy", "score_estimate")] head(move$candidates) ## ----autoplay-game, eval = FALSE---------------------------------------------- # game <- autoplay_game( # strategy = "growth_lookahead", # max_moves = 1000, # depth = 3, # beam_width = 10, # seed = 1 # ) # # game$final_state$score # game$history ## ----benchmark, eval = FALSE-------------------------------------------------- # bench <- benchmark_autoplay_strategies( # n_games = 10, # max_moves = 200, # settings = autoplay_benchmark_settings("fast"), # seed = 20260609, # workers = 1 # ) # # bench$summary ## ----high-score, eval = FALSE------------------------------------------------- # get_high_score() # get_high_score(preview_horizon = 3)