Feb22010

Feb22010 - UC Santa Cruz Computer Science Game Design CMPS...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
Computer Science – Game Design UC Santa Cruz Click to edit Master subtitle style 11/10/10 CMPS 20: Game Design Experience 2D Movement Pathfinding
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Computer Science – Game Design UC Santa Cruz 11/10/10 Path Following at Constant In previous lecture showed path following Used Lerp and CatmullRom interpolation methods built into Vector2 class These methods take an amount A number between 0 and 1 indicating the percentage distance between the start and end points (a “weight”) Problem A given amount can result in different perceived speeds, depending on the length of the line Solution Given a desired speed in terms of units per clock tick Compute per-tick change in amount as follows
Background image of page 2
Computer Science – Game Design UC Santa Cruz 11/10/10 Pathfinding In many games, computer controlled opponents need to move from one place to another in the game world If the start and end points are known in advance, and never change, Can simply define a fixed path Computed before the game begins Use path following techniques from previous lecture Most platformers do this
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Computer Science – Game Design UC Santa Cruz 11/10/10 Pathfinding Representations Waypoints Navigation Meshes
Background image of page 4
Computer Science – Game Design UC Santa Cruz 11/10/10 All Pairs Shortest Path Assume a labeled directed graph Nodes are pathnodes in your map Labels are the distances between connecting nodes (or other specific cost information) G=(V, E) in which each arc v w has a non-negative cost C[v,w]. Find, for each ordered pair (v,w) the
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Computer Science – Game Design UC Santa Cruz 11/10/10 All Pairs Shortest Path Floyd’s Algorithm Assume the vertices in V are numbered 1,. ..,n . Use an n X n matrix in which to compute the lengths of the shortest paths.
Background image of page 6
Computer Science – Game Design UC Santa Cruz 11/10/10 All Pairs Shortest Path Floyd’s Algorithm Set A[i,j] = C[i,j] for all i not equal to j . If there is no arc from i to j , then assume C[i,j] = ∞. Each diagonal element is set to 0.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Computer Science – Game Design UC Santa Cruz 11/10/10 All Pairs Shortest Path Floyd’s Algorithm Make n iterations over the matrix On the kth iteration, A[i,j] will have for its value the smallest length of any path from i to j that doesn’t pass through a vertex numbered higher than k.
Background image of page 8
Computer Science – Game Design UC Santa Cruz 11/10/10 All Pairs Shortest Path Floyd’s Algorithm On the kth iteration, use the following formula to compute A Ak-1[i,j] A[i,j] = min { Ak-1[i,k] + Ak-1[k,j]
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Computer Science – Game Design UC Santa Cruz 11/10/10 All Pairs Shortest Path Floyd’s Algorithm On the kth iteration, use the following formula to compute A Ak-1[i,j] A[i,j] = min { Ak-1[i,k] + Ak-1[k,j] The cost of going from i to j without going through k or any higher node
Background image of page 10
Computer Science – Game Design UC Santa Cruz 11/10/10 All Pairs Shortest Path Floyd’s Algorithm On the
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 46

Feb22010 - UC Santa Cruz Computer Science Game Design CMPS...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online