Skip to contents

tesseractR plays four-dimensional tic-tac-toe on a 4×4×4×4 hypercube (256 cells, 520 winning lines), with a depth-limited negamax AI, a ggplot2 visualization of the hypercube as a 4×4 grid of 4×4 boards, and an interactive Shiny app with live move evaluation and a game-analysis panel.

Installation

Requires R >= 4.1.0. For a reviewed local checkout, run R CMD INSTALL . after installing the packages listed in DESCRIPTION. The GitHub command below installs the published branch.

# install.packages("remotes")
remotes::install_github("r-heller/tesseractR")

Example

library(tesseractR)
b <- tsr_new_board()
b <- tsr_move(b, 0L, 0L, 0L, 0L)   # X at (0,0,0,0)
b <- tsr_move(b, cell = 17L)       # O
b <- tsr_move(b, 1L, 0L, 0L, 0L)   # X
print(b)
#> 
#> ── <ttt_board> ──
#> 
#> 4x4x4x4 board, 256 cells
#> moves played: 3
#> to move: O
#> legal moves: 253

Mid-game tesseractR board

Launch the interactive app with tsr_run_app() (requires shiny).

Interactive AI time budget

The Shiny app gives each AI response a cooperative 0.5-second search budget. Difficulty sets the maximum depth; the AI uses the last fully completed depth, or the lowest legal cell if none completes. Immediate wins and blocks retain priority. The handler runs synchronously: clock checks bound search work, but process scheduling and an individual operation can exceed the requested time.

Direct calls to tsr_ai_move() remain unrestricted by default. Supply time_limit in seconds for bounded iterative search, for example tsr_ai_move(board, difficulty = 4L, time_limit = 0.5). A zero budget returns a deterministic legal fallback after checking immediate tactics.