Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCE 552 Spring 2012 AI (III) & Multiplayer By Jijun Tang.

Similar presentations


Presentation on theme: "CSCE 552 Spring 2012 AI (III) & Multiplayer By Jijun Tang."— Presentation transcript:

1 CSCE 552 Spring 2012 AI (III) & Multiplayer By Jijun Tang

2 Searching for a Path A path is a list of cells, points, or nodes that an agent must traverse A pathfinding algorithm finds a path  From a start position to a goal position The following pathfinding algorithms can be used on  Grids  Waypoint graphs  Navigation meshes

3 Criteria for Evaluating Pathfinding Algorithms Quality of final path Resource consumption during search  CPU and memory Whether it is a complete algorithm  A complete algorithm guarantees to find a path if one exists

4 PathPlannerApp Demo

5 Characteristics of Grids Fast look-up Easy access to neighboring cells Complete representation of the level

6 Waypoint Graph A waypoint graph specifies lines/routes that are “ safe ” for traversing Each line (or link) connects exactly two waypoints

7 Navigation Meshes (continued)

8 Example—No Rotation

9 Resulted Path

10 Example 2—With Rotation

11 Random Trace Simple algorithm  Agent moves towards goal  If goal reached, then done  If obstacle Trace around the obstacle clockwise or counter-clockwise (pick randomly) until free path towards goal  Repeat procedure until goal reached

12 Random Trace (continued) How will Random Trace do on the following maps?

13 Random Trace Characteristics Not a complete algorithm Found paths are unlikely to be optimal Consumes very little memory

14 A* Pathfinding Directed search algorithm used for finding an optimal path through the game world Used knowledge about the destination to direct the search A* is regarded as the best  Guaranteed to find a path if one exists  Will find the optimal path  Very efficient and fast

15 Understanding A* To understand A*  First understand Breadth-First, Best-First, and Dijkstra algorithms These algorithms use nodes to represent candidate paths

16 Class Definition class PlannerNode { public: PlannerNode *m_pParent; int m_cellX, m_cellY;... }; The m_pParent member is used to chain nodes sequentially together to represent a path

17 Data Structures All of the following algorithms use two lists  The open list  The closed list Open list keeps track of promising nodes When a node is examined from open list  Taken off open list and checked to see whether it has reached the goal If it has not reached the goal  Used to create additional nodes  Then placed on the closed list

18 Overall Structure of the Algorithms 1. Create start point node – push onto open list 2. While open list is not empty A. Pop node from open list (call it currentNode) B. If currentNode corresponds to goal, break from step 2 C. Create new nodes (successors nodes) for cells around currentNode and push them onto open list D. Put currentNode onto closed list

19 Breadth-First Finds a path from the start to the goal by examining the search space ply-by-ply

20 Breadth-First Characteristics Exhaustive search  Systematic, but not clever Consumes substantial amount of CPU and memory Guarantees to find paths that have fewest number of nodes in them  Not necessarily the shortest distance! Complete algorithm

21 Best-First Uses problem specific knowledge to speed up the search process Head straight for the goal Computes the distance of every node to the goal  Uses the distance (or heuristic cost) as a priority value to determine the next node that should be brought out of the open list

22 Best-First (continued)

23 Situation where Best-First finds a suboptimal path

24 Best-First Characteristics Heuristic search Uses fewer resources than Breadth- First Tends to find good paths  No guarantee to find most optimal path Complete algorithm

25 Dijkstra Disregards distance to goal  Keeps track of the cost of every path  No guessing Computes accumulated cost paid to reach a node from the start  Uses the cost (called the given cost) as a priority value to determine the next node that should be brought out of the open list

26 Dijkstra Characteristics Exhaustive search At least as resource intensive as Breadth-First Always finds the most optimal path Complete algorithm

27 Example

28 A* Uses both heuristic cost and given cost to order the open list Final Cost = Given Cost + (Heuristic Cost * Heuristic Weight)

29 A* Characteristics Heuristic search On average, uses fewer resources than Dijkstra and Breadth-First Admissible heuristic guarantees it will find the most optimal path Complete algorithm

30 Example

31 Start Node and Costs F=G+H

32 First Move

33 Second Move

34 Cost Map

35 Path

36 Pathfinding with Constraints

37 More Example

38 Multiplayer Modes: Event Timing Turn-Based  Easy to implement  Any connection type Real-Time  Difficult to implement  Latency sensitive

39 Multiplayer Modes: Shared I/O Input Devices  Shared keyboard layout  Multiple device mapping Display  Full Screen and Screen Swap  Split Screen

40 Split Screen

41 Multiplayer Modes: Connectivity Non Real-Time  Floppy disk net  Email  Database Direct Link  Serial, USB, IrD, … (no hops) Circuit Switched (phones)  Dedicated line with consistent latency Packet Switched  Internet  Shared pipe

42 Protocols: Protocol Design Packet Length Conveyance Acknowledgement Methodology Error Checking / Correcting Compression Encryption Packet Control

43 Protocols: Packets Packets  Header = Protocol Manifest  Payload Gottchas  Pointers  Large/Variable Size Arrays  ADTs  Integer Alignment  Endian Order  Processor dependant Intrinsic Types (int and long)  Unicode vs. ASCII Strings

44 Protocols: Request for Comments RFC web site  http://www.rfc-editor.org/ http://www.rfc-editor.org/ Protocol Specifications  Definitive Resource  Public Criticism  Future Protocols

45 Example Packets IP Packet TCP Packet

46 Protocol Stack: Open System Interconnect

47 Another View

