@farama/ale-wasm
v0.12.0
Published
Arcade Learning Environment (ALE) compiled to WebAssembly for browser-based Atari 2600 emulation and reinforcement learning
Maintainers
Readme
@farama/ale-wasm
Arcade Learning Environment compiled to WebAssembly for browser-based Atari 2600 emulation.
Installation
npm install @farama/ale-wasmUsage
import createALEModule from '@farama/ale-wasm';
const ALE = await createALEModule();
const ale = new ALE.ALEInterface();
// Load ROM from URL
await ale.loadROMFromURL('https://example.com/breakout.bin');
// Or from file input
const fileInput = document.querySelector('input[type="file"]');
await ale.loadROMFromFile(fileInput.files[0]);
// Play
ale.resetGame();
while (!ale.gameOver()) {
const actions = ale.getMinimalActionSet();
const action = actions[Math.floor(Math.random() * actions.length)];
const reward = ale.act(action);
}API
ale.loadROM(path)- Load ROM from virtual filesystemale.loadROMFromURL(url)- Load ROM from URLale.loadROMFromFile(file)- Load ROM from File objectale.act(action)- Take action, returns rewardale.resetGame()- Reset gameale.gameOver()- Check if game is overale.getScreenRGB()- Get screen as RGB arrayale.getMinimalActionSet()- Get valid actions
Documentation
https://github.com/Farama-Foundation/Arcade-Learning-Environment
