{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)
# Welcome to {ActionSquirrel}!
# * New game: x <- ActionSquirrel$new()
# * Move: e.g. x$move('up')
# * Info: x$pause()
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()
# π³ π³ π³ π³ π³
# π³ π³ π° π³ π³
# π³ π³ π³ πΏ π³
# π³ π¦ π³ π³ π³
# π³ π³ π³ π³ π³
# Moves: 0
# Nuts: 0
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")
# π³ π³ π³ π³ π³
# π³ π³ π° πΏοΈ π³
# π³ π¦ π³ π³ π³
# π³ π³ π³ π³ π³
# π³ π³ π³ π³ π³
# Moves: 1
# Nuts: 0
Congratulations, your move tally has increased by one. Winter arrives after 30 turns and the game will end.
To the nut!
x$move("left")
# π³ π³ π³ π³ π³
# π³ π³ πΏοΈ π³ π³
# π³ π¦ π³ π³ π³
# π° π³ π³ π³ π³
# π³ π³ π³ π³ π³
# Moves: 2
# Nuts: 1
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.