{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:
- play a text-based version of Pokemon Blue’s Safari Zone in R
- repay your loan to Animal Crossing’s Tom Nook with an Automatic Bell Dispenser
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.