Designing an actor model game architecture with Pony
-
Upload
nick-pruehs -
Category
Technology
-
view
60 -
download
0
Transcript of Designing an actor model game architecture with Pony
![Page 1: Designing an actor model game architecture with Pony](https://reader031.fdocuments.us/reader031/viewer/2022030304/58786eb71a28ab497b8b591b/html5/thumbnails/1.jpg)
Designing an Actor Model Game Architecture with PonyNick Prühs
![Page 2: Designing an actor model game architecture with Pony](https://reader031.fdocuments.us/reader031/viewer/2022030304/58786eb71a28ab497b8b591b/html5/thumbnails/2.jpg)
![Page 3: Designing an actor model game architecture with Pony](https://reader031.fdocuments.us/reader031/viewer/2022030304/58786eb71a28ab497b8b591b/html5/thumbnails/3.jpg)
Pony
• object-oriented
• actor-model
• capabilities-secure
![Page 4: Designing an actor model game architecture with Pony](https://reader031.fdocuments.us/reader031/viewer/2022030304/58786eb71a28ab497b8b591b/html5/thumbnails/4.jpg)
Pony
• object-oriented
• actor-model
• capabilities-secure
![Page 5: Designing an actor model game architecture with Pony](https://reader031.fdocuments.us/reader031/viewer/2022030304/58786eb71a28ab497b8b591b/html5/thumbnails/5.jpg)
Hello world!
actor Mainnew create(env: Env) =>
env.out.print("Hello, world!")
![Page 6: Designing an actor model game architecture with Pony](https://reader031.fdocuments.us/reader031/viewer/2022030304/58786eb71a28ab497b8b591b/html5/thumbnails/6.jpg)
Actors in Pony
• Similar to classes
• Can have asynchronous functions called behaviours
• Bodies of behaviours will execute at some indeterminate time in the
future
• All behaviours always return the receiver
They can't return something they calculate (since they haven't
run yet)
Returning the receiver is a convenience to allow chaining calls
on the receiver
![Page 7: Designing an actor model game architecture with Pony](https://reader031.fdocuments.us/reader031/viewer/2022030304/58786eb71a28ab497b8b591b/html5/thumbnails/7.jpg)
Behaviours
actor Aardvark
let name: String
var _hunger_level: U64 = 0
new create(name': String) =>
name = name'
be eat(amount: U64) =>
_hunger_level = _hunger_level - amount.min(_hunger_level)
![Page 8: Designing an actor model game architecture with Pony](https://reader031.fdocuments.us/reader031/viewer/2022030304/58786eb71a28ab497b8b591b/html5/thumbnails/8.jpg)
“Here we have an Aardvark that can eat asynchronously.
Clever Aardvark.”
![Page 9: Designing an actor model game architecture with Pony](https://reader031.fdocuments.us/reader031/viewer/2022030304/58786eb71a28ab497b8b591b/html5/thumbnails/9.jpg)
Pony
• object-oriented
• actor-model
• capabilities-secure
![Page 10: Designing an actor model game architecture with Pony](https://reader031.fdocuments.us/reader031/viewer/2022030304/58786eb71a28ab497b8b591b/html5/thumbnails/10.jpg)
Reference Capabilities
Remember const in C++?
![Page 11: Designing an actor model game architecture with Pony](https://reader031.fdocuments.us/reader031/viewer/2022030304/58786eb71a28ab497b8b591b/html5/thumbnails/11.jpg)
Reference Capabilities
Remember const in C++?
Awesome, right?
![Page 12: Designing an actor model game architecture with Pony](https://reader031.fdocuments.us/reader031/viewer/2022030304/58786eb71a28ab497b8b591b/html5/thumbnails/12.jpg)
Reference Capabilities
• ref – mutable
• val - immutable
• iso - no one else can read or write
… plus three more.
![Page 13: Designing an actor model game architecture with Pony](https://reader031.fdocuments.us/reader031/viewer/2022030304/58786eb71a28ab497b8b591b/html5/thumbnails/13.jpg)
Reference Capabilities
actor FileStream is OutStream
let _file: File
new create(file: File iso) =>
_file = consume file
be write(data: ByteSeq) =>
_file.write(data)
![Page 14: Designing an actor model game architecture with Pony](https://reader031.fdocuments.us/reader031/viewer/2022030304/58786eb71a28ab497b8b591b/html5/thumbnails/14.jpg)
Pony
• type safe
• memory safe
• exception safe
• data-race free
• deadlock free
![Page 15: Designing an actor model game architecture with Pony](https://reader031.fdocuments.us/reader031/viewer/2022030304/58786eb71a28ab497b8b591b/html5/thumbnails/15.jpg)
PonyGame Architecture
![Page 16: Designing an actor model game architecture with Pony](https://reader031.fdocuments.us/reader031/viewer/2022030304/58786eb71a28ab497b8b591b/html5/thumbnails/16.jpg)
DEMO
![Page 17: Designing an actor model game architecture with Pony](https://reader031.fdocuments.us/reader031/viewer/2022030304/58786eb71a28ab497b8b591b/html5/thumbnails/17.jpg)
Code publicly available at
https://github.com/npruehs/pony-game
![Page 18: Designing an actor model game architecture with Pony](https://reader031.fdocuments.us/reader031/viewer/2022030304/58786eb71a28ab497b8b591b/html5/thumbnails/18.jpg)
References
• S. Clebsch, Pony: Co-Designing a Type System and a Runtime.Microsoft Research, Cambridge, 2016.
• S. T Allen, S. Clebsch, S. Blessing, A. McNeil et al., Pony Tutorial.http://tutorial.ponylang.org, 2016.
• S. Clebsch, S. Blessing, J. Franco, S. Drossopoulou, Ownership and Reference Counting based Garbage Collection in the Actor World.Causality Ltd. and Imperial College London, 2015.
• S. Clebsch, S. Drossopoulou, Fully Concurrent Garbage Collection of Actors on Many-Core Machines. OOPSLA 2013.
• S. Clebsch, S. Drossopoulou, S. Blessing, A. McNeil, Deny Capabilities for Safe, Fast Actors. Causality Ltd. and Imperial College London.