Penney's game: Difference between revisions

m
no edit summary
(Revert several unexplained deletions of the phrase "Rosetta Code" from several examples)
mNo edit summary
Line 1:
{{task|Games}}
 
[[wp:Penney's_game|Penney's game]]   is a game where two players bet on being the first to see a particular sequence of   [[wp:Coin_flipping|heads or tails]]   in consecutive tosses of a   [[wp:Fair_coin|fair coin]].
 
It is common to agree on a sequence length of three then one player will openly choose a sequence, for example:
Heads, Tails, Heads, or '''HTH''' for or short.
The other player on seeing the first players choice will choose his sequence. The coin is tossed and the first player to see his sequence in the sequence of coin tosses wins.
'''HTH''' for short.
The other player on seeing the first players choice will choose his sequence.
 
The coin is tossed and the first player to see his sequence in the sequence of coin tosses wins.
 
 
;Example:
One player might choose the sequence   '''HHT'''   and the other   '''THT'''.  
 
Successive coin tosses of   '''HTTHT'''   gives the win to the second player as the last three coin tosses are his sequence.
 
 
;Task:
Create a program that tosses the coin, keeps score and plays Penney's game against a human opponent.
:*   Who chooses and shows their sequence of three should be chosen randomly.
:*   If going first, the computer should randomly choose its sequence of three.
:*   If going second, the computer should automatically play [[wp:Penney's_game#Analysis_of_the_three-bit_game|the optimum sequence]].
:*   Successive coin tosses should be shown.
 
<br>
Line 28 ⟶ 25:
 
 
;See also:
* &nbsp; [https://www.youtube.com/watch?v=OcYnlSenF04 The Penney Ante Part 1] (Video).
* &nbsp; [https://www.youtube.com/watch?v=U9wak7g5yQA The Penney Ante Part 2] (Video).
<br><br>
 
Anonymous user