48 Protocol Stack: Physical Layer Bandwidth  Width of data pipe  Measured in bps = bits per second Latency  Travel time from point A to B  Measured in Milliseconds  You cannot beat the physics The Medium  Fiber, FireWire, IrD, CDMA & other cell Serial USB 1&2 ISDNDSLCable LAN 10/100/1G BaseT Wireless 802.11 a/b/g Power Line T1 Speed (bps) 20K 12M 480M 128k 1.5M down 896K up 3M down 256K up 10M 100M 1G b=11M a,g=54M 14M1.5M Table: Max Bandwidth Specifications

49 Protocol Stack: Data Link Layer Serializes data to/from physical layer Network Interface Card (NIC)  Ethernet  MAC Address

50 Protocol Stack: Network Layer Packet Routing  Hops  Routers, Hubs, Switches Internet Protocol (IP)  Contains Source & Destination IP Address  IPv4 Widespread Infrastructure  IPv6 Larger IP address

51 Protocol Stack: Network Layer: IP Address Unicast  Static  DHCP Multicast  Requires multicast capable router Broadcast  Local  Directed Loop Back  Send to self

52 Protocol Stack: Network Layer: DNS Domain Name Service  Converts text name to IP address  Must contact one or more DNS servers to resolve  Local cache resolution possible Game Tips  Store local game cache to use when DNS out of order.  DNS resolution often slow, use cache for same day resolution.

53 DNS

54 Protocol Stack: Transport Layer Manage data deliver between endpoints  Error recovery  Data flow TCP and UDP used with IP  Contains Source and Destination Port  TCP is connection-oriented, UDP is connectionless Port + IP = Net Address  Port Range = 0-64k  Well known Ports 0-1k

55 Protocol Stack: Transport Layer: TCP Guaranteed Correct In Order Delivery  Acknowledgement system: Ack, Nack, Resend  Checksum  Out of Band Connection Required  Packet Window  Packet Coalescence (united)  Keep Alive Streamed Data  User must serialize data

56 Protocol Stack: Transport Layer: UDP Non Guaranteed Delivery  No Acknowledgement system  May arrive out of order  Checksum Not Connected  Source not verified  Hop Count Limit = TTL (time to live)  Required for Broadcasting Datagram  Sent in packets exactly as user sends them

57 TCP/UDP Comparison

58 Protocol Stack: Session Layer Manages Connections between Apps  Connect  Terminate  Data Exchange Socket API live at this layer  Cross platform  Cross language

59 Protocol Stack: Session Layer: Sockets Based on File I/O  File Descriptors  Open/Close  Read/Write Winsock  Provides standard specification implementation plus more  Extension to spec prefixed with “ WSA ”  Requires call to WSAStartup() before use  Cleanup with WSAShutdown()

60 Protocol Stack: Session Layer: Socket Design Modes  Blocking  Non-Blocking Standard Models  Standard  Select Extended Models  Windows WSAEventSelect I/O Completion Ports  Unix Poll Kernel Queues

61 Socket Programming

62 Socket Programming-2

63 Socket Programming -3

64 Socket Programming -4

65 Protocol Stack: Presentation Layer Prepares App Data for Transmission  Compression Pascal Strings String Tables Float to Fixed Matrix to Quaternion  Encryption  Endian Order When used cross platform or cross language  Serialize Pointers Variable Length Arrays

66 Endian Order

67 Protocol Stack: Presentation Layer: Buffering Packet Coalescence Induced Latency Dead Data Large Packets

68 Protocol Stack: Application Layer Handles Game Logic Update Models  Input Reflection  State Reflection Synchronization  Dead Reckoning  AI Assist  Arbitration

69 Real-Time Communications: Connection Models Broadcast  Good for player discovery on LANs Peer to Peer  Good for 2 player games Client / Server  Good for 2+ player games  Dedicated lobby server great for player discovery

70 Real-Time Communications: Peer to Peer vs. Client/Server BroadcastPeer/PeerClient/Server Connections0 Client = 1 Server = N N = Number of players BroadcastPeer/PeerClient/Server Send1N-1 Client = 1 Server = N ReceiveN-1 Client = 1 Server = N

71 Security: Encryption Goals Authentication Privacy Integrity

72 Security: Encryption Methods Keyed  Public Key  Private Key  Ciphers Message Digest Certificates IPSec (Internet Protocol Security)

73 IPSec

74 Security: Copy Protection Disk Copy Protection  Costly Mastering, delay copies to ensure first several months ’ sale  Invalid/Special Sector Read Code Sheets  Ask code from a line in a large manual Watermarking

75 Security: Execution Cryptography Code Obfuscation  Strip Symbols: int numOfPlayer;  int a1; Heap Hopper  Move sensitive data around in the heap to avoid snapshots Stack Overrun Execution  Check for buffer overflow Timer Hacking  Do not allow time to change backward DLL Shims

76 Privacy Critical data should be kept secret and strong encrypted:  Real name  Password  Address/phone/email  Billing  Age (especially for minors) Using public key for transforming user name and password

77 Security: Firewalls Packet Filter  Allow a packet based on its headers Proxies  Check contents Circuit Gateways  Setup secure sessions

78 Security: Firewalls: Network Address Translation

79 Security: Firewalls: NAT Traversal Port Forwarding Port Triggering DMZ Determining WAN IP

80 Summary: Further Study Socket Programming Serial Communication Server Design Network Gear & Infrastructure VOIP Tools of the Trade Unit & Public Beta Testing Middleware Databases Web Development Asynchronous Programming


Download ppt "CSCE 552 Spring 2012 AI (III) & Multiplayer By Jijun Tang."

Similar presentations


Ads by Google