ゲーム用のAIボットを開始したばかり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
私はJavaScript(より具体的にはNode.js)で作業していますが、上記の理由により、bashシェルの子プロセスを生成して開始するように指示していても、プログラムから再生できません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);
プログラムの出力は次のとおりです。
stdout: You must play from a terminal.
child process exited with code 1
この問題を解決するために、どのNode.js / JavaScript(および可能であれば他の言語やフレームワークではない)の黒魔術を使用できますか?