SlideShare a Scribd company logo
1 of 30
Download to read offline
Deterministic Simulation
What modern online games can learn from the Game Boy
David Salz
CTO, Sandbox Interactive
Who am I?
 CTO, Co-Founder of Sandbox Interactive
 15 years in the industry
 Albion Online:
 Sandbox MMORPG
 Cross-Platform (Windows/OSX/Linux/Android/iOS)
 Player-Driven Economy (everything is player-crafted)
 Strong focus on PvP + Guilds
 Currently in Beta w/ 120.000+ „founding“ players
 Using Unity Engine
Agenda
 Deterministic Simulation – A short reminder
 How RTS-style games use it
 How MMO-style games can still use it!
 The pitfalls: How to do it and what to avoid
 A few tricks with deterministic randomness
 A few examples from Albion Online
Gameboy Multiplayer
 Link cable had very limited
throughput
 … as in: a few bytes per
frame and player
 Syncing complex game state
is impossible
 Instead: used like a controller cable! Deterministic
simulation on all devices
 Frame updates are synced (effectively „lock-stepping“)
 Still used on DSi and 3DS
Deterministic Simulation?
 This should be an old hat, but…
 Deterministic: same input  same output
 Input[i] × State[i-1] = State[i]
 where i is the simulation step number
 Given State[0] and same sequence of inputs Input[1..n]
 … all clients will produce same Sequence State[1..n]
S[0] S[1] S[2] S[3]
I[1] I[2] I[3]
Deterministic Simulation!
 This is cool because:
 Only need to send State[0] and Inputs through network!
 Only Inputs if State[0] is known
 Can save replays by saving only Inputs!
 You can debug replays of bugs!
 Difficulties:
 one mistake and the clients „desync“
 must be independent of frame/thread timings
 requires lock-stepping for online games
 Late join requires you to send State[n]
 Dead Reckoning:
 Extrapolate future state of an object based on a known
state and current behavior
 Example: movement of a mob TimeStamp: T510
Positon: 210, 425
MoveTarget: 190, 415
MoveSpeed: 2/s
AttackTarget: MadDave
Predicted
current position
Known, past
position
Deterministic Simulation vs. Dead Reckoning
Deterministic Simulation vs. Dead Reckoning
 But: this is only a prediction! May be incorrect and client may
act on incorrect info!
 May have to correct state given new information!
T2: 504
Timestamp T0
Health = 500, +2/s
T3: 506
T4: 508
T5: 510
Timestamp T4
Health = 400, +10/s
T6: 420
Wrong!
Wrong!
Network
Delay: 2
Lock-stepping (1)
 This is how RTS games do it
 Basically everything from Age of Empires to Starcraft2
 Collect input from all players, send it to all players
 Simulation step i can only happen when input from all players for step i has
