Download environments/games/web/tools/gym_server.js from THUSI-Lab/GameDojo: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/datasets/THUSI-Lab/GameDojo/resolve/main/environments/games/web/tools/gym_server.js
- Command line
-
hf download hf://datasets/THUSI-Lab/GameDojo/environments/games/web/tools/gym_server.js
-
curl -L -o gym_server.js https://huggingface.co/datasets/THUSI-Lab/GameDojo/resolve/main/environments/games/web/tools/gym_server.js
1.03 kB
| // Node transport for the Python gymnasium binding: one env per process, one JSON command per stdin line, | |
| // one JSON reply per stdout line ({error} on failure). Symbolic only; pixels go through the browser transport. | |
| // usage: node tools/gym_server.js [game = hollowknight_remake] (a name under web/games/ or a path to a game folder) | |
| // One game per process (games share the BB global); prototype/bossbench/webenv.py starts one per game. | |
| var path = require('path'), fs = require('fs'); | |
| var arg = process.argv[2] || 'hollowknight_remake', dir = fs.existsSync(path.join(__dirname, '..', 'games', arg)) ? path.join(__dirname, '..', 'games', arg) : path.resolve(arg); | |
| var BB = require('../engine/load.js')(dir); | |
| require('../engine/bridge.js'); | |
| var rl = require('readline').createInterface({ input: process.stdin, terminal: false }); | |
| rl.on('line', function (line) { | |
| var res; | |
| try { res = BB.bridge(JSON.parse(line)); } catch (e) { res = { error: String(e && e.stack || e) }; } | |
| process.stdout.write(JSON.stringify(res) + '\n'); | |
| }); | |