[BlindRUG] discovered a new package that gives a simple game

Godfrey, Jonathan A.J.Godfrey at massey.ac.nz
Wed Jan 27 08:07:54 UTC 2016


Hi all,

Just read an item from R bloggers today that mentioned a new package that does little but offer a simple game.

The game is called lights out and is playable in the R terminal. You start with a square grid of odd size, some of the elements in the matrix are ones and the others are zeroes (1 for on, 0 for off)
The aim is to get all the lights off.

It's a nice little mathematical problem even though it looks utterly trivial. Not all game boards are guaranteed to be resolvable

The full description is at:
https://github.com/daattali/lightsout

but the short version is:

1.       Install the package using install.packages("lightsout")

2.       Load the package using library(lightsout)

3.       Get a new game board using something like game1=random_board(3) to generate a new puzzle of 3x3 size.

4.       Use play(r,c) to toggle the light at row r and column c off/on which also toggles the adjacent lights (up to 4 of them)

5.       You can speed things up by using the pipe operator to combine multiple game1 %>% play(1,2) %>% play 3,3)

Btw: I tried the web version (shiny app) and found it inaccessible. That is built on the command line version anyway so we only miss out on the interface not the game.
What I like is that it can be used to show a few things about R code and R structures. I can see myself using it as a teaching tool to bring people into R coding, not to mention the fact that it shows people that the back end can be converted into a front end for that "modern" feel the vision-dependent crave.

Jonathan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nfbnet.org/pipermail/blindrug_nfbnet.org/attachments/20160127/bbc31450/attachment.html>


More information about the BlindRUG mailing list