Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Creating a MUD client...

This thread is locked; no one can reply to it. rss feed Print
Creating a MUD client...
nshade
Member #4,372
February 2004

Call me crazy ^_^

Every single mud client I have downloaded for my Linux box is buggy or reqires some wierd lib breaks my dependices.

Necessity being the mother of all inventions I have decided to write my OWN mud client, as I need a good goal anyway.

So what does this have to do with Allegro? and why on Earth can't I just use telnet like the rest of the known universe?

Well, you see, the goal is to write a generic graphical sprite-based client for MUDs and MUSHs.

The problem is I need to learn how to make a generic telnet connction to a host. I can write my own english parsers, but I don't know how to make a socket connection. Can someone point me to some simple examples? I'll also elaborate a little if you guys need me to.

-J

Billybob
Member #3,136
January 2003

You're crazy.

Try [url www.google.com] -ing for "socket programming example tutorial" or look in the depot and the forum for the depot for MUD clients, I recall there being one around within the past year or less :)

nshade
Member #4,372
February 2004

I did that. I seem to run into a problem. I was thinking I could just do something like this;

internet_open("domain.com",23);
inernet_read(input);
/* wait till characters stop coming in */
prinf(input);
get_keyboard_string();
internet_write(keyboard_string);

and then loop

It seems that you have to "talk" telnet to the telnetd server before you even get characters. You also have to do all kinds of stuff like do domain lookups even before you connect. I was told to go read an RFC on the telnet protocol.

BAH!

I thought it was like reading a serial port (I've made term programs in the past.) I was hoping for a quick telnet program that was 50 lines or so. Enough to connet, read data and then write data.

The examples use thier own simple protocols and don't have any ability to negotiate with a telnet server. I even thought of using busybox's telnet program, but even that is spread out between five diffrent files.

Anyone have any other ideas?

*** ADDUMDUM ***

Duhhh! I'm spacing! I can DL the source to more simplistic MUD clients and work from there. The framework would be built already

Oscar Giner
Member #2,207
April 2002
avatar

I also started doing a MUD, but didn't arrive to anything. But I wrote all the code for managing the telnet connection (really, I didn't do much more than that). I don't have it here, but I can post it this night when I get home.

Derezo was doing a MUD, and he put the code available in his web page.

Niunio
Member #1,975
March 2002
avatar

I'm lost, since I don't know what's a MUD ???

Anyway, you're talking about socket connection so I'll suggest you to use a cross-platform net library, as LibNet or such. This way that MUD thing will be more cross-platform...

Or, is it impossible?

[edit]I did a google search and I discovered that MUD is a kind of multiplayer RPG... Cool[/edit]

-----------------
Current projects: Allegro.pas | MinGRo

gnolam
Member #2,030
March 2002
avatar

Telnet in passive mode is more or less what you describe - every byte sent is basically a character. You should do a full implementation of Telnet with option negotiation (the "talking" you see when you connect) though... it's not that hard, really :)

A good page describing the Telnet protocol can be found here: http://www.scit.wlv.ac.uk/~jphb/comms/telnet.html (no RFCs needed :))
It was an invaluable resource when I was writing a MUD for a Uni project...

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Maverick
Member #2,337
May 2002

J Walker said:

Every single mud client I have downloaded for my Linux box is buggy or reqires some wierd lib breaks my dependices.

Tiny Fugue works fine for me, though it's not exactly graphical. It's been quite a while since I compiled it, but IIRC the only external lib it uses is curses.

J Walker said:

The problem is I need to learn how to make a generic telnet connction to a host. I can write my own english parsers, but I don't know how to make a socket connection. Can someone point me to some simple examples?

Beej's Guide to Network Programming is one of my personal favorite sites with information on socket programming. It doesn't have anything specific to telnet, but the MUD servers I've seen (well, server... PennMUSH) don't use any special handshaking, except for detecting Pueblo clients.

-Maverick

-----
"the polls here don't change as much because I believe so much in free speakin' that I want everyone a chance to vote at least once, and possibly a few dozen times, that way they are really heard." -Matthew Leverton

Steve Terry
Member #1,989
March 2002
avatar

Straight up TCP/IP communication is pretty straightforward once you learn all the functions and stuff. Other things you have to keep in mind is byte order if you ever want a mac and PC to talk, though functions do that too, but you have to use them. Another powerful function to learn is select(). This allows you to poll a socket for read/write so you can either pause and have the CPU do 0 work until select returns, or you can have it return every time but makes for a nice non-blocking way of handling multiple client connections to a server since it will tell you once any data is available and from which socket to get that data from. I wrote a nice Server/Client app in college that was a multi-client database, not too tricky to handle, and MUDS should use the same principle.

___________________________________
[ Facebook ]
Microsoft is not the Borg collective. The Borg collective has got proper networking. - planetspace.de
Bill Gates is in fact Shawn Hargreaves' ßî+çh. - Gideon Weems

Oscar Giner
Member #2,207
April 2002
avatar

