1 CO2301 - Games Development 1 Week 4 Finite State Machines + Maths Gareth Bellaby.

Slides:



Advertisements
Similar presentations
Our Friend the Dot Product
Advertisements

Tangent and Cotangent Graphs
1 MA 1128: Lecture 05 – 9/12/14 Inequalities And Absolute Values.
Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Introduction In the previous lesson, we applied the properties of similar triangles to find unknown side lengths. We discovered that the side ratios of.
Michael Zyda Finite State Machines Michael Zyda
Calculating the “actual” internal force in truss bridge members
Math / Physics 101 GAM 376 Robin Burke Winter 2008.
12 VECTORS AND THE GEOMETRY OF SPACE.
Fundamentals of Applied Electromagnetics
Bridge Design part 3 Note: have worksheet ready for vector work
Bridge Design part 2 Note: have worksheets of triangles for using trig functions ready By Alan Pennington, materials taken from and adapted West Point.
Vectors Sections 6.6.
Slopes and Areas Frequently we will want to know the slope of a curve at some point. Or an area under a curve. We calculate area under a curve as the sum.
Copyright © Cengage Learning. All rights reserved.
Unit Circle Definition of Trig Functions. The Unit Circle  A unit circle is the circle with center at the origin and radius equal to 1 (one unit). 
The Game of Algebra or The Other Side of Arithmetic The Game of Algebra or The Other Side of Arithmetic © 2007 Herbert I. Gross by Herbert I. Gross & Richard.
Scalar and Vector Fields
Introduction Lecturer: Professor Stephen T. Thornton.
Angles Type of angle: Acute: An Angle less than 90 degrees Right angle: An angle that is 90 degrees Obtuse angle: An angle more than 90 degrees Straight.
Algebra Problems… Solutions Algebra Problems… Solutions © 2007 Herbert I. Gross Set 2 By Herbert I. Gross and Richard A. Medeiros next.
Solving Exponential Equations…
1 CO Games Development 1 Week 5 Deriving a "look at" function + Graph Theory Gareth Bellaby.
Functions of several variables. Function, Domain and Range.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
1 CO Games Development 1 Week 1 Introduction to AI Gareth Bellaby.
§ 4.3 Equations and Inequalities Involving Absolute Value.
Lesson 5-3 (non honors) The Law of Sines
Calculate the components of a force vector. Add two force vectors together. Draw a free body diagram. Calculate whether a truss is statically determinate.
Trigonometric Equations M 140 Precalculus V. J. Motto.
Mechanics of Machines Dr. Mohammad Kilani Class 3 Position Analysis.
1 CO Games Concepts Week 20 Matrices continued Gareth Bellaby.
Math / Physics 101 GAM 376 Robin Burke Fall 2006.
Week 13 - Monday.  What did we talk about last time?  Exam 2!  Before that…  Polygonal techniques ▪ Tessellation and triangulation  Triangle strips,
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
VECTORS. A vector is a quantity that has both magnitude and direction. It is represented by an arrow. The length of the vector represents the magnitude.
Ranking in Information Retrieval Systems Prepared by: Mariam John CSE /23/2006.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
CGDD 4003 THE MATH LECTURE (BOILED DOWN, YET LIGHTLY SALTED)
Games Development 2 Entity Update & Rendering CO3301 Week 2, Part 1.
Artificial Intelligence for Games Finite State Machines
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
H.Melikyan/12001 Inverse Trigonometric Functions.
Copyright © Ed2Net Learning, Inc.1 Good Afternoon! Today we will be learning about Review of Right Triangles Let’s warm up : Find the length of the missing.
CS1Q Computer Systems Lecture 2 Simon Gay. Lecture 2CS1Q Computer Systems - Simon Gay2 Binary Numbers We’ll look at some details of the representation.
 In this packet we will look at:  The meaning of acceleration  How acceleration is related to velocity and time  2 distinct types acceleration  A.
1 CO Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby.
Computer Graphics Basic Maths for Graphics in C++ CO2409 Computer Graphics Week 4.
5 INTEGRALS.
1 CO Games Development 1 Week 3 Game Agents 2 Gareth Bellaby.
Radian Measure One radian is the measure of a central angle of a circle that intercepts an arc whose length equals a radius of the circle. What does that.
CSCI 4310 Lecture 5: Steering Behaviors in Raven.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
The Electric Field Due to a Continuous Charge Distribution (worked examples) finite line of charge general derivation:
Multiple Angle Formulas for Cosine We’re going to build them using lots of algebra (6.3, 6.4) (1)
Finite State Machines Logical and Artificial Intelligence in Games Lecture 3a.
Things I expect you will be able to explain on the final exam.
Computer Graphics Mathematical Fundamentals Lecture 10 Taqdees A. Siddiqi
1 CO Games Development 2 Week 13 Influence Maps Gareth Bellaby.
Algebra 2 Properties of Real Numbers Lesson 1-2 Goals Goal To graph and order real numbers. To Identity properties of real numbers. Rubric Level 1 –
Right Triangle Trig Review Given the right triangle from the origin to the point (x, y) with the angle, we can find the following trig functions:
Computer Graphics Basic Maths for Graphics in C++
CO1301: Games ts 2015 Lecture 6 Vectors Dr Nick Mitchell (Room CM 224)
06 – Concave or Converging Mirrors
CO Games Development 2 Week 19 Extensions to Finite State Machines
CO1301: Games Concepts Lecture 13 Basic Trigonometry
What is an equation? An equation says that two things are equal. It will have an equals sign "=" like this: x + 2 = 6 This equation says: what is on the.
CO Games Concepts Week 12 Collision Detection
CHAPTER 3 VECTORS NHAA/IMK/UNIMAP.
Presentation transcript:

1 CO Games Development 1 Week 4 Finite State Machines + Maths Gareth Bellaby

2 Practical Finish game agents next week. Check list of things to have completed in the worksheet for next week. Keep your code - a good side project.

3 Part A: Finite State Machines

4 A FSM is a machine which models states, transitions between states, and actions. State Transition Diagram.

5 Convention being used Box represents a state. Line represents a transition between states, single-direction only. An arrow with a dot at the end indicates the start state. A state can just be an start state (nothing leads into the state). A state can just be an end state (nothing leads from the state).

6 FPS Monster Idle Attacking Dying Attacks No hit points Player location NPC hit points Simple monster that reacts when the player comes into range and is in line-of-sight. Note different convention. Start

7 FPS enemy Wander Attack Flee See Enemy Low Health No Enemy Taken from Intro to Game Development No Enemy Start

8 UML UML lends itself well to the design of a FSM.

9 Characteristics Two type of machine: Actions occur within a state Actions occur during a transition In the games industry the distinctions between the two types of FSMs are blurred. It is common to see a FSM in which actions occur within a state and in which actions occur during a transition.

10 Simple Strategic RTS Explore (early game) Build (middle game) Attack Resource Level Numerical Superiority Numerical Inferiority Start

11 Thief (approximately...) Not alert Suspicious Fully Alerted Minor Sound Suspicious Sound/Sight Definite Sound/Sight Timer Suspicious Sound/Sight Start

12 Your game Patrol Move to thief LOS and distance OR sound Out of range Reach waypoint LOS and distance OR sound Start Move to previous (?) waypoint

13 Your game Patrol Move to thief LOS and distance OR sound distance > 12 LOS and distance OR sound Start distance < 1 Thief killed

14 Capabilities A game actor may have more than one FSM. One FMS could be swapped out and replaced by another. A FSM could cause a cause in another FSM, e.g. a guard alerting another guard. Probabilities Randomness Extra information Extra actions

15 Characteristics of FSMs To summarise, FSMs are: Flexible Appropriate Comprehensible and straightforward Can become unwieldy especially: if FSM is piled upon FSM lots of interconnecting FSMs (feedback) Additions, special cases, etc. undermine the structure.

16 Part B: Cross Product and derving a "look at" function

17 Note Use lookAt function to point to next waypoint in sequence. When you read the next waypoint increment waypoint number. If greater than max set back to 0. Do not wait until you reach the waypoint! Floating point inaccurancies mean that an equality test will most likely fail. You will end up pointing at the waypoint (and hence point down, or with the model upside down). Instead, check within a radius (N.B. a range)

18 Topics 1. Vectors and dot product 2. Test for "in front" or "behind".

19 Topic 1 Vectors and dot product

20 Relevance You will have an exam for CO2301: Games Development 1 at the end of this semester. You will be examined on the first half of the module. All of the AI material is examinable. However, so is all of the maths taught in this half of the module. All of this lecture is examinable, including all of the equations.

21 Length of a vector The length of a vector can be calculated from its components.

22 The normalised vector A normalised vector is a vector whose length is 1. Also known as the unit vector. A vector is normalised by dividing each of its components by its length:

23 The dot product The dot product gets its name from the symbol used: a single dot between two vectors. ●Pronounced " V dot W ", or say "the dot product of V and W ". ●The dot product takes two vectors and produces a single result.

24 Cosine of the angle ●The dot product expresses the relationship of the angle between two vectors. ●Given any two vectors we can derive the angle between them. ●The angle can be found using the inverse cosine operation (arcos)

25 Simplified if normalised If v and w are normalised then the length of v is 1 and the length of w is 1. The equation becomes: ●(but only If v and w are normalised!)

26 Cosine Wave image of sine and cosine waves ●Image taken from Wikipedia

27 Topic 2 Test for "in front" or "behind".

28 In front or behind? You have a gun (or guard or whatever). Let the facing vector (the orientation) of the gun be v. Let the vector from the gun to the target be w. Do not need to calculate the exact angle. Instead you can use the sign to classify angle ||a|| and ||b|| are always non-negative, so sign depends on cos a, therefore v w > 0 if angle < 90° v w = 0 if angle = 90° (orthogonal) v w 90°

29 In front or behind? Therefore if v w < 0 then the target is behind the gun. See Van Verth, also his web site. For this particular test the length of the vectors doesn't matter so you don't have to normalise the vectors. This makes this a very inexpensive test and so extremely useful. Use it to test whether two vectors are orthogonal.