arrived (stepping is „synced“ or „locked“
 Collect input a little earlier to account for ping
 Allows high unit count with super-small bandwidth!
Lock-stepping (2)
Simulate S[1]
Collect I[3]
Simulate S[2]
Collect I[4]
Simulate S[3]
Collect I[5]
Client 1 Client 2Server
(may run on a Client)
Collect I[3] from all
Send I[3] to all
Collect I[4] from all
Send I[4]to all
Simulate S[1]
Collect I[3]
Simulate S[2]
Collect I[4]
Simulate S[3]
Collect I[5]
Lock-stepping (3)
 Problems:
 Slowest player’s ping will be felt by all players
 Worst case: „waiting for player“
 Input delay is noticeable
 Usually covered by animation, audio prompt etc.
 Difficult to handle drop-out / late join
  only suitable for very limited number of players!
Actor-based determinism (1)
 Lock-stepping is not suitable for MMOs!
 Cannot wait for players (worst ping = everyone's ping!)
 Single player cannot „see“ full game state (just too big)
 Everyone does a „late Join“
 BUT: can still use deterministic simulation for a single
actor
 … as long as behavior depends only on actor itself
 example: roaming behavior of a mob (later)
 Can mix with dead reckoning
 Also great for visual stuff w/o gameplay influence
Actor-based determinism (2)
Farm Animal
- roaming around
- just eye candy!
MOBs
- gameplay relevant
- attackable
- can attack
- roaming around
Pitfalls & Common Mistakes
 Uninitialized variables, dangling pointers etc.
 add an unwanted random element to the simulation
 Undefined behavior of C++ or library functions
 Random number generators behave differently across library versions! (Roll your
own!)
 Use fixed simulation timing!
 simulation MUST NOT depend on frame timing
 but rendering, animation MUST…
 Need a clean separation of simulation and presentation
Separation
ObjectFactory ObjectViewFactory
Object
+Position
+…
+RequestAction()
ObjectView
+Renderer
+AnimationCtrl
+HandleInput()
destroyed
changed
…etc..
created
Object
+Position
+…
+RequestAction()
Server Client Unity-Client
Interest-
Management
changed
…etc..
obj-enter
obj-leave
The trouble with float (1)
 IEEE standard: only +, –, *, /, sqrt guaranteed to give same results
everywhere
 not: sin, cos, tan etc. (different on different CPU types)
 CPU can store numbers in float or double format
 how intermediate results are stored is often unspecified (depends on
compiler)
 x86: per-thread settings for precision, exceptions, rounding, denormal support
 … check the manual of your target CPUs…
 different feature sets (SIMD sets like MMX, SSE etc.)
The trouble with float (2)
 You can make floats work if…
 … you stick to +, –, *, /, sqrt (write the rest yourself)
 … you can configure compiler behavior (intermediate precision, instruction set
used)
 … you can control CPU behavior (precision, rounding etc.)
 Best: one target CPU type, same binary for all clients
 You are in trouble if…
 … you need to support a JIT environment
 … you need to target different CPUs
 … you need to use different compilers
Fixed Point numbers (1)
 Idea: create fractional number type based on integers
 … and use only this in (deterministic) simulation
 again: clean separation of gameplay / rendering is
important
 e.g. 110.010
= 1*22 + 1*21 + 0*20 + 0*2-1 + 1*2-2 +0*2-3
= 1*4 + 1*2 + 0*1 + 0*0,5 + 1*0,25 + 0*0,125
= 6,25
Deterministic Randomness
 Random number generators are deterministic
 Provided same initial seed, will produce same random
sequence
 Many copy-paste-ready implementations exist
 E.g. Mersenne Twister, WELL, XORshift
 (Wikipedia has a list!)
 Watch out for:
 period length
 memory footprint
 speed
 warmup period
 But can we „seek“ inside the random sequence?
Cryptographic Hashes
 Cryptographic Hash functions can be used as random number sources!
 Hash Function: converts data into unique integer
 i.e. byte[]  int
 … seeks to avoid „collisions“ (i.e. different data should produce hash;
meaning equal distribution of hashes)
 Cryptographic hash function: not easily reversible
 i.e. output must appear random!
Seekable random sequences
 Cryptographic Hashes can be used to build seekable
random number generators!
 because Hash(i) is random, even if i = {0,1,2,3,4,5… n}
 Note: you can do this with timestamps, coordinates,
… anything really!
Seekable random sequences
for(int i=0; i<1000; i+=2)
{
DrawPoint(Hash(i) % 300, Hash(i+1) % 300)
}
Adler32 MD5
Example: Mob Roaming Behavior
 given:
 Mob „Home“ position
 Roaming Radius
 repeat:
 pick random point inside roaming circle
 walk to random point (stop if path is
blocked)
 wait for random time (between a given min
and max)
StartNextCycle(startTimeStamp, startPosition)
{
init RNG with startTimeStamp
pick „random“ moveTarget point
if(there is a collision on the way there)…
… the collision point is the moveTarget
calculate the walkTime to moveTarget
pick a random waitTime
endTimeStamp = startTimeStamp + walkTime + waitTime
}
Render(nowTimeStamp)
{
while(nowTimeStamp > endTimeStamp)
StartNextCycle(endTimeStamp, moveTarget)
if(nowTimeStamp < startTimeStamp + walkTime)
position = LERP(startPosition, moveTarget)
else
position = moveTarget
}
Live Demo!
Takeaway
 Deterministic Simulation can greatly reduce network traffic in
online/multiplayer games
 RTS-style games use fully deterministic gameplay with lock-stepping
 MMO-style games can still use actor-based deterministic simulation
 May have to use fixed point instead of float
 Hash functions are great for „randomness“ (including seekable random
sequences!)
References
 1500 Archers on a 28.8
 http://www.gamasutra.com/view/feature/131503/1500_archers_on_a_288_network_.php
 Floating-Point Determinism
 https://randomascii.wordpress.com/2013/07/16/floating-point-determinism/
 List of random number generators
 https://en.wikipedia.org/wiki/List_of_random_number_generators
Thank you!
Questions / Comments?
david@sandbox-interactive.com
We are hiring!
https://albiononline.com/en/jobs

More Related Content

What's hot

테라로 살펴본 MMORPG의 논타겟팅 시스템
테라로 살펴본 MMORPG의 논타겟팅 시스템테라로 살펴본 MMORPG의 논타겟팅 시스템
테라로 살펴본 MMORPG의 논타겟팅 시스템QooJuice
 
서비스중인 게임 DB 설계 (쿠키런 편)
서비스중인 게임 DB 설계 (쿠키런 편)서비스중인 게임 DB 설계 (쿠키런 편)
서비스중인 게임 DB 설계 (쿠키런 편)_ce
 
실시간 게임 서버 최적화 전략
실시간 게임 서버 최적화 전략실시간 게임 서버 최적화 전략
실시간 게임 서버 최적화 전략YEONG-CHEON YOU
 
[KGC 2012] Online Game Server Architecture Case Study Performance and Security
[KGC 2012] Online Game Server Architecture Case Study Performance and Security[KGC 2012] Online Game Server Architecture Case Study Performance and Security
[KGC 2012] Online Game Server Architecture Case Study Performance and SecuritySeungmin Shin
 
NDC12_Lockless게임서버설계와구현
NDC12_Lockless게임서버설계와구현NDC12_Lockless게임서버설계와구현
NDC12_Lockless게임서버설계와구현noerror
 
05_Reliable UDP 구현
05_Reliable UDP 구현05_Reliable UDP 구현
05_Reliable UDP 구현noerror
 
[야생의 땅: 듀랑고] 서버 아키텍처 Vol. 2 (자막)
[야생의 땅: 듀랑고] 서버 아키텍처 Vol. 2 (자막)[야생의 땅: 듀랑고] 서버 아키텍처 Vol. 2 (자막)
[야생의 땅: 듀랑고] 서버 아키텍처 Vol. 2 (자막)Heungsub Lee
 
Multiplayer Game Sync Techniques through CAP theorem
Multiplayer Game Sync Techniques through CAP theoremMultiplayer Game Sync Techniques through CAP theorem
Multiplayer Game Sync Techniques through CAP theoremSeungmo Koo
 
스마트폰 온라인 게임에서 고려해야 할 것들
스마트폰 온라인 게임에서 고려해야 할 것들스마트폰 온라인 게임에서 고려해야 할 것들
스마트폰 온라인 게임에서 고려해야 할 것들Hyunjik Bae
 
iFunEngine: 30분 만에 게임 서버 만들기
iFunEngine: 30분 만에 게임 서버 만들기iFunEngine: 30분 만에 게임 서버 만들기
iFunEngine: 30분 만에 게임 서버 만들기iFunFactory Inc.
 
홍성우, 게임 서버의 목차 - 시작부터 출시까지, NDC2019
홍성우, 게임 서버의 목차 - 시작부터 출시까지, NDC2019홍성우, 게임 서버의 목차 - 시작부터 출시까지, NDC2019
홍성우, 게임 서버의 목차 - 시작부터 출시까지, NDC2019devCAT Studio, NEXON
 
게임회사 실무용어 완전정복! 쿡앱스 용어정리집
게임회사 실무용어 완전정복! 쿡앱스 용어정리집 게임회사 실무용어 완전정복! 쿡앱스 용어정리집
게임회사 실무용어 완전정복! 쿡앱스 용어정리집 CookApps
 
[IGC 2017] 펄어비스 민경인 - Mmorpg를 위한 voxel 기반 네비게이션 라이브러리 개발기
[IGC 2017] 펄어비스 민경인 - Mmorpg를 위한 voxel 기반 네비게이션 라이브러리 개발기[IGC 2017] 펄어비스 민경인 - Mmorpg를 위한 voxel 기반 네비게이션 라이브러리 개발기
[IGC 2017] 펄어비스 민경인 - Mmorpg를 위한 voxel 기반 네비게이션 라이브러리 개발기강 민우
 
임태현, MMO 서버 개발 포스트 모템, NDC2012
임태현, MMO 서버 개발 포스트 모템, NDC2012임태현, MMO 서버 개발 포스트 모템, NDC2012
임태현, MMO 서버 개발 포스트 모템, NDC2012devCAT Studio, NEXON
 
Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)Esun Kim
 
임태현, 게임 서버 디자인 가이드, NDC2013
임태현, 게임 서버 디자인 가이드, NDC2013임태현, 게임 서버 디자인 가이드, NDC2013
임태현, 게임 서버 디자인 가이드, NDC2013devCAT Studio, NEXON
 
Next-generation MMORPG service architecture
Next-generation MMORPG service architectureNext-generation MMORPG service architecture
Next-generation MMORPG service architectureJongwon Kim
 
NoSQL 위에서 MMORPG 개발하기
NoSQL 위에서 MMORPG 개발하기NoSQL 위에서 MMORPG 개발하기
NoSQL 위에서 MMORPG 개발하기Hoyoung Choi
 
혼자서 만드는 MMO게임 서버
혼자서 만드는 MMO게임 서버혼자서 만드는 MMO게임 서버
혼자서 만드는 MMO게임 서버iFunFactory Inc.
 
Unity Internals: Memory and Performance
Unity Internals: Memory and PerformanceUnity Internals: Memory and Performance
Unity Internals: Memory and PerformanceDevGAMM Conference
 

What's hot (20)

테라로 살펴본 MMORPG의 논타겟팅 시스템
테라로 살펴본 MMORPG의 논타겟팅 시스템테라로 살펴본 MMORPG의 논타겟팅 시스템
테라로 살펴본 MMORPG의 논타겟팅 시스템
 
서비스중인 게임 DB 설계 (쿠키런 편)
서비스중인 게임 DB 설계 (쿠키런 편)서비스중인 게임 DB 설계 (쿠키런 편)
서비스중인 게임 DB 설계 (쿠키런 편)
 
실시간 게임 서버 최적화 전략
실시간 게임 서버 최적화 전략실시간 게임 서버 최적화 전략
실시간 게임 서버 최적화 전략
 
[KGC 2012] Online Game Server Architecture Case Study Performance and Security
[KGC 2012] Online Game Server Architecture Case Study Performance and Security[KGC 2012] Online Game Server Architecture Case Study Performance and Security
[KGC 2012] Online Game Server Architecture Case Study Performance and Security
 
NDC12_Lockless게임서버설계와구현
NDC12_Lockless게임서버설계와구현NDC12_Lockless게임서버설계와구현
NDC12_Lockless게임서버설계와구현
 
05_Reliable UDP 구현
05_Reliable UDP 구현05_Reliable UDP 구현
05_Reliable UDP 구현
 
[야생의 땅: 듀랑고] 서버 아키텍처 Vol. 2 (자막)
[야생의 땅: 듀랑고] 서버 아키텍처 Vol. 2 (자막)[야생의 땅: 듀랑고] 서버 아키텍처 Vol. 2 (자막)
[야생의 땅: 듀랑고] 서버 아키텍처 Vol. 2 (자막)
 
Multiplayer Game Sync Techniques through CAP theorem
Multiplayer Game Sync Techniques through CAP theoremMultiplayer Game Sync Techniques through CAP theorem
Multiplayer Game Sync Techniques through CAP theorem
 
스마트폰 온라인 게임에서 고려해야 할 것들
스마트폰 온라인 게임에서 고려해야 할 것들스마트폰 온라인 게임에서 고려해야 할 것들
스마트폰 온라인 게임에서 고려해야 할 것들
 
iFunEngine: 30분 만에 게임 서버 만들기
iFunEngine: 30분 만에 게임 서버 만들기iFunEngine: 30분 만에 게임 서버 만들기
iFunEngine: 30분 만에 게임 서버 만들기
 
홍성우, 게임 서버의 목차 - 시작부터 출시까지, NDC2019
홍성우, 게임 서버의 목차 - 시작부터 출시까지, NDC2019홍성우, 게임 서버의 목차 - 시작부터 출시까지, NDC2019
홍성우, 게임 서버의 목차 - 시작부터 출시까지, NDC2019
 
게임회사 실무용어 완전정복! 쿡앱스 용어정리집
게임회사 실무용어 완전정복! 쿡앱스 용어정리집 게임회사 실무용어 완전정복! 쿡앱스 용어정리집
게임회사 실무용어 완전정복! 쿡앱스 용어정리집
 
[IGC 2017] 펄어비스 민경인 - Mmorpg를 위한 voxel 기반 네비게이션 라이브러리 개발기
[IGC 2017] 펄어비스 민경인 - Mmorpg를 위한 voxel 기반 네비게이션 라이브러리 개발기[IGC 2017] 펄어비스 민경인 - Mmorpg를 위한 voxel 기반 네비게이션 라이브러리 개발기
[IGC 2017] 펄어비스 민경인 - Mmorpg를 위한 voxel 기반 네비게이션 라이브러리 개발기
 
임태현, MMO 서버 개발 포스트 모템, NDC2012
임태현, MMO 서버 개발 포스트 모템, NDC2012임태현, MMO 서버 개발 포스트 모템, NDC2012
임태현, MMO 서버 개발 포스트 모템, NDC2012
 
Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)
 
