knitr::opts_chunk$set( collapse = TRUE, comment = "#", fig.path = "man/figures/README-", out.width = "100%" ) set.seed(2)
{ActionSquirrel} is an R package containing an interactive audio-visual experience ('game') in the R console, powered by {R6}.
You play as the titular Action Squirrel. Move around the forest and collect at least eight nuts to survive winter, which happens after 30 turns. Avoid being eaten by the owl.
Read more in the accompanying blog post.
The package is available from GitHub.
install.packages("remotes") # if not installed already remotes::install_github("matt-dray/ActionSquirrel")
Note that I’ve developed and tested this only in RStudio v1.4.1717 with R v4.1.0 running on macOS Big Sur.
Attach the package for instructions.
library(ActionSquirrel)
Initiate by assigning ActionSquirrel$new() to a name. This clears the console and generates a forest that contains Action Squirrel. And a delicious nut. And a scary owl!
x <- ActionSquirrel$new()
Note: Action Squirrel nor the nut nor the owl are as big as a tree. It's just perspective.
You control Action Squirrel. Use the move() method to move through the forest and grab the nuts, avoiding the owl.
x$move("up")
Congratulations, your move tally has increased by one. Winter arrives after 30 turns and the game will end.
To the nut!
x$move("left")
Congratulations, your nut tally has increased by one. And there's a new nut! Collect at least eight, or you won't survive winter.
Advanced tech: you only need the first letter of the direction, like x$move("r") for right, and you can chain moves together like x$move("r")$move("d") to go right then down.
I'll leave it to the player to discover the consequences of being eaten, the endscreens and the sound effects.
Inspired in part by Tomaz's 'Little Useless-Useful R Functions'.
Thanks to Winston Chang for the {R6} package, and Stefan Siegert and Robin Williams for {sonify}.
I've done some other silly things with {R6}. You can:
Add bugs or ideas to the issues.
Please note that the {ActionSquirrel} project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.