MIT Sheet 5 und so…

Media Informatics and Technology 1 for IMD & AG

Task Sheet 5: Boolean Algebra

Task 1: Prove Boolean Laws

Prove the following three Boolean laws using a truth table, like in the lecture:

a.            A || false = A

A false i
true false true
false false true

 

b.            A || true = true

A true i
true true true
false true true

 

c.            A && false = false

A false i
false false true
true false true

 

d.            A && true = A

A true i
false true true
true true true

 

e.            !A || !B = !(A && B)

A !B i
false false true
false true false
true false false
true true true

 

Task 2: Simplify Boolean Expressions

Use the Boolean laws proven above and in the lecture to simplify the following Boolean

expressions:

a.            isHappy || (isHappy == false)

isHappy || false

b.            playerHit || playerHasShield && !playerHasShield

playerHit || true // && has a higher priority than ||

c.            (lives > 0 && isRunning) || (lives >0 && !isRunning)

lives > 0 && isRunning || lives > 0 && !isRunning

lives > 0 && true

d.            A && (B || (C && false))

A && (B || C && false)

e.            (A == false) && B

 

f.             A && B || A &&!B

 

Task 3: Improve Example Player2

In a first step, complete the keyboard controls by allowing vertical movement. Use the key ‘w’

for up and ‘s’ for down direction.

Next add more emotional states and facial expressions (anger, fear, surprise, etc.). Make a

plan: which user action will cause which emotion? Then use Boolean variables to store the

emotional states.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert