Type: | Package |
Title: | Play Minesweeper |
Version: | 1.0.1 |
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. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
Imports: | grid |
Suggests: | gifski |
RoxygenNote: | 7.3.1 |
Depends: | R (≥ 2.10) |
URL: | https://github.com/hrryt/minesweeper |
BugReports: | https://github.com/hrryt/minesweeper/issues |
NeedsCompilation: | no |
Packaged: | 2024-11-20 22:13:56 UTC; harry |
Author: | Harry Thompson [aut, cre, cph] |
Maintainer: | Harry Thompson <harry@mayesfield.uk> |
Repository: | CRAN |
Date/Publication: | 2024-11-20 23:20:02 UTC |
minesweeper: 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.
Author(s)
Maintainer: Harry Thompson harry@mayesfield.uk [copyright holder]
See Also
Useful links:
Start a Minesweeper Game
Description
Play minesweeper interactively in the current graphics device.
Usage
play_minesweeper(
difficulty = c("expert", "intermediate", "beginner"),
nrow = NULL,
ncol = NULL,
mine_count = NULL,
mine_density = NULL,
os_type = c("guess", "unix", "windows")
)
Arguments
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 |
Details
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.
Value
Object of class "minesweeper_recording" to pass to
replay_minesweeper()
or save_minesweeper_gif()
, invisibly.
Controls
-
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.
Examples
x11() # Unix-specific example
recording <- play_minesweeper()
dev.off()
Replay a Minesweeper Recording
Description
Replay a recorded game of minesweeper in the current graphics device.
Usage
replay_minesweeper(recording)
Arguments
recording |
object of class "minesweeper_recording" returned by
|
Value
recording
, invisibly.
Examples
x11() # Unix-specific example
recording <- play_minesweeper()
replay_minesweeper(recording)
dev.off()
Save a Minesweeper Recording to GIF
Description
Save a recorded game of minesweeper to a GIF file.
Usage
save_minesweeper_gif(
recording,
gif_file = "animation.gif",
width = 800,
height = 600,
delay = 1,
loop = TRUE,
progress = TRUE,
...
)
Arguments
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 |
Details
Reduce the delay
for greater temporal resolution.
Value
The file path of the GIF file.
Examples
x11() # Unix-specific example
recording <- play_minesweeper()
save_minesweeper_gif(recording)
dev.off()