Jump to content

Penney's game: Difference between revisions

m
added a ;See also: (bold) header, corrected a misspelling, added a Wiki link for "fair coin".
No edit summary
m (added a ;See also: (bold) header, corrected a misspelling, added a Wiki link for "fair coin".)
Line 1:
{{task|Games}}
 
[[wp:Penney's_game|PenneysPenney's game]]   is a game where two players bet on being the first to see a particular sequence of Heads and 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 short; then 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.:
Heads, Tails, Heads, or
'''HTH''' for short.
The other player on seeing the first players choice will choose his sequence.
 
ForThe example:coin Oneis player might choose the sequence HHTtossed and the otherfirst THT. Successive coin tosses of HTTHT gives the winplayer to thesee secondhis playersequence asin the lastsequence threeof coin tosses are his sequencewins.
 
 
;Example:
;The Task:
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.
 
 
;The 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 randomly.
:*   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>
Show output of a game where the computer choseschooses first and a game where the user goes first here on this page.
 
 
;See also:
;Refs:
* &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>
 
Cookies help us deliver our services. By using our services, you agree to our use of cookies.