Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ofsinope

LISP help?

This topic is 5610 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.....

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Snif. Don''t "Ah ha" me.

Hehe...look, the odds of me seeing this through to completion are rather low, just because I have so many more productive things that I need to do. I''m just puttering around and having fun.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!