mlii / mfrl

Mean Field Multi-Agent Reinforcement Learning
MIT License
369 stars 101 forks source link

how to show battle #20

Open Ruobird opened 4 years ago

Ruobird commented 4 years ago

I want to take a look at the battle screens I trained. What should I do? I found the index.html page file. How should I use this? Looking forward to your answer

Swell61 commented 3 years ago

I've had a look at this today as I had the same question.

From my experimentation, you can either compile the render backend in examples/battle_model/src/render/backend (I had to use clang++ as g++ wouldn't compile the jsoncpp library), or use the binary render in examples/battle_model/build/render/.

The web page will then connect to the server. You supply it with the config and map files. The config file is in the render directory. If you feed one of the video_x files as a map, it seems to work, I get an animation of blue and red boxes, similar to that of the demo.

I'm not sure what static.map is for. When it is provided as the map file, it outputs an error invalid tag of walls. Comparing it to the video_x files (after running battle.py with the --render arg), it's missing a W at the start of the file. If I add the W, it starts to load but the backend produces a segmentation fault.

ElizabethDuo commented 3 years ago

I've had a look at this today as I had the same question.

From my experimentation, you can either compile the render backend in examples/battle_model/src/render/backend (I had to use clang++ as g++ wouldn't compile the jsoncpp library), or use the binary render in examples/battle_model/build/render/.

The web page will then connect to the server. You supply it with the config and map files. The config file is in the render directory. If you feed one of the video_x files as a map, it seems to work, I get an animation of blue and red boxes, similar to that of the demo.

I'm not sure what static.map is for. When it is provided as the map file, it outputs an error invalid tag of walls. Comparing it to the video_x files (after running battle.py with the --render arg), it's missing a W at the start of the file. If I add the W, it starts to load but the backend produces a segmentation fault.

@Swell61 Hi Swell! Your answer helped a lot! I ran render under examples/battle_model/build/render/ and tried to serve cofig.json andvideo_x.txt as the map. config.json seemed to be fine, but it failed for magent::render::RenderException: "invalid handle of the map configuration file". Any idea to solve this? Hope to hear from you soon.

Swell61 commented 3 years ago

@Swell61 Hi Swell! Your answer helped a lot! I ran render under examples/battle_model/build/render/ and tried to serve cofig.json andvideo_x.txt as the map. config.json seemed to be fine, but it failed for magent::render::RenderException: "invalid handle of the map configuration file". Any idea to solve this? Hope to hear from you soon.

Hi, do you have the files in the same directory as render? I think I remember encountering an issue when attempting to feed it files that were in different directory to render and it wouldn't run.

I've just tried it again with config.json and video_15.txt in the same directory as render and index.html and it worked.

Let me know if this works or not.

ElizabethDuo commented 3 years ago

@Swell61 Hi Swell! Your answer helped a lot! I ran render under examples/battle_model/build/render/ and tried to serve cofig.json andvideo_x.txt as the map. config.json seemed to be fine, but it failed for magent::render::RenderException: "invalid handle of the map configuration file". Any idea to solve this? Hope to hear from you soon.

Hi, do you have the files in the same directory as render? I think I remember encountering an issue when attempting to feed it files that were in different directory to render and it wouldn't run.

I've just tried it again with config.json and video_15.txt in the same directory as render and index.html and it worked.

Let me know if this works or not.

Swell, thank you for the reply! I have solved this problem by just type in the name of cofig.json and video_x.txt. I was wrongly upload the whole file path before, then caused the error. And it was simply solved by input the name of files only. Thanks again for your help!