<!-- MHonArc v2.4.4 --> <!--X-Subject: Re: [MUD-Dev] Sparse Arrays and co-ordinate based worlds --> <!--X-From-R13: [vpunry Vburafrr <zvpunryNfcnegn.znvafgernz.arg> --> <!--X-Date: Thu, 07 Aug 1997 16:08:46 +0000 --> <!--X-Message-Id: 33E9F29D.7914A8D9#sparta,mainstream.net --> <!--X-Content-Type: text/plain --> <!--X-Reference: 199708051726.MAA31970#laurel,actlab.utexas.edu --> <!--X-Head-End--> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html> <head> <title>MUD-Dev message, Re: [MUD-Dev] Sparse Arrays and co-ordinate based worlds</title> <!-- meta name="robots" content="noindex,nofollow" --> <link rev="made" href="mailto:michael#sparta,mainstream.net"> </head> <body background="/backgrounds/paperback.gif" bgcolor="#ffffff" text="#000000" link="#0000FF" alink="#FF0000" vlink="#006000"> <font size="+4" color="#804040"> <strong><em>MUD-Dev<br>mailing list archive</em></strong> </font> <br> [ <a href="../">Other Periods</a> | <a href="../../">Other mailing lists</a> | <a href="/search.php3">Search</a> ] <br clear=all><hr> <!--X-Body-Begin--> <!--X-User-Header--> <!--X-User-Header-End--> <!--X-TopPNI--> Date: [ <a href="msg00421.html">Previous</a> | <a href="msg00423.html">Next</a> ] Thread: [ <a href="msg00397.html">Previous</a> | <a href="msg00395.html">Next</a> ] Index: [ <A HREF="author.html#00422">Author</A> | <A HREF="#00422">Date</A> | <A HREF="thread.html#00422">Thread</A> ] <!--X-TopPNI-End--> <!--X-MsgBody--> <!--X-Subject-Header-Begin--> <H1>Re: [MUD-Dev] Sparse Arrays and co-ordinate based worlds</H1> <HR> <!--X-Subject-Header-End--> <!--X-Head-of-Message--> <UL> <LI><em>To</em>: <A HREF="mailto:mud-dev#null,net">mud-dev#null,net</A></LI> <LI><em>Subject</em>: Re: [MUD-Dev] Sparse Arrays and co-ordinate based worlds</LI> <LI><em>From</em>: Michael Hohensee <<A HREF="mailto:michael#sparta,mainstream.net">michael#sparta,mainstream.net</A>></LI> <LI><em>Date</em>: Thu, 07 Aug 1997 12:06:53 -0400</LI> <LI><em>Sender</em>: <A HREF="mailto:michael#sparta,mainstream.net">michael#sparta,mainstream.net</A></LI> </UL> <!--X-Head-of-Message-End--> <!--X-Head-Body-Sep-Begin--> <HR> <!--X-Head-Body-Sep-End--> <!--X-Body-of-Message--> <PRE> Cynbe ru Taren wrote: > > | Ok, next improvement. Instead of having one linked list, break it up > | into a few hundred lists with a hashtable. That way, when you look for > | from [100][20][0] to [110][30][10], avoiding going over the room at > |[90][23][5] and its friends. > > Bingo, except there's no reason to use spatial clustering like > that for your hash function: Won't help you and is quite likely > to hurt you. Just mangle key (three integers, in this case) into > a pretty arbitrary hashcode to scatter your entries over the table. > Adding them is a quick hack, using something like MD5 will give > you a betterhash which may or may not be worth the coding and run > time. Keep the table empty enough that most of your lists are > one long or empty. Hmm. Good idea. I was kinda turning green whilst trying to code my hashtable to insert rooms into the right spot.. One problem.. How do you deal with "filler" entries? In a spatial oriented hashtable, one would just toss one entry which tells the program that the locations ahead of it are of type X and go on for length Y. While objects are real easy to find in the system you propose, it seems unclear as to where to place the filler entries. (we can't place them individually in each "empty" area, or else we might as well have a matrix) > > | Would such a system be viable? Could any improvements be made to it? > > Well, you're effectively basing your system on a coarse integer > coordinate system. If the idea works at all, I'd predict on past > experience that you'll wind up cursing them eventually and recoding > to use float coordinates. If you wind up doing anything involving > needing to know object orientation, you will then eventually wind > up cursing -that- and representing object coordinate info using > 4x4 homogeneous transform matrices... or wishing you could but being > unable to because of installed codebase (e.g., the NASA Panel library > wound up that way). There's still no particular problem hashing > three or sixteen floats into a hashcode and looking them up, if you're > just needing exact matches. (Need to watch precision problems a > bit, depending on what your're doing.) If you can't settle for > exact matches, then you're back to R-trees, which have already > been covered here. :0 The system as it stands is as follows (in C++) World is represented on a hashtable of Wld_Entry classes (structs, to the C++ impared) class Wld_Entry { int terrain; Base_Obj *room; int how_far; Wld_Entry *Xnext; Wld_Entry *Xprev; Wld_Entry *Ynext; Wld_Entry *Yprev; Wld_Entry *Znext; Wld_Entry *Zprev; int X; int Y; int Z; }; Each Wld_Entry can either represent an "empty" zone, (ie tell the program that there are no specific rooms created for "how_far" units in the +X direction, and that they all have terrain type "terrain"), or it can contain a room. (The room, of course, can be any other sort of object as well.) When we need to insert a room into the hashtable (when a player or other object wanders into an "empty" zone, or during boot-up) we call the function: insert_at_location(Wld_Entry *obj, int x, int y, int z); This function hashes each co-ordinate value, and travels down the table till it gets to the correct spot. It also checks to see if any filler statements are going have to be modified to keep up with this new arrangement. We remove objects from their locations with remove_from_location(......); The problem is (and it hasn't been coded yet) that it is very ugly to code, from what little I've started. -- Michael Hohensee michael#sparta,mainstream.net <A HREF="http://www.geocities.com/SiliconValley/Heights/9025/">http://www.geocities.com/SiliconValley/Heights/9025/</A> Finger me for my PGP Public Key, or use: <A HREF="http://sparta.mainstream.net/michael/pgpkey.txt">http://sparta.mainstream.net/michael/pgpkey.txt</A> </PRE> <!--X-Body-of-Message-End--> <!--X-MsgBody-End--> <!--X-Follow-Ups--> <HR> <!--X-Follow-Ups-End--> <!--X-References--> <UL><LI><STRONG>References</STRONG>: <UL> <LI><STRONG><A NAME="00397" HREF="msg00397.html">Re: [MUD-Dev] Sparse Arrays and co-ordinate based worlds</A></STRONG> <UL><LI><EM>From:</EM> Cynbe ru Taren <cynbe#laurel,actlab.utexas.edu></LI></UL></LI> </UL></LI></UL> <!--X-References-End--> <!--X-BotPNI--> <UL> <LI>Prev by Date: <STRONG><A HREF="msg00421.html">Re: [MUD-Dev] Spellcaster, or Waving Hands</A></STRONG> </LI> <LI>Next by Date: <STRONG><A HREF="msg00423.html">Re: [MUD-Dev] Spellcaster, or Waving Hands</A></STRONG> </LI> <LI>Prev by thread: <STRONG><A HREF="msg00397.html">Re: [MUD-Dev] Sparse Arrays and co-ordinate based worlds</A></STRONG> </LI> <LI>Next by thread: <STRONG><A HREF="msg00395.html">[MUD-Dev] Worlds VS Games, etc {was GMuds, UO}</A></STRONG> </LI> <LI>Index(es): <UL> <LI><A HREF="index.html#00422"><STRONG>Date</STRONG></A></LI> <LI><A HREF="thread.html#00422"><STRONG>Thread</STRONG></A></LI> </UL> </LI> </UL> <!--X-BotPNI-End--> <!--X-User-Footer--> <!--X-User-Footer-End--> <ul><li>Thread context: <BLOCKQUOTE><UL> <LI><strong><A NAME="00401" HREF="msg00401.html">[MUD-Dev] Ultima Online/Generalized AI</A></strong>, Koster, Raph <a href="mailto:rkoster#origin,ea.com">rkoster#origin,ea.com</a>, Wed 06 Aug 1997, 02:13 GMT <LI><strong><A NAME="00400" HREF="msg00400.html">RE: [MUD-Dev] Graphic MUDS/perspectives</A></strong>, Koster, Raph <a href="mailto:rkoster#origin,ea.com">rkoster#origin,ea.com</a>, Wed 06 Aug 1997, 01:58 GMT <UL> <LI><strong><A NAME="00406" HREF="msg00406.html">Re: [MUD-Dev] Graphic MUDS/perspectives</A></strong>, Jeff Kesselman <a href="mailto:jeffk#tenetwork,com">jeffk#tenetwork,com</a>, Wed 06 Aug 1997, 09:34 GMT </LI> </UL> </LI> <LI><strong><A NAME="00397" HREF="msg00397.html">Re: [MUD-Dev] Sparse Arrays and co-ordinate based worlds</A></strong>, Cynbe ru Taren <a href="mailto:cynbe#laurel,actlab.utexas.edu">cynbe#laurel,actlab.utexas.edu</a>, Wed 06 Aug 1997, 00:26 GMT <UL> <LI><strong><A NAME="00422" HREF="msg00422.html">Re: [MUD-Dev] Sparse Arrays and co-ordinate based worlds</A></strong>, Michael Hohensee <a href="mailto:michael#sparta,mainstream.net">michael#sparta,mainstream.net</a>, Thu 07 Aug 1997, 16:08 GMT </LI> </UL> </LI> <LI><strong><A NAME="00395" HREF="msg00395.html">[MUD-Dev] Worlds VS Games, etc {was GMuds, UO}</A></strong>, Koster, Raph <a href="mailto:rkoster#origin,ea.com">rkoster#origin,ea.com</a>, Tue 05 Aug 1997, 23:04 GMT <LI><strong><A NAME="00382" HREF="msg00382.html">Sparse Arrays and co-ordinate based worlds</A></strong>, Michael Hohensee <a href="mailto:michael#mainstream,net">michael#mainstream,net</a>, Tue 05 Aug 1997, 00:51 GMT <UL> <li><Possible follow-up(s)><br> <LI><strong><A NAME="00394" HREF="msg00394.html">Sparse Arrays and co-ordinate based worlds</A></strong>, Michael Hohensee <a href="mailto:michael#sparta,mainstream.net">michael#sparta,mainstream.net</a>, Tue 05 Aug 1997, 21:12 GMT <UL> <LI><strong><A NAME="00398" HREF="msg00398.html">Re: [MUD-Dev] Sparse Arrays and co-ordinate based worlds</A></strong>, Shawn Halpenny <a href="mailto:malachai#iname,com">malachai#iname,com</a>, Wed 06 Aug 1997, 00:38 GMT </LI> </UL> </LI> </UL> </LI> </UL></BLOCKQUOTE> </ul> <hr> <center> [ <a href="../">Other Periods</a> | <a href="../../">Other mailing lists</a> | <a href="/search.php3">Search</a> ] </center> <hr> </body> </html>