geek-ai / MAgent

A Platform for Many-Agent Reinforcement Learning
MIT License
1.68k stars 332 forks source link

兄弟-1索引下标是怎么通过测试的 #90

Open weyenrooney opened 2 years ago

weyenrooney commented 2 years ago

gridworld.py 420行 _LIB.env_get_info(self.game, -1, b"global_minimap", buf.ctypes.data_as(ctypes.POINTER(ctypes.c_float)))

c++ 712行

void GridWorld::get_info(GroupHandle group, const char name, void void_buffer) { // for more information from the engine, add items here

std::vector<Agent*> &agents = groups[group].get_agents();
Kipsora commented 2 years ago

It appears to be a bug. Could you open a PR to fix it? I guess it is because the group agents are not useful for getting global_minimap anyway that this bug could never cause fatal exceptions on some machines.

weyenrooney commented 2 years ago

search text in gridworld.py with "_LIB.env_get_info(self.game, -1",it appears 5 times I fix it in c++ as follow void GridWorld::get_info(GroupHandle group, const char name, void void_buffer) { // for more information from the engine, add items here if (group<0 || group>=groups.size()) { //LOG(FATAL) << "index group out of range " << name; //return; group = 0; }

I build a windows version and debug it

merrymercy commented 2 years ago

@Kipsora is correct. The variable std::vector<Agent*> &agents is never used in this case, so it does not trigger any invalid memory access.