03LogicGates

# r o c k p a p e r s c is s o rs l o g ic a l v a ria

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: k -P a p e r-S c is s o rs : L o g ic a l v a ria b le s • In p u t: c h o ic e o f p la y e r 1 , c h o ic e o f p la y e r 2 • O u tp u t: o u tc o m e o f th e g a m e ( a c c o r d in g to th e r u le s ) • N e e d to c o n v e r t in p u t a n d o u tp u t to b in a r y r e p r e s e n ta tio n . • N e e d 2 v a r ia b le s to r e p r e s e n t th e p o s s ib le c h o ic e o f e a c h p la y e r 01 = Scissors 10 = Paper 11 = Rock So we need 4 variables to represent the choice of both players. • N e e d 2 v a r ia b le s to r e p r e s e n t th e p o s s ib le o u tc o m e s . 10 = Player 1 wins 01 = Player 2 wins = 10 C O M P - 1 0 2 : C o m p u te r s a n d C o m p u tin g 23 00 = Tie ( th a n k s to J o e lle P in e a u ! ) Rock-Paper-Scissors: Other representations • There are other possible binary representations. • Some are equivalent: – same expressive power, same number of bits – E.g. Scissors = 00, Paper = 01, Rock = 11 • Some are not equivalent: – E.g. Scissors = 0, Paper = 1, Rock = 1 (Fewer bits, less expressive power) – E.g. Scissors = 000, Paper = 001, Rock = 011 (Same power, but more bits) C O M P - 1 0 2 : C o m p u te r s a n d C o m p u tin g 24 ( th a n k s to J o e lle P in e a u ! ) R o c k - P a p e r - S c i s s o r s : T r u th T a b l e Input logical variables: Output variables: Player1: A B Player2: C D EF Scissors 0 1 Scissors 0 1 Scissors 0 1 Paper 10 Player 1 wins 1 0 Scissors 0 1 Rock 11 Player 2 wins 0 1 Paper 10 Scissors 0 1 Player 2 wins 0 1 Paper 10 Paper 10 Paper 10 Rock 11 Rock 11 Scissors 0 1 Player 1 wins Rock 11 Paper 10 Player 2 wins 0 1 Rock 11 Rock 11 Tie 00 Tie 00 Player 1 wins 1 0 Tie 10 00 What happens to the unspecified input (e.g. 0000)? Doesn’t matter what the output is! C O M P - 1 0 2 : C o m p u te r s a n d C o m p u tin g 25 ( th a n k s to J o e lle P in e a u ! ) Rock-Paper-Scissors: Logical expressions • N e e d tw o e x p r e s s io n s , o n e fo r e a c h o f th e o u tp u t b its . E = ( (N O T A ) A N D B A N D C A N D (N O T...
View Full Document

Ask a homework question - tutors are online