我正试图根据博弈论建立一个行动矩阵.所以,如果两个人相遇,他们要么共同分享,要么一起偷,要么一起偷,等等.
我的概述如下(不是整个矩阵,只是让你有个 idea ):
if first_agent.type == "AlwaysShare" and second_agent.type == "AlwaysShare":
pass
elif first_agent.type == "AlwaysSteal" and second_agent.type == "AlwaysShare":
pass
elif first_agent.type == "AlwaysShare" and second_agent.type == "AlwaysSteal":
pass
显然,这是非常低效的,而且容易出错.如何对此进行优化,以便有效管理矩阵的交互?