1 co2301 - games development 1 week 13 - revision lecture ai revision gareth bellaby
TRANSCRIPT
![Page 1: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/1.jpg)
1
CO2301 - Games Development 1
Week 13 - Revision LectureAI Revision
CO2301 - Games Development 1
Week 13 - Revision LectureAI Revision
Gareth BellabyGareth Bellaby
![Page 2: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/2.jpg)
2
Exam formatExam format●2 hours. 10 minutes reading time.
●Only semester 1 material - AI + maths.
●All of the material from semester 1 is examinable.
![Page 3: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/3.jpg)
3
Exam formatExam format● Section A and Section B.
● Section A
● Answer all of the questions
● Maths (Vector maths and graph theory)
● Pathfinding definitions and terms
● Section B
● 4 questions.
● Choose 2.
● Longer questions
![Page 4: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/4.jpg)
4
Topic ListTopic List
●There's a list of words and topics I gave at the beginning of doing the AI.
● "AI - to be learnt".
●Learn all of these phrases and their meanings.
![Page 5: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/5.jpg)
5
RevisionRevision
●Read
●Read around the subject
●Write out own notes
●Condense notes
●Group study is invalulable
![Page 6: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/6.jpg)
6
Characteristics of the exam Characteristics of the exam questionsquestions
●Describe the topic, e.g. what is a game agent?, What is a FSM?
●Be prepared to give an example, e.g. give an example of a game agent, provide an example of a FSM.
●Provide an example of use. How would it be used? Why would it be used?
![Page 7: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/7.jpg)
7
Prepare to draw a diagramPrepare to draw a diagram
●Be prepared to draw a diagram for every topic.
Idle
Attacking
Dying
Attacks No hit points
Player distance &
LOS
NPC hit points
Start
![Page 8: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/8.jpg)
8
Game AgentGame Agent
sense
memory
think
act
(optional)
![Page 9: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/9.jpg)
9
Game AgentsGame Agents
●Autonomous or semi-autonomous.
●Perceives the world and acts upon the world.
●Agents are situated in the world.
●Agents interact with the world.
●Suits genres such as FPS, but also think about games such as Viva Pinata.
![Page 10: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/10.jpg)
10
Game Agents - sensingGame Agents - sensing● Perceiving the world in a similar (or analogous) way to that of
the player.
● Seeing.
An efficient vision algorithm would only consider:
● objects that the agent is interested in
● objects within the viewing distance of the agent
● objects within the viewing angle of the agent
● objects within the unobscured LOS of the agent
● Hearing.
● Similar considerations to seeing, but need to discuss sound propagation, ambient sound, etc.
● Communication with other agents.
![Page 11: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/11.jpg)
11
Finite State MachineFinite State Machine● Finite State Machine is a machine which represents
behaviour as:
● states
● transitions between states
● actions. The actions can occur within a state, on entry to a state, on exit from a state.
● Need a start state and an end state.
● You need to consider FSMs as a diagramatic technique.
● I provided a bunch of examples. Make sure you understand them and write similar examples of your own.
![Page 12: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/12.jpg)
12
PathfindingPathfinding
● What is pathfinding?
●7 algorithms:
●Crash and Turn
●Breadth-first algorithm
●Depth-first algorithm
●Hill-climbing algorithm
●Best-first algorithm
●Djikstra's algorithm
●A* algorithm
![Page 13: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/13.jpg)
13
PathfindingPathfinding●Don't need to learn the algorithms off by heart but
you do need to able to describe and discuss them.
●You must be aware of the fundamental characteristics of each of the search techniques.
●You must be able to explain and discuss the algorithms.
●Each of the search techniques can be compared to the others.
●What are the relative advantages and disadvantages of each of the searches?
![Page 14: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/14.jpg)
14
PathfindingPathfinding
● Description: The characteristics of the algorithm.
● Is the algorithm guaranteed to find a solution?
● If the algorithm guaranteed to find the optimal solution?
● Efficiency: speed, size of tree.
● Heuristic: blind or directed?
● Cost: does the algorithm employ cost?
● Application: Where would you use the algorithm? What are the advantages and disadvantages of the algorithm?
![Page 15: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/15.jpg)
15
PathfindingPathfinding
●Simplest algorithm is "Crash and Turn": move towards objective, if crash into an obstacle turn and move around its perimeter until you can move towards the objective again.
●Simple to implement.
●Can be effective in simple situations
●Guaranteed to work so long as all objects are convex.
●Think about using in combination with other methods.
![Page 16: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/16.jpg)
16
Breadth-first algorithmBreadth-first algorithm
●Expands all of the nodes, layer by layer.
●Exhaustive search.
●Guaranteed to find solution, if one exists.
●Guaranteed to find the optimal solution.
● Inefficient because every node searched. The problem of combinatorial explosion.
●Does not employ a heuristic.
●OK for small problems where size is manageable. Useful if you definitely want to search all of the nodes.
![Page 17: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/17.jpg)
17
Depth-first algorithmDepth-first algorithm● Only one node expanded. Single path followed.
● Need to include backtracking, otherwise it is pretty useless.
● Not guaranteed to find a solution. (But variants such as using a limiting wall and employing backtracking are guaranteed to do so).
● Not guaranteed to find the optimal solution.
● Overcomes combinatorial explosion because a smaller tree is generated.
● Does not employ a heuristic.
● May get lucky and, on average, faster than breadth-first.
● Used for problems in which optimality not important.
● Can be used in conjunction with other searches, e.g. for opportunistic searches.
![Page 18: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/18.jpg)
18
Hill-climbing algorithmHill-climbing algorithm● Current node examined to find the best successor. Path follows best
successor.
● Better than depth and breadth.
● Basic algorithm is not guaranteed to find a solution.
● Foothills.
● Plateaus.
● Ridges.
● However, it is guaranteed to find a solution if backtracking is used, together with the option to move to a worse successor if no other alternatives exist.
● Not guaranteed to find optimal solution.
● Uses a heuristic.
● Variants include randomness, jumps.
● Useful for climbing a hill! (Or equivalent).
![Page 19: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/19.jpg)
19
Best-first algorithmBest-first algorithm
● All unexpanded nodes recorded. Best overall node chosen.
● Uses a heuristic.
● Better than depth, breadth and hill-climbing.
● Guaranteed to find a solution.
● Not guaranteed to find the optimal solution, e.g. on a map with terrain costs.
● Useful for maps with no costs or equivalent kinds of problems.
● Can be employed in a game with moving obstacles.
![Page 20: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/20.jpg)
20
Djikstra's algorithmDjikstra's algorithm● Uses cost.
● Choose the successor node with the lowest cost. Cost is accumulated along each route.
● Guaranteed to find a solution.
● Guaranteed to find the optimal solution.
● Very efficient for maps in which all of the costs can be pre-generated.
● For a game with a large map can be inefficient because potentially a large number of alternatives may be considered.
● Inefficient with moving obstacles since cost would have to be regenerated.
![Page 21: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/21.jpg)
21
A* algorithmA* algorithm
● Uses cost and heuristic.
● Choose the successor node with the lowest summed cost + heuristic. Cost is accumulated along each route.
● Guaranteed to find a solution.
● Guaranteed to find the optimal solution.
● An efficient algorithm.
● A commonly used games algorithm. Compare with Djikstra's. If cost can be pre-generated and stored efficiently then Djikstra's will be the better choice, otherwise use A*.
![Page 22: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/22.jpg)
22
A* algorithmA* algorithm
●Admissability, , i.e. the heuristic never overestimates the distance.
●Graceful decay of admissability. Be strict about admissability at the beginning of the search but as the search is assumed to get closer to the destination relax the admissability criterion.
![Page 23: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/23.jpg)
23
SearchSearch
●Combinatorial explosion: the problem whereby rules in combination give rise to a large number of alternatives.
●Dealing with the complexity of the real world.
●Simplification. Using a less detailed representation
●Level-of-detail, e.g. different sized grids for pathfinding, rule based system can have different levels.
![Page 24: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/24.jpg)
24
SearchSearch
●Representations: grids, waypoints, regions, points-of-visibility.
●Map design.
![Page 25: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/25.jpg)
25
Game characteristicsGame characteristics
perfect information imperfect information
2-player n-player
simple physical world complex physical world
timing - precise time periods
timing - variable time periods
precise goals imprecise goals
![Page 26: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/26.jpg)
26
MathsMaths
●Maths:
●vectors:● length
● normalisation
●dot product
●cross product
●angle
cos wvwv
![Page 27: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/27.jpg)
27
TargetingTargeting●Test of "in front of", or "behind".
● x is the gun's x-axis.
● w is the vector from the gun to the target.
● x • w > 0 if the target is to the right
● x • w = 0 if the target is straight ahead.
● x • w < 0 if the target is to the left
●Also "to left of", or "to right of".
●Deriving the local axis, e.g. local x-axis.
![Page 28: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/28.jpg)
28
TargetingTargeting
●Construct a LookAt function. You need to be able to write down how the function is constructed. You need to understand:
● length of a vector
●normalise a vector
●dot product
●cross product
● the relevant axes
●Write down the procedure in full
![Page 29: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/29.jpg)
29
Interpolation and splinesInterpolation and splines
●Path smoothing is the process of smoothing out the angular route produced by the search method. So implemented after the search has been calculated.
●Be able to define and describe the terms.
●Describe and discuss what a spline is.
●Describe and discuss interpolation.
●Describe and discuss the characteristics of the Catmull-Rom and Bézier curve.
● Interpolation of the tangents.
![Page 30: 1 CO2301 - Games Development 1 Week 13 - Revision Lecture AI Revision Gareth Bellaby](https://reader035.vdocuments.net/reader035/viewer/2022070414/5697c0021a28abf838cc3580/html5/thumbnails/30.jpg)
30
Interpolation and splinesInterpolation and splines
●Path smoothing.
●Smoothing is implemented through the use of interpolation - calculating points in between our known points.
●Looked at a method of generating a curve called the Catmull-Rom spline.
●Generate tangents based on the position of the sample points.