임태현, 게임 서버 디자인 가이드, NDC2013
임태현, 게임 서버 디자인 가이드, NDC2013임태현, 게임 서버 디자인 가이드, NDC2013
임태현, 게임 서버 디자인 가이드, NDC2013
 
Next-generation MMORPG service architecture
Next-generation MMORPG service architectureNext-generation MMORPG service architecture
Next-generation MMORPG service architecture
 
NoSQL 위에서 MMORPG 개발하기
NoSQL 위에서 MMORPG 개발하기NoSQL 위에서 MMORPG 개발하기
NoSQL 위에서 MMORPG 개발하기
 
혼자서 만드는 MMO게임 서버
혼자서 만드는 MMO게임 서버혼자서 만드는 MMO게임 서버
혼자서 만드는 MMO게임 서버
 
Unity Internals: Memory and Performance
Unity Internals: Memory and PerformanceUnity Internals: Memory and Performance
Unity Internals: Memory and Performance
 

Similar to Deterministic Simulation - What modern online games can learn from the Game Boy (talk @ GDCE 2016, Cologne)

A Decompiler for Blackhain-Based Smart Contracts Bytecode
A Decompiler for Blackhain-Based Smart Contracts BytecodeA Decompiler for Blackhain-Based Smart Contracts Bytecode
A Decompiler for Blackhain-Based Smart Contracts BytecodeShakacon
 
