Let's Talk About Lambda Functions!
Duncan Booth
duncan at NOSPAMrcp.co.uk
Thu Aug 22 06:16:33 EDT 2002
hwlgw at hotmail.com (Will Stuyvesant) wrote in
news:cb035744.0208220055.3a09c133 at posting.google.com:
> Duncan Booth <duncan at NOSPAMrcp.co.uk> wrote:
>> hwlgw at hotmail.com (Will Stuyvesant) wrote:
>> > Hmm, a nethack bot written in Python could be fun. Need to capture
>> > nethack's character based output somehow.
>> >
>> Anyway, extracting the output from Nethack at a suitably high level
>> isn't a hard task. It is pretty well structured in that area.
>
> How would you set out to do that?
> Something like redirecting the nethack output, um,
> os.system('nethack > outtputfile')
> and reading the outputfile?
What I meant was that you recompile Nethack supplying your own
implementations of the screen driving functions. These functions are quite
a high level: win_askname (asks the player for their name), win_putstr
(outputs a string to a specified window), win_start_menu, win_add_menu,
win_end_menu, win_select_menu (do menu stuff), win_yn_function (asks a
question expecting yes, no, quit etc. as answers).
The interface functions also include event notifications such as
win_update_inventory (called whenever your inventory changes).
Reimplement these functions to links through to your bot and you will get
more information than most ports generally put on the screen.
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list