A attach my MUD code. May it help you. You really won't call this a mud, because all it does when you connect is asking you for a login, and then asks you if you want to create a new player. But all the connection stuff is done, and I did all the telnet protocol stuff. It's in C++. No comments but IMHO most of the code is neat. I include the MSVC workspace, but it should compile with any compiler with minor, if any, modifications.

There's only one bug I added sometime: for some reason, if you close the windows' telnet window (it doesn't happen with putty) the server hangs. I couldn't figure out what I did wrong.

[edit] Forgot the attachment

[edit2] I tested it, and now it doesn't hang, but I didn't touch anything:-/ However, it still doesn't detect the disconnection. But only with windows telnet. It works with putty. It's weird.

Billybob
Member #3,136
January 2003

No attachment. Don't worry, I do it to.

EDIT; he fixed it.

nshade
Member #4,372
February 2004

I found tintin++ has a real stright forward init and connect function. TF is cool but it also mutitasks sessions which means the connect code is thread-safe and a little more complex.

If someone can post thier own simple telnet connect I would like that..

Here's my idea for the client. You see what I'm planning on doing is writing a program that can parse a mud room, and then generate a sprite based 2D version of the dicription. It breaks down the paragraphs into sentenses and then breaks those down into thier indiviual parts of speech and "trigger" off of the discriptions.

"There is a road to your west"->(Draw road)
"obvious exits, North, south"->(Draw exits)
"Marrcke is here" -> (Draw Marrcke)

Think of it as a really complex graphical trigger system/automapper. If the world is rendered "wrong" there is a palette of objects at the bottom of the graphic window to allow you to add details to the room the computer missed. You then walk your little sprite guy around the room to interact with the envionment.

There will still be a command line so you can put "normal" input in as well

The idea is to have the system "learn" the current mud you are playing on. These can be saved as memory files and traded between mudders.

My test MUD?

I have a lab computer set up where when you connect via telnet to it you get Zork 1. I have bunches of infocom games to try this idea out with.

It's more a proof of concept more than anything...

I really like this as I start small (Making a simple telnet connection) and can build off of it, yet still have a goal in mind.

Anyone want to offer some input?

ADDUNDUM:

I'm a bit of a knob when it comes to c++. I also don't know windows very well at all. I have been running Linux only for the last few years and don't know much about it anyomre. (I quit windows after ME came out)

Mae Mutts
Member #3,766
August 2003
avatar

I have a modified star wars MUD based upon the MERC code base, if you want to take a peek. I also have a semi-cloned version of it in Java. I plan on writing a new one, 2D-graphical based in c++ w/ allegro when I get the time. But none right now.

I've attached the mud.h and comm.c files for you to look at. If there is a misisng piece, I will repost those portions tomorrow when I get back to work.

I don't mind posting this since I did a ton of work on this heavily-modified MUD ( not sure where it is anymore though after I left :( ).

Radagar
Member #2,768
September 2002
avatar

Well, I'd say your idea is VERY optimistic. If it works, great... But this is going to be a LOT of work. I wish you the best of luck.

If you have a windows system available, I would suggest downloading Zmud from www.zuggsoft.com - take a look at it's automapper and #trigger system. It might help you out.

------------
Radagar - So your vote is for A.D.H.D.?
Chris Katko - Well, that was uninten--ooh kitty!

nshade
Member #4,372
February 2004

This is cool, but alas, it's server code. I'm just making a simple telnet app for now (Start small, work big) That will be my foundation, I'll start rewriting my parser after that is sorted out. If it becomes too big of a job, at least I have a cute graphical telnet application.

The whole system works on "foudation building"

I expect that the computer isn't going to be able to parse whole rooms, it's just a really pretty interactive automapper. I'll have a few predefined "rooms" that the system will trigger off of. (Swamp, field, cave, inn) and a few events (Rain, snow, %s is here '...,) I have a contextual parser hanging around that I've fiddled with.

After the room is "rendered" a tool palette is availible for the user to spice up the room based on discription. (Think MUD client meets RPGMaker) The parser will be availible to the user in game. For example, if the system flakes out on a particular way a discription is communicted, you can alter the parser to trigger off of the correct context.

What makes the system unique is that the parser not only triggers off on literals, ("there is a %s here"), but can identify parts of speech and can trigger off of a particular noun or verb within the context of a sentence. Here and example from my parser I've been messing with.

-------------------------
halkun@naru~:>parse "You are standing west of a white house."

2 Noun(s) found: "You"[context: sentence subject], "house"[context: sentence object]

1 verb(s) found: "standing"[type: -ing form "stand", context: "You"]

1 adjective(s) found: "white"[context: "house"]

1 adverb(s) found "west"[context: "standing" subject: "You", object: "house"]
--------------------

It took me forever to figure out how to parse an adverb correctly there's a lot of information that's reqired for that to work properly. It breaks with sentences with more than one subject/object pair. "You are standing west of a white house with a boarded front door" doesn't parse right. (For example "West" was not parsed as a noun becuse there was already nouns slotted in the "subject" and "object" slots.)

Pretty neat-o eh? ^_^

Go to: