Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to connect to nethack from Node.js?
    text
    copied!<p>I'm just starting an AI bot for the game <code>nethack</code>, and I can't bypass the 'human-check' that's in source. The section of code I'm talking about is <code>nethack/sys/unix/unixunix.c</code>:</p> <pre><code>#ifdef TTY_GRAPHICS /* idea from rpick%ucqais@uccba.uc.edu * prevent automated rerolling of characters * test input (fd0) so that tee'ing output to get a screen dump still * works * also incidentally prevents development of any hack-o-matic programs */ /* added check for window-system type -dlc */ if (!strcmp(windowprocs.name, "tty")) if (!isatty(0)) error("You must play from a terminal."); #endif </code></pre> <p>I'm working in JavaScript, (more specifically Node.js), and due to the above, it won't let me play from the program, even though I'm spawning a bash shell child process and telling it to start <code>nethack</code>. I need to figure out a way to bypass the above without recompiling the source.</p> <p>The current code I'm using is:</p> <pre><code>"use strict"; var env = { TERM: 'tty' }; for (var k in process.env) { env[k] = process.env[k]; } var terminal = require('child_process').spawn('bash', [], { env: env, }); terminal.stdout.on('data', function (data) { console.log('stdout: ' + data); }); terminal.on('exit', function (code) { console.log('child process exited with code ' + code); }); setTimeout(function() { terminal.stdin.write('nethack'); terminal.stdin.end(); }, 1000); </code></pre> <p>The output of the program is:</p> <pre><code>stdout: You must play from a terminal. child process exited with code 1 </code></pre> <p>What Node.js/JavaScript (and not any other language or framework, if possible) black magic could I use to solve this problem?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload