knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/" ) set.seed(101315)
Welcome to the casino, we've got fun and games
We got everything you want and we know your name
We are a place where you can find whatever you may need
And if you got no money, don't worry! You can play for "free"!
Play casino games in the R console!
Available games:
# Install the CRAN version install.packages("casino") # Install development version from GitHub devtools::install_github("anthonypileggi/casino")
Are you getting impatient already? Then use play()
to get started immediately.
casino::play()
.casino
)All players must agree to our policies on recording activity. If you do not agree, you cannot play. House rules!
library(casino) # create a local file for storing persisent player data setup()
This allows us to store player information persistently between games and R sessions.
You can create a new player manually.
# Create a new player Player$new(name = "Player 1") # View all available player profiles players()
Or just start playing, and one will automatically be created for you.
# Start a new game (this will auto-create a player) Blackjack$new(who = "Player 2") # View all available player profiles (again) players()
Now it's time to head off to the casino! What do you want to play first?!
x <- Poker$new(who = "Player 1", type = "stud", bet = 10) # play a game x$play() # specify a different bet for this game x$play(bet = 5)
x <- Poker$new(who = "Player 1", type = "draw", bet = 20) # play a game x$play() x$hold(1, 2, 5) # hold cards in positions {1, 2, 5} x$draw() # draw new cards for positions {3, 4}
x <- Blackjack$new(who = "Player 1", bet = 25) x$play()$stand()
x <- Slots$new(who = "Player 1", bet = 1) x$play() # set the `spins` argument to play > 1 game at a time x$play(spins = 2)
If you want to play a lot of games, you can write a script.
Just make sure to silence the output (verbose = FALSE
) and sounds (sound = FALSE
).
# poker (stud) x <- Poker$new(who = "Player 1", type = "stud", bet = 10, verbose = FALSE, sound = FALSE) for (i in 1:50) suppressMessages(x$play()) # blackjack (blind) x <- Blackjack$new(who = "Player 1", bet = 5, verbose = FALSE, sound = FALSE) for (i in 1:50) { suppressMessages(x$play()) if (x$active) x$stand() } # penny slots x <- Slots$new(who = "Player 1", bet = 1, verbose = FALSE, sound = FALSE) suppressMessages(x$play(spins = 50))
If you run out of money, the Bank will immediately loan you 100.
You: "So, what's the interest rate on this loan?"
Bank: "Oh, don't worry. It's very reasonable..."
# player profile is stored in `$who` of a game object player <- x$who player$debt()
What a fun day at the casino! Or, was it?
# player profile is stored in `$who` of a game object player <- x$who # Overall player$summary() # By Game player$summary(game)
Let's relive the excitement!
player$plot()
Well, I guess we'll you'll be back tomorrow. See you then!
# clean-up player information created while compiling readme delete()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.