一句话:在 Haskell 纯度和静态指针支持下,锁步模拟变得极易实现,并可在 CodeWorld 中无纪律要求地提供一致性。
本文关注多人联网游戏中的锁步模拟:各客户端广播输入并独立计算状态,但保证所有客户端状态一致通常极为困难,需要游戏程序员高度自律。作者提出,在函数式编程中,尤其借助 Haskell 的纯度和静态指针,该难题几乎变得微不足道。为验证这一论点,他们在教育编程环境 CodeWorld 中实现了在恶劣条件下的锁步模拟,使其支持交互式多用户联网游戏。尽管提供非常抽象的高层接口,且不要求程序员额外自律,系统仍能提供带客户端预测的一致锁步模拟。
Implementing multi-player networked games by broadcasting the player’s input and letting each client calculate the game state -- a scheme known as *lock-step simulation* – is an established technique. However, ensuring that every client in this scheme obtains a consistent state is infamously hard and in general requires great discipline from the game programmer. The thesis of this pearl is that in the realm of functional programming – in particular with Haskell's purity and static pointers – this hard problem becomes almost trivially easy. We support this thesis by implementing lock-step simulation under very adverse conditions. We extended the educational programming environment CodeWorld, which is used to teach math and programming to middle school students, with the ability to create and run interactive, networked multi-user games. Despite providing a very abstract and high-level interface, and without requiring any discipline from the programmer, we can provide consistent lock-step simulation with client prediction.
DOI 原文 · arXiv · PDF(开放获取) · DBLP
@article{BreitnerS17,
title = {Lock-step simulation is child's play (experience report)},
author = {Joachim Breitner and Chris Smith},
journal = {Proceedings of the ACM on Programming Languages},
volume = {1},
number = {ICFP},
year = {2017},
doi = {10.1145/3110247}
}