[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory Analysis[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory AnalysisMoabi.com
 
Monogame Introduction (ENG)
Monogame Introduction (ENG)Monogame Introduction (ENG)
Monogame Introduction (ENG)Aloïs Deniel
 
Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)
Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)
Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)Johan Andersson
 
A Development of Log-based Game AI using Deep Learning
A Development of Log-based Game AI using Deep LearningA Development of Log-based Game AI using Deep Learning
A Development of Log-based Game AI using Deep LearningSuntae Kim
 
Mastering Multiplayer Stage3d and AIR game development for mobile devices
Mastering Multiplayer Stage3d and AIR game development for mobile devicesMastering Multiplayer Stage3d and AIR game development for mobile devices
Mastering Multiplayer Stage3d and AIR game development for mobile devicesJean-Philippe Doiron
 
Dynamic Wounds on Animated Characters in UE4
Dynamic Wounds on Animated Characters in UE4Dynamic Wounds on Animated Characters in UE4
Dynamic Wounds on Animated Characters in UE4Michał Kłoś
 
Gdc gameplay replication in acu with videos
Gdc   gameplay replication in acu with videosGdc   gameplay replication in acu with videos
Gdc gameplay replication in acu with videosCharles Lefebvre
 
[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory Analysis[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory AnalysisMoabi.com
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory AnalysisMoabi.com
 
[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit Automation[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit AutomationMoabi.com
 
Enterprise Tic-Tac-Toe
Enterprise Tic-Tac-ToeEnterprise Tic-Tac-Toe
Enterprise Tic-Tac-ToeScott Wlaschin
 
Game development with Cocos2d-x Engine
Game development with Cocos2d-x EngineGame development with Cocos2d-x Engine
Game development with Cocos2d-x EngineDuy Tan Geek
 
PVS-Studio and 3DO Emulators
PVS-Studio and 3DO EmulatorsPVS-Studio and 3DO Emulators
PVS-Studio and 3DO EmulatorsAndrey Karpov
 
4Developers 2015: Gamedev-grade debugging - Leszek Godlewski
4Developers 2015: Gamedev-grade debugging - Leszek Godlewski4Developers 2015: Gamedev-grade debugging - Leszek Godlewski
4Developers 2015: Gamedev-grade debugging - Leszek GodlewskiPROIDEA
 
FGS 2011: Making A Game With Molehill: Zombie Tycoon
FGS 2011: Making A Game With Molehill: Zombie TycoonFGS 2011: Making A Game With Molehill: Zombie Tycoon
FGS 2011: Making A Game With Molehill: Zombie Tycoonmochimedia
 
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attac
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attacDefcon 22-paul-mcmillan-attacking-the-iot-using-timing-attac
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attacPriyanka Aash
 
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)Nate Lawson
 

Similar to Deterministic Simulation - What modern online games can learn from the Game Boy (talk @ GDCE 2016, Cologne) (20)

A Decompiler for Blackhain-Based Smart Contracts Bytecode
A Decompiler for Blackhain-Based Smart Contracts BytecodeA Decompiler for Blackhain-Based Smart Contracts Bytecode
A Decompiler for Blackhain-Based Smart Contracts Bytecode
 
Gamedev-grade debugging
Gamedev-grade debuggingGamedev-grade debugging
Gamedev-grade debugging
 
[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory Analysis[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory Analysis
 
Monogame Introduction (ENG)
Monogame Introduction (ENG)Monogame Introduction (ENG)
Monogame Introduction (ENG)
 
Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)
Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)
Parallel Graphics in Frostbite - Current & Future (Siggraph 2009)
 
A Development of Log-based Game AI using Deep Learning
A Development of Log-based Game AI using Deep LearningA Development of Log-based Game AI using Deep Learning
A Development of Log-based Game AI using Deep Learning
 
Mastering Multiplayer Stage3d and AIR game development for mobile devices
Mastering Multiplayer Stage3d and AIR game development for mobile devicesMastering Multiplayer Stage3d and AIR game development for mobile devices
Mastering Multiplayer Stage3d and AIR game development for mobile devices
 
Dynamic Wounds on Animated Characters in UE4
Dynamic Wounds on Animated Characters in UE4Dynamic Wounds on Animated Characters in UE4
Dynamic Wounds on Animated Characters in UE4
 
Tactical Assassins
Tactical AssassinsTactical Assassins
Tactical Assassins
 
Gdc gameplay replication in acu with videos
Gdc   gameplay replication in acu with videosGdc   gameplay replication in acu with videos
Gdc gameplay replication in acu with videos
 
[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory Analysis[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory Analysis
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis
 
[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit Automation[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit Automation
 
Enterprise Tic-Tac-Toe
Enterprise Tic-Tac-ToeEnterprise Tic-Tac-Toe
Enterprise Tic-Tac-Toe
 
Game development with Cocos2d-x Engine
Game development with Cocos2d-x EngineGame development with Cocos2d-x Engine
Game development with Cocos2d-x Engine
 
PVS-Studio and 3DO Emulators
PVS-Studio and 3DO EmulatorsPVS-Studio and 3DO Emulators
PVS-Studio and 3DO Emulators
 
4Developers 2015: Gamedev-grade debugging - Leszek Godlewski
4Developers 2015: Gamedev-grade debugging - Leszek Godlewski4Developers 2015: Gamedev-grade debugging - Leszek Godlewski
4Developers 2015: Gamedev-grade debugging - Leszek Godlewski
 
FGS 2011: Making A Game With Molehill: Zombie Tycoon
FGS 2011: Making A Game With Molehill: Zombie TycoonFGS 2011: Making A Game With Molehill: Zombie Tycoon
FGS 2011: Making A Game With Molehill: Zombie Tycoon
 
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attac
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attacDefcon 22-paul-mcmillan-attacking-the-iot-using-timing-attac
Defcon 22-paul-mcmillan-attacking-the-iot-using-timing-attac
 
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)
 

Recently uploaded

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 

Recently uploaded (20)

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 

Deterministic Simulation - What modern online games can learn from the Game Boy (talk @ GDCE 2016, Cologne)

  • 1. Deterministic Simulation What modern online games can learn from the Game Boy David Salz CTO, Sandbox Interactive
  • 2. Who am I?  CTO, Co-Founder of Sandbox Interactive  15 years in the industry  Albion Online:  Sandbox MMORPG  Cross-Platform (Windows/OSX/Linux/Android/iOS)  Player-Driven Economy (everything is player-crafted)  Strong focus on PvP + Guilds  Currently in Beta w/ 120.000+ „founding“ players  Using Unity Engine
  • 3.
  • 4. Agenda  Deterministic Simulation – A short reminder  How RTS-style games use it  How MMO-style games can still use it!  The pitfalls: How to do it and what to avoid  A few tricks with deterministic randomness  A few examples from Albion Online
  • 5. Gameboy Multiplayer  Link cable had very limited throughput  … as in: a few bytes per frame and player  Syncing complex game state is impossible  Instead: used like a controller cable! Deterministic simulation on all devices  Frame updates are synced (effectively „lock-stepping“)  Still used on DSi and 3DS
  • 6. Deterministic Simulation?  This should be an old hat, but…  Deterministic: same input  same output  Input[i] × State[i-1] = State[i]  where i is the simulation step number  Given State[0] and same sequence of inputs Input[1..n]  … all clients will produce same Sequence State[1..n] S[0] S[1] S[2] S[3] I[1] I[2] I[3]
  • 7. Deterministic Simulation!  This is cool because:  Only need to send State[0] and Inputs through network!  Only Inputs if State[0] is known  Can save replays by saving only Inputs!  You can debug replays of bugs!  Difficulties:  one mistake and the clients „desync“  must be independent of frame/thread timings  requires lock-stepping for online games  Late join requires you to send State[n]
  • 8.  Dead Reckoning:  Extrapolate future state of an object based on a known state and current behavior  Example: movement of a mob TimeStamp: T510 Positon: 210, 425 MoveTarget: 190, 415 MoveSpeed: 2/s AttackTarget: MadDave Predicted current position Known, past position Deterministic Simulation vs. Dead Reckoning
  • 9. Deterministic Simulation vs. Dead Reckoning  But: this is only a prediction! May be incorrect and client may act on incorrect info!  May have to correct state given new information! T2: 504 Timestamp T0 Health = 500, +2/s T3: 506 T4: 508 T5: 510 Timestamp T4 Health = 400, +10/s T6: 420 Wrong! Wrong! Network Delay: 2
  • 10. Lock-stepping (1)  This is how RTS games do it  Basically everything from Age of Empires to Starcraft2  Collect input from all players, send it to all players  Simulation step i can only happen when input from all players for step i has arrived (stepping is „synced“ or „locked“  Collect input a little earlier to account for ping  Allows high unit count with super-small bandwidth!
  • 11. Lock-stepping (2) Simulate S[1] Collect I[3] Simulate S[2] Collect I[4] Simulate S[3] Collect I[5] Client 1 Client 2Server (may run on a Client) Collect I[3] from all Send I[3] to all Collect I[4] from all Send I[4]to all Simulate S[1] Collect I[3] Simulate S[2] Collect I[4] Simulate S[3] Collect I[5]
  • 12. Lock-stepping (3)  Problems:  Slowest player’s ping will be felt by all players  Worst case: „waiting for player“  Input delay is noticeable  Usually covered by animation, audio prompt etc.  Difficult to handle drop-out / late join   only suitable for very limited number of players!
  • 13. Actor-based determinism (1)  Lock-stepping is not suitable for MMOs!  Cannot wait for players (worst ping = everyone's ping!)  Single player cannot „see“ full game state (just too big)  Everyone does a „late Join“  BUT: can still use deterministic simulation for a single actor  … as long as behavior depends only on actor itself  example: roaming behavior of a mob (later)  Can mix with dead reckoning  Also great for visual stuff w/o gameplay influence
  • 14. Actor-based determinism (2) Farm Animal - roaming around - just eye candy! MOBs - gameplay relevant - attackable - can attack - roaming around
  • 15. Pitfalls & Common Mistakes  Uninitialized variables, dangling pointers etc.  add an unwanted random element to the simulation  Undefined behavior of C++ or library functions  Random number generators behave differently across library versions! (Roll your own!)  Use fixed simulation timing!  simulation MUST NOT depend on frame timing  but rendering, animation MUST…  Need a clean separation of simulation and presentation
  • 17. The trouble with float (1)  IEEE standard: only +, –, *, /, sqrt guaranteed to give same results everywhere  not: sin, cos, tan etc. (different on different CPU types)  CPU can store numbers in float or double format  how intermediate results are stored is often unspecified (depends on compiler)  x86: per-thread settings for precision, exceptions, rounding, denormal support  … check the manual of your target CPUs…  different feature sets (SIMD sets like MMX, SSE etc.)
  • 18. The trouble with float (2)  You can make floats work if…  … you stick to +, –, *, /, sqrt (write the rest yourself)  … you can configure compiler behavior (intermediate precision, instruction set used)  … you can control CPU behavior (precision, rounding etc.)  Best: one target CPU type, same binary for all clients  You are in trouble if…  … you need to support a JIT environment  … you need to target different CPUs  … you need to use different compilers
  • 19. Fixed Point numbers (1)  Idea: create fractional number type based on integers  … and use only this in (deterministic) simulation  again: clean separation of gameplay / rendering is important  e.g. 110.010 = 1*22 + 1*21 + 0*20 + 0*2-1 + 1*2-2 +0*2-3 = 1*4 + 1*2 + 0*1 + 0*0,5 + 1*0,25 + 0*0,125 = 6,25
  • 20.
  • 21. Deterministic Randomness  Random number generators are deterministic  Provided same initial seed, will produce same random sequence  Many copy-paste-ready implementations exist  E.g. Mersenne Twister, WELL, XORshift  (Wikipedia has a list!)  Watch out for:  period length  memory footprint  speed  warmup period  But can we „seek“ inside the random sequence?
  • 22. Cryptographic Hashes  Cryptographic Hash functions can be used as random number sources!  Hash Function: converts data into unique integer  i.e. byte[]  int  … seeks to avoid „collisions“ (i.e. different data should produce hash; meaning equal distribution of hashes)  Cryptographic hash function: not easily reversible  i.e. output must appear random!
  • 23. Seekable random sequences  Cryptographic Hashes can be used to build seekable random number generators!  because Hash(i) is random, even if i = {0,1,2,3,4,5… n}  Note: you can do this with timestamps, coordinates, … anything really!
  • 24. Seekable random sequences for(int i=0; i<1000; i+=2) { DrawPoint(Hash(i) % 300, Hash(i+1) % 300) } Adler32 MD5
  • 25. Example: Mob Roaming Behavior  given:  Mob „Home“ position  Roaming Radius  repeat:  pick random point inside roaming circle  walk to random point (stop if path is blocked)  wait for random time (between a given min and max)
  • 26. StartNextCycle(startTimeStamp, startPosition) { init RNG with startTimeStamp pick „random“ moveTarget point if(there is a collision on the way there)… … the collision point is the moveTarget calculate the walkTime to moveTarget pick a random waitTime endTimeStamp = startTimeStamp + walkTime + waitTime } Render(nowTimeStamp) { while(nowTimeStamp > endTimeStamp) StartNextCycle(endTimeStamp, moveTarget) if(nowTimeStamp < startTimeStamp + walkTime) position = LERP(startPosition, moveTarget) else position = moveTarget }
  • 28. Takeaway  Deterministic Simulation can greatly reduce network traffic in online/multiplayer games  RTS-style games use fully deterministic gameplay with lock-stepping  MMO-style games can still use actor-based deterministic simulation  May have to use fixed point instead of float  Hash functions are great for „randomness“ (including seekable random sequences!)
  • 29. References  1500 Archers on a 28.8  http://www.gamasutra.com/view/feature/131503/1500_archers_on_a_288_network_.php  Floating-Point Determinism  https://randomascii.wordpress.com/2013/07/16/floating-point-determinism/  List of random number generators  https://en.wikipedia.org/wiki/List_of_random_number_generators
  • 30. Thank you! Questions / Comments? david@sandbox-interactive.com We are hiring! https://albiononline.com/en/jobs