Skip to main content
gamedev.net
🔒 Locked

LISP help?

Started by ofsinope May 7, 2003 at 7:41 PM 9 replies 700+ views
Original Post
ofsinope
ofsinope
Does anyone have LISP code for text to list input (for a text-based RPG)? All I really need is capability to understand string input--or at least parse it to lists! i.e.: Parse only: "Throw red rock hard at big ugly giant" ==> (Throw red rock hard at big ugly giant) True understanding: "Throw red rock hard at big ugly giant" ==> ((Throw hard) (rock red) at (giant big ugly)) The second part is just car/cdr/cons wrangling, though, and is actually easier for me! I really only have trouble with strings...read and write and concatenate oh my. Thank you very much! I know LISP isn''t really a "language of choice" for most people anymore but maybe somebody out there stuck with it.....
bishop_pass
bishop_pass
Forget about text parsing right now. Just input using list format: (throw the red rock at the super ugly monster). That''s what is so great about Lisp, it let''s you forget about all the bullshit and get to the heart of the problem. When you''re done with the guts of your program, you''ll have the skills necessary to do the text parsing.

Seriously, do it the Lisp way. Bypass the text parsing right now, and just do it in list form.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in
SabreMan
SabreMan
quote:
Original post by ofsinope
Does anyone have LISP code for text to list input (for a text-based RPG)?

Check out `read-from-string''. E.g:

(read-from-string
(format nil "(~A)" "throw red rock hard at big ugly giant"))

quote:

Thank you very much! I know LISP isn''t really a "language of choice" for most people anymore but maybe somebody out there stuck with it.....

Stuck with it?
Diodor
Diodor
Maybe not the most elegant method to parse a string, but you can access strings char by char with AREF, you can retrieve parts of a string using SUBSEQ. MAP also works on strings.
ofsinope
ofsinope
SabreMan: Hey, that''s pretty clever. Great idea! I think I''ll modify it just a bit and go with:

(read-from-string (concatenate ''string "(" "throw your mom at whatever" ")"))

...just because format is such a monstrously bloated function.

BishopPass: I''ve been doing that so far, but EVERYONE doesn''t really need to know that it was written in lisp. Requiring parentheses make it so brutally obvious...
Diodor: Retch! As long as people don''t throw in any ran@#$!%^dom characters, I shouldn''t need to go to those extremes.

Thanks y''all...
Diodor
Diodor
quote:

Diodor: Retch! As long as people don''t throw in any ran@#$!%^dom characters, I shouldn''t need to go to those extremes.



Is there any simple way to avoid the program crashing when the user does throw random characters at your program? If not, it seems to me that sooner or later you''ll have to give up on READing input.
bishop_pass
bishop_pass
quote:
Original post by ofsinope
BishopPass: I''ve been doing that so far, but EVERYONE doesn''t really need to know that it was written in lisp. Requiring parentheses make it so brutally obvious...

So you''re totally done with the program then?

_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in
ofsinope
ofsinope
quote:
Original post by bishop_pass
So you''re totally done with the program then?



Haha! I wish...I''m just getting started, really. But I have a few simple functions that handle the savegames and the world map...once they''re finished, you can have them if you want.
bishop_pass
bishop_pass
quote:
Original post by ofsinope
Haha! I wish...I''m just getting started, really.

Ah Ha! You should be focusing on the semantics and guts, not the low level I/O.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in
bishop_pass
bishop_pass
quote:
Original post by Anonymous Poster
I''m just puttering around and having fun.

Excellent! All the more reason to get down and dirty with the good stuff, rather than fooling with the low level I/O. Tnakfully, you have made a wise decision and selected a language and paradigm that will let you do that with your limited amount of time.

Have you read any of Schank''s works? Or Winograd''s?

_______________________________

"To understand the horse you''ll find that you''re going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses


ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.