Articles

You R not going to believe this

minesweeperNext time I build a predictive model in R and I am just not getting anywhere with it, I think I will try Minesweeper? Most of you probably know this, but the R package fun is a collection of some classical computer games, like the Minesweeper and Five in a row, as well as other fun stuff. Before I offer some examples from the documentation some examples, let me say that all of R programming is fun for me. I suppose that makes me a geek☺

The fun-package was developed by Yihui Xie, Taiyun Wei and Yixuan Qiu in August 2011. Not all of the functions worked with my version of R and RStudio.

mine_sweeper

What a fun game, but also a brain teaser. When I taught at West Point my first time, we would have competitions among the faculty. I do not recall that I won, but I was on the leader board. The controls should be familiar to you: Click the left mouse button to dig in an area, and right button to mark or unmark the area with flags.

## install.packages('fun')
require(fun)
if (.Platform$OS.type == "windows") x11() else x11(type = "Xlib")
mine_sweeper()

minesweeper

alzheimer_test

In this challenge you have look for hard to find the letters or numbers, like “N” in 300 “M”s, one “6” in 300 “9”s, etc. I suppose that if you cannot pass the test, you have Alzheimer disease. I suppose that if you cannot pass the test, you have Alzheimer disease. I suppose that if you cannot pass the test, you have Alzheimer disease.

> x = alzheimer_test()

This is a REAL neurological test. Sit comfortably and be calm.

TEST  1
* Find the "6" below
* Do not use any cursor help
1: Ready, Go!
2: Let me quit the test!
Selection: 1

999999999999999999999999999999
999999999999999999999999999999
999999999999999999999999999999
999999999999999999999999999996
999999999999999999999999999999
999999999999999999999999999999
999999999999999999999999999999
999999999999999999999999999999
999999999999999999999999999999
999999999999999999999999999999

Find it now?
1: Yes! (Input the answer later)
2: No... (See the answer later)
Selection: 1

Please input the Row number and Column number respectively when you find the character:
1: 4
2: 30
 
Read 2 items

random_password

Not a game, but if you need a good password, try this function that generates a random password sampled from the ASCII table. Obviously, it is not the only algorithm we could use to get a random password, but I did not have to write this one.

> random_password()
# set the seed to get fixed password every time; you may
# just remember the seed and forget the real password
# because it's reproducible
set.seed(123)
random_password()
# long password
random_password(20, TRUE)

[1] “6|[EP@T?pH.J”

tower_of_hanoi

The Tower of Hanoi had special interest to me, as I used it for introducing modeling with discrete dynamical systems (DDS), the first time I taught at West Point. Since DDS are recursive difference equations, the Tower of Hanoi was the perfect example. This function uses the recursive algorithm to solve the Tower of Hanoi puzzle, and demonstrates the game in animation.

tower_of_hanoi(7)

More Fun!

If you R having any more “fun” ideas, please submit them as comments and I will add them with the appropriate credit.


Profile_PicAuthored by:
Jeffrey Strickland, Ph.D.

Jeffrey Strickland, Ph.D., is the Author of Predictive Analytics Using R and a Senior Analytics Scientist with Clarity Solution Group. He has performed predictive modeling, simulation and analysis for the Department of Defense, NASA, the Missile Defense Agency, and the Financial and Insurance Industries for over 20 years. Jeff is a Certified Modeling and Simulation professional (CMSP) and an Associate Systems Engineering Professional (ASEP). He has published nearly 200 blogs on LinkedIn, is also a frequently invited guest speaker and the author of 20 books including:

  • Operations Research using Open-Source Tools
  • Discrete Event simulation using ExtendSim
  • Crime Analysis and Mapping
  • Missile Flight Simulation
  • Mathematical Modeling of Warfare and Combat Phenomenon
  • Predictive Modeling and Analytics
  • Using Math to Defeat the Enemy
  • Verification and Validation for Modeling and Simulation
  • Simulation Conceptual Modeling
  • System Engineering Process and Practices

Connect with Jeffrey Strickland
Contact Jeffrey Strickland

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s