Title: | Play Minesweeper |
---|---|
Description: | Play and record games of minesweeper using a graphics device that supports event handling. Replay recorded games and save GIF animations of them. Based on classic minesweeper as detailed by Crow P. (1997) <https://minesweepergame.com/math/a-mathematical-introduction-to-the-game-of-minesweeper-1997.pdf>. |
Authors: | Harry Thompson [aut, cre, cph] |
Maintainer: | Harry Thompson <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.1 |
Built: | 2024-11-25 15:25:14 UTC |
Source: | CRAN |
Play minesweeper interactively in the current graphics device.
play_minesweeper( difficulty = c("expert", "intermediate", "beginner"), nrow = NULL, ncol = NULL, mine_count = NULL, mine_density = NULL, os_type = c("guess", "unix", "windows") )
play_minesweeper( difficulty = c("expert", "intermediate", "beginner"), nrow = NULL, ncol = NULL, mine_count = NULL, mine_density = NULL, os_type = c("guess", "unix", "windows") )
difficulty |
establishes default dimensions and mine count |
nrow , ncol
|
dimensions of the minesweeper board |
mine_count |
number of mines to sweep |
mine_density |
proportion of cells that conceal a mine |
os_type |
used to interpret |
Expert difficulty is 16x30 with 99 mines, intermediate 16x16 with 40 mines, and beginner 9x9 with 10 mines.
The current graphics device must support event handling
(see grDevices::getGraphicsEvent()
). If onIdle
is not supported,
the timer will only update on mouse events.
Object of class "minesweeper_recording" to pass to
replay_minesweeper()
or save_minesweeper_gif()
, invisibly.
Left click an empty square to reveal it.
Right click an empty square to flag it.
Middle click a number to reveal its adjacent squares.
Press r to reset the board.
Press q to quit.
x11() # Unix-specific example recording <- play_minesweeper() dev.off()
x11() # Unix-specific example recording <- play_minesweeper() dev.off()
Replay a recorded game of minesweeper in the current graphics device.
replay_minesweeper(recording)
replay_minesweeper(recording)
recording |
object of class "minesweeper_recording" returned by
|
recording
, invisibly.
x11() # Unix-specific example recording <- play_minesweeper() replay_minesweeper(recording) dev.off()
x11() # Unix-specific example recording <- play_minesweeper() replay_minesweeper(recording) dev.off()
Save a recorded game of minesweeper to a GIF file.
save_minesweeper_gif( recording, gif_file = "animation.gif", width = 800, height = 600, delay = 1, loop = TRUE, progress = TRUE, ... )
save_minesweeper_gif( recording, gif_file = "animation.gif", width = 800, height = 600, delay = 1, loop = TRUE, progress = TRUE, ... )
recording |
object of class "minesweeper_recording" returned by
|
gif_file |
output gif file |
width |
gif width in pixels |
height |
gif height in pixel |
delay |
time to show each image in seconds |
loop |
if the gif should be repeated. Set to FALSE to only play once, or a number to indicate how many times to repeat after the first. |
progress |
print some verbose status output |
... |
other graphical parameters passed to png |
Reduce the delay
for greater temporal resolution.
The file path of the GIF file.
x11() # Unix-specific example recording <- play_minesweeper() save_minesweeper_gif(recording) dev.off()
x11() # Unix-specific example recording <- play_minesweeper() save_minesweeper_gif(recording) dev.off()