LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-13-2012, 04:17 PM   #16
S. Chapelin
Member
 
Registered: Jan 2010
Location: Quebec
Posts: 144

Original Poster
Rep: Reputation: 6

First I just want to send nethack some commands and receive the output interactively, then I want to draw the results using pygame or preferably a 3d engine or something. I'm aiming for a fps. Lots of fun in perspective. Luckily, nethack should send relatively constant formated output (for the tty).
 
Old 02-14-2012, 02:03 AM   #17
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 709

Rep: Reputation: 428Reputation: 428Reputation: 428Reputation: 428Reputation: 428
Hi.

Take a look at glhack -- another frontend to nethack.
 
Old 02-14-2012, 02:32 AM   #18
S. Chapelin
Member
 
Registered: Jan 2010
Location: Quebec
Posts: 144

Original Poster
Rep: Reputation: 6
I'm thinking of eventually using pygame or a 3d module, but for now I just want to play around with it, see what it does, if it works properly. I just want to input a command and read the output. Have fun with it.

Sorry for the double post. I hadn't noticed there was a second page.
I will look at glhack.

Last edited by S. Chapelin; 02-14-2012 at 02:34 AM. Reason: double post
 
Old 02-14-2012, 07:15 AM   #19
S. Chapelin
Member
 
Registered: Jan 2010
Location: Quebec
Posts: 144

Original Poster
Rep: Reputation: 6
Talking

Played around with it for a bit.
Here is an example of the output.
Code:
response = [?1049hNetHack, Copyright 1985-2003
         By Stichting Mathematisch Centrum and M. Stephenson.
         See license for details.
Shall I pick a character's race, role, gender and alignment for you? [ynq]
command = y
response = y---------------|...f.........||.:.@.........||........$....|+.............|---+-----------Gillesg the Evoker        St:11 Dx:12 Co:13 In:18 Wi:10 Ch:11  Chaotic
Dlvl:1  $:0  HP:12(12) Pw:7(7) AC:9  Exp:1 It is written in the Book of Anhur:      After the Creation, the cruel god Moloch rebelled     against the authority of Marduk the Creator.     Moloch stole from Marduk the most powerful of all     the artifacts of the gods, the Amulet of Yendor,     and he hid it in the dark cavities of Gehennom, the     Under World, where he now lurks, and bides his time.  Your god Anhur seeks to possess the Amulet, and with it to gain deserved ascendance over the other gods.  You, a newly trained Evoker, have been heralded from birth as the instrument of Anhur.  You are destined to
command = 	
response = recover the Amulet for your deity, or die in the attempt.  Your hour of destiny has come.  For the sake of us all:  Go bravely with Anhur!--More-----------------|...f.........||.:.@.........||........$....|+.............|---+-----------Hello gillesg, welcome to NetHack!  You are a chaotic male human Wizard.Unavailable command '^I'..<f.@
command = #quit
response = # quituitittReally quit? [yn] (n) 
command = y
response = yDo you want your possessions identified? [ynq] (n) nDo you want to see your attributes? [ynq] (n) 
As you can see, it is rather constant. Shouldn't be too hard to parse. Just have to look for the position markers ([x;xxH) to build the map, then find the stats for the hud, display the messages in a pretty box. First, though, I'm just going to put the map into a two-dimensional array.
Long term puzzle. Lottsa fun in sight.
 
Old 02-15-2012, 09:11 PM   #20
S. Chapelin
Member
 
Registered: Jan 2010
Location: Quebec
Posts: 144

Original Poster
Rep: Reputation: 6
Unhappy

I've comme across a slight difficulty. See this extract of the output from nethack:
Code:
[5;60H|...f.........|
The [5;60H is the coordinates where nethack draws the map, which is the |, the line of dots and the f.
I have succeded in extracting the coordinates.
In order to extract the map portion, I must go from the H to the little square, which is in reality an escape caracter (0x1B), as I discovered in Hexedit.
So I tried the following line:
Code:
 while c_c[i] != 0x1B
and
Code:
 while c_c[i] != '0x1B'
and (desperate)
Code:
 while c_c[i] != ""
but none of them work.
Code:
$ python test.py
  File "test.py", line 40
    while c_c[i] != 0x1B
                       ^
SyntaxError: invalid syntax
Any ideas?
 
Old 02-15-2012, 09:34 PM   #21
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 709

Rep: Reputation: 428Reputation: 428Reputation: 428Reputation: 428Reputation: 428
Hi.

Try
Code:
while c_c[i] != '\x1B': ...
 
1 members found this post helpful.
Old 02-16-2012, 05:57 AM   #22
S. Chapelin
Member
 
Registered: Jan 2010
Location: Quebec
Posts: 144

Original Poster
Rep: Reputation: 6
Thanks. It worked. (I added a little security)
Code:
    while i < len(c_c) and c_c[i] != '\x1B':
Also, to Nominal Animal: I am going to look at pyte. I hadn't caught on earlier. I am sometimes slow to catch on. Thanks for the tip.

Code:
stream.feed(u"")  # Move the cursor up 5 rows.
So the escape[ sequence would mean move to?
Verrrry interrrestink. got to know more!

Last edited by S. Chapelin; 02-16-2012 at 06:08 AM. Reason: learned more
 
Old 02-16-2012, 07:39 PM   #23
S. Chapelin
Member
 
Registered: Jan 2010
Location: Quebec
Posts: 144

Original Poster
Rep: Reputation: 6
Believe it or not, this is what the nethack output looks like when it is put into a two dimentional array. Not much, right?
This should be the floor on which the hero will stand and look around from the position occupied by the '@', with his faithfull dog where the 'f' is, ready to be attacked by a lichen (':'), I think it is. What I want to do next is a pseudo3d, that is to say that the hero will be able to look around and move around with the mouse, but although he will probably be able to look up and down, it will be an illusion as he won't be able to move up or down. When he moves up or down a level, there will only be a replacement of the map by another. He won't see the stairs going down. Similarely, when he falls in a hole, in reality only his height will change. Nothing else.
Also, even though hethack is turn based, modern computers are so fast that I wonder if it will make a difference. I don't know. We'll just have to see.
Anyway, lots of fun in sight!
Code:
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000---------------00000
000000000000000000000000000000000000000000000000000000000000|...f.........|00000
000000000000000000000000000000000000000000000000000000000000|.:.@.........|00000
000000000000000000000000000000000000000000000000000000000000|........$....|00000
000000000000000000000000000000000000000000000000000000000000+.............|00000
000000000000000000000000000000000000000000000000000000000000---+-----------00000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0Python the Evoker         St:11 Dx:12 Co:13 In:18 Wi:10 Ch:11  Chaotic000000000
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Myth TV back end or front end. thedoctor Linux - Newbie 1 05-20-2010 07:58 PM
gui read out of back end command lines from gui front end activation? how? Siljrath Linux - General 0 10-24-2008 10:11 AM
Mythbuntu front-end and back-end questions... Liambiscuit Linux - Software 4 09-28-2008 05:11 PM
Multiple Apache - Front-end & Back-end in one server grant-skywalker Linux - Server 3 08-27-2008 02:04 PM
vB forum front-end? General Linux - Software 3 10-18-2005 12:14 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration