chr*_*ode 5 javascript artificial-intelligence tty nethack node.js
我刚刚为游戏启动了一个人工智能机器人nethack,我无法绕过源头的"人工检查".我正在谈论的代码部分是nethack/sys/unix/unixunix.c:
#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
Run Code Online (Sandbox Code Playgroud)
我正在使用JavaScript,(更具体地说是Node.js),由于上述原因,即使我正在生成一个bash shell子进程并告诉它启动,它也不会让我从程序中玩nethack.我需要想办法绕过上面的内容而不重新编译源代码.
我正在使用的当前代码是:
"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);
Run Code Online (Sandbox Code Playgroud)
该计划的输出是:
stdout: You must play from a terminal.
child process exited with code 1
Run Code Online (Sandbox Code Playgroud)
什么Node.js/JavaScript(而不是任何其他语言或框架,如果可能的话)黑魔法可以用来解决这个问题?
| 归档时间: |
|
| 查看次数: |
734 次 |
| 最近记录: |