Test2 FSM Flashcards Preview

GameAI > Test2 FSM > Flashcards

Flashcards in Test2 FSM Deck (8)
Loading flashcards...
1

Circle / Sphere

𝐼𝐹 π‘‘π‘–π‘ π‘‘π‘Žπ‘›π‘π‘’ 𝑑 = (π‘₯0 βˆ’ π‘₯1) 2 + (𝑦0 βˆ’ 𝑦1) 2

𝑇𝐻𝐸𝑁 𝑑 2 = (π‘₯0 βˆ’ π‘₯1) 2 + (𝑦0 βˆ’ 𝑦1) 2

Collision Occurs IF: (C1 radius + C2 radius) 2 >= (C1x – C2x) 2 + (C1y – C2y) 2

2

Square/Rectangle

AABB Min-Max

Β 

IF (a.Xmax < b.Xmin OR a.Xmin > b.Xmax) return 0 // No Collision Exists IF (a.Ymax < S2MinY OR S1MinY > S2MaxY) return 0 // No Collision Exists return 1 // Collision Exists

Collision Occurs IF: (S1MaxX >= S2MinX AND S1MinX = S2MinY AND S1MinY <= S2MaxY)

3

Square

AABB Min-Width

Xwidth = | Xmax - Xmin |

Ywidth = | Ymax - Ymin |

IF (a.Xmin – b.Xmin > b.Width OR - (a.Xmin – b.Xmin) > a.Width) return 0 // No Collision Exists

IF (a.Ymin – b.Ymin > b.Width OR - (a.Ymin – b.Ymin) > a.Width) return 0 // No Collision Exists return 1 // Collision Exists

Collision Occurs IF:

(S1MinX - S2MinX) <= S2Xwidth AND - (S1MinX - S2MinX) <= S1Xwidth

AND

(S1MinY - S2MinY) <= S2Ywidth AND - (S1MinY - S2MinY) <= S1Ywidth

4

Square

AABB Center-Radius

IF ((|a.Xcen - b.Xcen|) > a.rad + b.rad) return 0 // No Collision Exists

IF ((|a.Ycen - b.Ycen|) > a.rad + b.rad) return 0 // No Collision Exists return 1 // Collision Exists

Collision Occurs IF:

( | S1X – S2X | ) <= (S1Radius + S2Radius)

AND

( | S1Y – S2Y | ) <= (S1Radius + S2Radius)

5

Why Finite State Machines?

Β 

Quick and simple to code

easy to debug

they have little computational overhead

intuitive

flexible

Β 

6

What is a FSM?

a device or a model of a device which has a finite number of states it can be in at any given time and can operate on input to either make transitions from one state to another or to cause an output or action to take place. Β It can only be in one state at a time.

7

switch based

good for very simple game objects

as more states an donditions are added, thsi sort of structure ends up becoming unreadable and hard to debug.

it makes it hard to code enter and exit conditions

8

Polymorphic State Machine

Good for more complex code.

easy to code enter and exit condtions

you can embed rules for state changes within each state;