Running multiplayer codecombat arena locally

Hi there,

I’m trying the Greed challenge and already have a lot of fun with it.
I would like to test many variations of some algorithms, and for this having a local arena on my computer would be very useful. I found some documentation for setting up a development environment but I have a few questions:

  • can the arena be simulated without a browser? I guess there should be somewhere a server side simulation engine and not only a browser-based simulation process.
  • what are the minimal components I need to install ?

Thanks,

The arena is usually simulated on people’s browsers–we primarily crowdsource the simulations to properly scale simulation supply with demand. We do have a server-side simulator, but it’s sometimes buggy. You can try it, though. We’ll be working the bugs out of it next week. I am not sure why you’d need to use the headless simulator, though.

You should be able to follow the dev setup instructions (including restoring the database), create some accounts and submit their solutions to the leaderboards locally, and then run the simulator (from the ladder page’s Simulate tab) on your local instance.

Thanks for your answer, I will look for this headless simulator.

There are many reasons to use a command line tool, for example:

  • To automate tests for new code, with different random seeds,
  • To automatically test the effect of parameters, with meaningful statistical measurements,
  • I’m more a command line guy and for me automating things in the browser feels awkward.
1 Like

You can find it here. Usage:

coffee headless_client.coffee

You’ll need to create a login.coffee file next to it with this format:

module.exports = username: 'your_local_dev_user_email@gmail', password: 'your_local_dev_user_password'

If you want to use it to simulate one game against another, then you pass both of the session IDs as command-line arguments.

1 Like

Thank you for the link. It works without options but I can’t use it to simulate a game between two given oppents (see traceback below).

Cheers,

