gdc gameplay replication in acu with videos

54
Gameplay and AI networking in Assassin’s Creed Unity Charles Lefebvre AI programmer, Ubisoft Montreal [email protected], @FrozenInMtl

Upload: charles-lefebvre

Post on 14-Jul-2015

366 views

Category:

Presentations & Public Speaking


0 download

TRANSCRIPT

Page 1: Gdc   gameplay replication in acu with videos

Gameplay and AI networking

in Assassin’s Creed Unity

Charles Lefebvre

AI programmer, Ubisoft Montreal

[email protected], @FrozenInMtl

Page 2: Gdc   gameplay replication in acu with videos

Unity

Page 3: Gdc   gameplay replication in acu with videos

Unity

Page 4: Gdc   gameplay replication in acu with videos

Unity

Page 5: Gdc   gameplay replication in acu with videos

Unity

Page 6: Gdc   gameplay replication in acu with videos

Unity

Page 7: Gdc   gameplay replication in acu with videos
Page 8: Gdc   gameplay replication in acu with videos

glossary

Migration

Entity

Join in progress

Session Memento

NetObject

Master

Replica

Simulation bubble

PeerPeer to peer

Player

Multiplayer

Network keyDiscovery

Host

Components

Coop

Page 9: Gdc   gameplay replication in acu with videos

NetObject

glossary

M

Peer 1 Visual component

AI component

Animation component

Network component

Network key

Entity

Network key (u64) = peer + type + ID

Page 10: Gdc   gameplay replication in acu with videos

glossary

M R

Peer 1 Peer 2

Mementos

M

Page 11: Gdc   gameplay replication in acu with videos

NetTokens

NetTokens: Layer for peer to peer conflict resolution

t=5

t=4

no

Peer1

yesPeer2 Peer3

t=4

t=5

yes

yes

Page 12: Gdc   gameplay replication in acu with videos

NetTokens

Can also be used to wait for all players

t=5

t=4

Peer1

Peer2 Peer3

t=4

t=5

t=6

t=6

Page 13: Gdc   gameplay replication in acu with videos

remote procedure call

Remote procedure call (RPC): execute a function on a peer, this function

will be executed on other peers

network void PlayAnimation(const AnimationParams & params);

• Can be ordered or not

• Can be persisted for Join In Progress

• Can be executed later, or re-executed

Page 14: Gdc   gameplay replication in acu with videos

Flow examples:

remote procedure call

Replica Replica Replica

Master

Replica Replica

Master

Replica Replica

Master

Page 15: Gdc   gameplay replication in acu with videos

NetHandle

struct NetHandle{

Handle<Entity> m_Entity;NetKey m_NetKey;

bool IsValid();Entity * GetEntity();bool GetPosition(vec4& position);bool GetSight(vec4& position);

}

Page 16: Gdc   gameplay replication in acu with videos

NetHandle

?

NetHandle

(full entity)

??

?

Simulation

bubble

Undiscovered

entity

Page 17: Gdc   gameplay replication in acu with videos
Page 18: Gdc   gameplay replication in acu with videos

Spawning strategy

Spawning client

system

Spawning

request Spawning strategy

Spawning manager

Spawning strategy

Mementos

Page 19: Gdc   gameplay replication in acu with videos

Peer 1 (spawner)

simulation bubble

M

replication

Net descriptor

Spawning

request

Spawning

requestR

Page 20: Gdc   gameplay replication in acu with videos

replication

Peer 1

loading range

Peer 2

loading range

Spawning

request

Spawning

requestToken

M R

Page 21: Gdc   gameplay replication in acu with videos

gameplay

• Replicate the crowd event generation in echo

• Replicate the victim/thief in engine

Page 22: Gdc   gameplay replication in acu with videos

conclusions

(+) Almost no change in the spawning clients code

(+) Cheap in bandwidth

(+) Data is the same in single and multiplayer

(-) No network balancing

(-) A lot of edge cases to handle when a spawning request is cancelled

(-) Systemic gameplay is not easy to replicate

Page 23: Gdc   gameplay replication in acu with videos
Page 24: Gdc   gameplay replication in acu with videos

objectives

• Need a way to replicate the player’s movements with good accuracy

• Animation quality of replicas must be the same as masters

• Must support join in progress

• Shouldn’t take too much bandwidth

Page 25: Gdc   gameplay replication in acu with videos

comparison tool

Page 26: Gdc   gameplay replication in acu with videos

HSM

Animation

NetBehaviorAI

Replica

Replica Brain

flow

Controller

HSM

Animation

NetBehaviorAI

Master

Replication

Final decisions

Page 27: Gdc   gameplay replication in acu with videos

final decisions

Page 28: Gdc   gameplay replication in acu with videos

conclusions

(+) Good replication quality

(+) Can recover nicely from divergences

