petals | R Documentation |
This plays the lateral thinking game Petals Around the Rose. This is a game where 5 regular dice are rolled and the players then try to figure out how many petals are around the rose.
petals(plot = TRUE, txt = TRUE)
plot |
Should the dice be plotted to the current/default graphics device. |
txt |
Should the dice be shown in the console window using text. |
At least one of the arguments plot
and txt
needs to be
true, otherwise you will be guessing blind (or testing your psychic
abilities).
The game is usually played with 5 physical dice, one person who knows the rules (the potentate of the rose, here the computer), and one or more players trying to learn the puzzle. The potentate can only give the players the following 3 rules:
The name of the game is "Petals Around the Rose" and the name is significant.
The answer is always 0 or an even number.
The potentate can tell the answer for any roll after any guesses are made.
The potentate (or other player) then rolls the 5 dice and any players are then allowed to guess. The potentate either confirms a correct guess or tells the correct answer, then the game continues with another roll. Players are not to discuss their reasoning so that each can solve it themselves. When a player thinks they have worked out the reasoning they demonstrate it by getting correct guesses, but not by discussing it with anyone. Generally 6 correct guesses in a row is considered evidence that they have figured out the rules and they are then considered a potentate of the rose.
For this implementation the computer will simulate the role of 5 dice and display the results and ask for a guess of how many petals are around the rose. The player then enters their guess and the computer then either confirms that it is correct or gives the correct answer.
Pressing enter without making a guess ends the game.
This function only returns NULL, it is run for its side effects.
Casual viewing of the function source code is unlikely to reveal the secret (and therefore this could be used as an example of one way to disguise portions of code from casual examination). More on disguising source code is at https://stat.ethz.ch/pipermail/r-devel/2011-October/062236.html.
Some basic debugging can reveal the secret, but that would be cheating and an admission that such a simple game has defeated you, so don't do it, just keep playing until you figure it out.
Greg Snow, 538280@gmail.com
http://www.borrett.id.au/computing/petals-bg.htm
dice
if(interactive()){
petals()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.