Launch an interactive terminal game that asks the user to guess a UK
geography (e.g., Local Authority District, MSOA) selected at random.
The game downloads ONS boundaries for the chosen area_type, shows an
initial map, and then responds to user commands (hint, options,
reveal, quit) until the round ends.
Usage
LA_game(
area_type = "lad",
chatty = FALSE,
resolution = "BGC",
nations = c(E = TRUE, N = FALSE, S = FALSE, W = FALSE),
random_seed = NULL,
hint_mode = c("proportional", "fixed_km"),
buffers_km = c(15, 30, 60),
buffer_scales = c(1, 2.5, 5),
buffer_basis = c("maxdim", "diag", "area_radius"),
min_buffer_km = 5,
n_options = 4,
options_radius_km = 60
)Arguments
- area_type
Character scalar, one of
"lad","ctyua","msoa","pcon". These correspond to:"lad"= Local Authority District"ctyua"= Counties and Unitary Authority"msoa"= Middle Layer Super Output Area"pcon"= Parliamentary Constituency
Default is
"lad".- resolution
Character scalar passed to
ons_get_boundaries()to choose the boundary generalisation. Defaults to"BGC".- nations
Named logical vector of length 4 defining which nations to include when downloading boundaries; names must be
c("E","N","S","W"). The default isc(E = TRUE, N = FALSE, S = FALSE, W = FALSE).- random_seed
Integer or
NULL. If supplied, sets the RNG seed at the start of the round to ensure reproducibility of the selected area and the generated options. IfNULL(default), each run is random.- hint_mode
Character scalar; how to generate hint distances. One of:
"proportional"(default) or"fixed_km"."proportional": distances are computed asbuffer_scales * unit_km, whereunit_kmdepends onbuffer_basis(see below) and is floored atmin_buffer_km."fixed_km": distances are taken directly frombuffers_km.
- buffers_km
Numeric vector of hint distances in kilometres used only when
hint_mode == "fixed_km". Default:c(15, 30, 60).- buffer_scales
Numeric vector of multipliers used only when
hint_mode == "proportional". Default:c(1, 2.5, 5).- buffer_basis
Character scalar defining the basis for proportional hints; one of
"maxdim","diag","area_radius". This is passed to.la_size_unit_km()to computeunit_km.- min_buffer_km
Numeric scalar. Minimum hint distance (km) applied when using proportional hints so that very small areas still get a sensible first hint. Default:
5.- n_options
Integer scalar. Total number of answer options to show when the user types
"options". One is correct; the rest are distractors. Default:4.- options_radius_km
Numeric scalar. Maximum distance (km) from the target within which distractor options are sampled. Default:
60.
How it works
Downloads boundaries via
ons_get_boundaries()for the givenarea_type,resolution, andnations.Randomly selects a target and opens a plot of the selected area.
Provides progressive hints either at fixed distances (
hint_mode = "fixed_km") or distances proportional to the size of the area (hint_mode = "proportional"), where proportional distances are computed frombuffer_basis.Offers multiple-choice options drawn from nearby areas.