现在我们就要初始化世界(World)可以跑起我们的FSM了! if __name__ == "__main__": world = World() world.init() world.run()
用python解释器执行上面的代码,我们可以看到程序不停地输出Car的状态: ...... Car8453392 exit run state! Car8453392 enter stop state! Car8453392 in stop state! Stop!!! Car8453392 in stop state! Stop!!! Car8453392 exit stop state! Car8453392 enter run state! Car8453392 in run state! Goooooo!!! Car8453392 exit run state! Car8453392 enter stop state! Car8453392 in stop state! Stop!!! Car8453392 exit stop state! Car8453392 enter run state! Car8453392 in run state! Goooooo!!! Car8453392 in run state! Goooooo!!! Car8453392 exit run state! Car8453392 enter stop state! Car8453392 in stop state! Stop!!! Car8453392 in stop state! Stop!!! Car8453392 exit stop state! Car8453392 enter run state! Car8453392 in run state! Goooooo!!! ......