$ ./node_modules/coffee-script/bin/coffee headless_client.coffee one-game 537c0f3f0ff88b2c06287c2b 537be145a3b60b390500dcc3
Simulating 537c0f3f0ff88b2c06287c2b vs 537be145a3b60b390500dcc3
Error: ENOENT, no such file or directory '/home/adrien/codecombat_install/coco/node_modules/aether/node_modules/iota-compiler/one-game'
  at Object.fs.openSync (fs.js:427:18)
  at Object.fs.readFileSync (fs.js:284:15)
  at Object.<anonymous> (/home/adrien/codecombat_install/coco/node_modules/aether/node_modules/iota-compiler/iota.js:26:16)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (/home/adrien/codecombat_install/coco/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at Function.Module._load (module.js:312:12)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at Object.<anonymous> (/home/adrien/codecombat_install/coco/node_modules/aether/lib/languages/io.js:8:10)
  at Object.<anonymous> (/home/adrien/codecombat_install/coco/node_modules/aether/lib/languages/io.js:89:4)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (/home/adrien/codecombat_install/coco/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at Function.Module._load (module.js:312:12)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at Object.<anonymous> (/home/adrien/codecombat_install/coco/node_modules/aether/lib/languages/languages.js:8:9)
  at Object.<anonymous> (/home/adrien/codecombat_install/coco/node_modules/aether/lib/languages/languages.js:11:4)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (/home/adrien/codecombat_install/coco/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at Function.Module._load (module.js:312:12)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at Object.<anonymous> (/home/adrien/codecombat_install/coco/node_modules/aether/lib/aether.js:33:15)
  at Object.<anonymous> (/home/adrien/codecombat_install/coco/node_modules/aether/lib/aether.js:527:4)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (/home/adrien/codecombat_install/coco/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at Function.Module._load (module.js:312:12)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at Object.<anonymous> (/home/adrien/codecombat_install/coco/headless_client/worker_world.coffee:7:26)
  at Object.<anonymous> (/home/adrien/codecombat_install/coco/headless_client/worker_world.coffee:5:1)
  at Module._compile (module.js:456:26)
  at Object.loadFile (/home/adrien/codecombat_install/coco/node_modules/coffee-script/lib/coffee-script/register.js:16:19)
  at Module.load (/home/adrien/codecombat_install/coco/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at Function.Module._load (module.js:312:12)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at Object.<anonymous> (/home/adrien/codecombat_install/coco/headless_client.coffee:14:15)
  at Object.<anonymous> (/home/adrien/codecombat_install/coco/headless_client.coffee:1:1)
  at Module._compile (module.js:456:26)

@schmatz Have you seen this while working on the headless simulator recently?

Haven’t seen this recently, but I will check it out.

Updating to the newest Aether allowed me to replicate this bug. Will debug.

iota.js is interfering when you run Aether from node.

As a workaround, go into node_modules/aether/node_modules/iota-compiler/iota.js and edit the conditional that’s like if (filename) to something like if (false) and things will work. I also am pushing a few changes to do with user code errors and correctness today.

@nick What’s the status of the headless simulator at this point? Did you end up working on getting the bugs out of it as you planned?

I’m also interested in simulating games locally and it seems like the obvious option.

1 Like

@lawrencejohnston We got it working and used it for Greed tournament verification, so you should be able to just use it now.

When I try to run the headless simulator using this command:

./node_modules/coffee-script/bin/coffee headless_client.coffee

I get this error:

Error: Cannot find module 'jason'
  at Function.Module._resolveFilename (module.js:338:15)
  at Function.Module._load (module.js:280:25)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at Object.<anonymous> (/home/manu/Desktop/CodeCombat/coco/headless_client/worker_world.coffee:5:9)
  at Object.<anonymous> (/home/manu/Desktop/CodeCombat/coco/headless_client/worker_world.coffee:5:1)
  at Module._compile (module.js:456:26)
  at Object.loadFile (/home/manu/Desktop/CodeCombat/coco/node_modules/coffee-script/lib/coffee-script/register.js:16:19)
  at Module.load (/home/manu/Desktop/CodeCombat/coco/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
  at Function.Module._load (module.js:312:12)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at Object.<anonymous> (/home/manu/Desktop/CodeCombat/coco/headless_client.coffee:14:15)
  at Object.<anonymous> (/home/manu/Desktop/CodeCombat/coco/headless_client.coffee:1:1)
  at Module._compile (module.js:456:26)

I suppose It doens’t know where to find the libraries.
How would I go about fixing this?

Have you done these steps from within the CodeCombat directory?

npm install
bower install
bin/coco-brunch
Philipp@PHILIPP-PC /d/Projekte/CodeCombat/GitCode/codecombat (master)
$ npm install
npm WARN package.json karma-firefox-launcher@0.1.4 No README data
npm WARN package.json karma-phantomjs-launcher@0.1.4 No README data
npm WARN package.json passport-local@0.1.6 No README data
npm WARN package.json karma-chrome-launcher@0.1.7 No README data

Philipp@PHILIPP-PC /d/Projekte/CodeCombat/GitCode/codecombat (master)
$ bower install

Philipp@PHILIPP-PC /d/Projekte/CodeCombat/GitCode/codecombat (master)
$ coffee headless_client.coffee
Error: ENOENT, no such file or directory 'd:\Projekte\CodeCombat\GitCode\codecombat\public\javascripts\lodash.js'
  at Object.fs.openSync (fs.js:438:18)
  at Object.fs.readFileSync (fs.js:289:15)
  at Object.<anonymous> (d:\Projekte\CodeCombat\GitCode\codecombat\headless_client\worker_world.coffee:193:28)
  at Object.<anonymous> (d:\Projekte\CodeCombat\GitCode\codecombat\headless_client\worker_world.coffee:5:1)
  at Module._compile (module.js:456:26)
  at Object.loadFile (c:\Users\Philipp\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\register.js:16:19)
  at Module.load (c:\Users\Philipp\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\register.js:45:36)
  at Function.Module._load (module.js:312:12)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at Object.<anonymous> (d:\Projekte\CodeCombat\GitCode\codecombat\headless_client.coffee:14:15)
  at Object.<anonymous> (d:\Projekte\CodeCombat\GitCode\codecombat\headless_client.coffee:1:1)
  at Module._compile (module.js:456:26)


Philipp@PHILIPP-PC /d/Projekte/CodeCombat/GitCode/codecombat (master)
$

@J_F_B_M hey over here

Sry. I forgot “brunch w” run.

Is it working now that you did the brunch step?