(-) Expensive in bandwidth

(-) 3 state machines (HSM / NetBehaviorAI / animation graph) to

maintained

Page 29: Gdc   gameplay replication in acu with videos
Page 30: Gdc   gameplay replication in acu with videos

• Replicate NPC behavior at a very low cost

objectives

• Not a perfect match: not a first person game

• Quality of realization: same for masters and replicas

• Existing behaviors easily updated to support multiplayer

Page 31: Gdc   gameplay replication in acu with videos

flow

Logic

HSM

Animation

HSM

Animation

Intentions

Master

Intentions

Replica

Logic

Replication

Page 32: Gdc   gameplay replication in acu with videos

replication

Animations Navigation Weapons LookAt

Idle IdleIdle Idle

Play animation

Push

Stumble

Go to position

Wander

Follow

Sheath

Unsheath

Fire

Look at

position

Look at

target

RPC

Page 33: Gdc   gameplay replication in acu with videos

conclusions

(+) Cheap in bandwidth

(+) Seamless migrations

(-) Average replication quality

(-) Services (navigation, animation…) must also be synchronized to

prevent behavior branching

Page 34: Gdc   gameplay replication in acu with videos
Page 35: Gdc   gameplay replication in acu with videos

coordinators

• Spawn NPCs

• UI

• Interactions

Page 36: Gdc   gameplay replication in acu with videos

coordinators

Sensors

Distance

Line of sight

UI

Coordinators in previous Assassin’s Creed games

Actions

Page 37: Gdc   gameplay replication in acu with videos

coordinators

Net data

Sensors synthesis

Execution count

Local state

Released entities

For local player

Sensors

Distance

Line of sight

UI

Actions

R

M

M

Page 38: Gdc   gameplay replication in acu with videos

coordinators

Replica

Net data

Sensors

synthesis

Sensors

Replica

Net data

Sensors

synthesis

Sensors

Master

Net data

Sensors

synthesis

RPCSensors

RPCRPC

MementoMemento

Page 39: Gdc   gameplay replication in acu with videos

conclusions

(+) Good replication quality

(+) Cheap in bandwidth

(+) Code and data are the same in single and multiplayer

(-) Join in progress can be tricky

(-) Reaction times can become noticeable

Page 40: Gdc   gameplay replication in acu with videos
Page 41: Gdc   gameplay replication in acu with videos

stations

Page 42: Gdc   gameplay replication in acu with videos

stations

How does it work in single player :

• Crowd Life Manager updates all stations

• Stations = data containers (not systemic)

• Stations loaded with cells

• NPCs spawned/released by stations

Page 43: Gdc   gameplay replication in acu with videos

stations

• Amount of stations and NPCs to track

Challenges of replicating:

• Stations are not replicated

• NPCs in stations can be masters, replicas, or even non-

replicated entities

Page 44: Gdc   gameplay replication in acu with videos

replication

Page 45: Gdc   gameplay replication in acu with videos

replication

What to replicate ?

• NPCs

• Station state

Master = token winner

Page 46: Gdc   gameplay replication in acu with videos

split mastering

Crowd Life

Manager

Stations

NPCs

Peer 1

NetObject

(master)

Peer 2

NetObject

(replica)

Peer 3

NetObject

(replica)

Peer 4

NetObject

(replica)

Crowd Life

Manager

Stations

NPCs

Peer 2

NetObject

(master)

Peer 1

NetObject

(replica)

Peer 3

NetObject

(replica)

Peer 4

NetObject

(replica)

Peer 1 Peer 2

Replication

s

Memento

Memento

Page 47: Gdc   gameplay replication in acu with videos

conclusions

(+) Only 1 net object per peer = big gains on bandwidth/CPU

(+) Each peer can run their own logics

(+) Data is already available on discovery

(-) Data is broadcast on all peers even if they don’t need it

(-) Execution logic tends to be complicated

Page 48: Gdc   gameplay replication in acu with videos
Page 49: Gdc   gameplay replication in acu with videos

statsCurrent bps

Page 50: Gdc   gameplay replication in acu with videos

stats

• Below TRC of 92 kbps per peer (around 30 kbps outside fight)

• Most expensive systems:

• Proxies: list of vectors

• Player, but high replication quality

• Crowd life: lots of stations, actually cheap per station

Page 51: Gdc   gameplay replication in acu with videos

quality

Page 52: Gdc   gameplay replication in acu with videos

conclusion

(+) Cheap in bandwidth, no additional CPU cost

(+) Good replication quality

(+) Multiplayer team = gameplay team

(-) Limited to a low number of players

(-) Hard to identify sources of divergences

Page 53: Gdc   gameplay replication in acu with videos

conclusion

Existing code kept

and converted to

multiplayer

Page 54: Gdc   gameplay replication in acu with videos