<分区>
我使用此函数生成数字 0、1、2、3 的随机排列,这些排列由代理在 Tron 游戏的二维网格中转换为移动。
srand(time(nullptr));
vector<int> permutationMoves = { 0, 1, 2, 3 };
auto currentIndexCounter = permutationMoves.size();
for (auto iter = permutationMoves.rbegin(); iter != permutationMoves.rend();
iter++, --currentIndexCounter) {
int randomIndex = rand() % currentIndexCounter;
if (*iter != permutationMoves.at(randomIndex)) {
swap(permutationMoves.at(randomIndex), *iter);
}
}
但是,我有两个问题:
- 如果两个智能体连续移动,则由于随机数取决于时间,因此他们会移动相同的移动。
- 如果代理人在彼此之后玩多轮,则两个代理人的 Action 与前一局的 Action 相同。所以最终网格总是相同的,在大多数情况下,1 个智能体最终赢得 95%-100% 的游戏。
非常感谢所有帮助,谢谢!