HamFon's Bot Of The Month Club
"Even with all of the browser programming I did (trueSpace, renderware animation (3.3), internationalization, tunnel server, and uncountable "little things"), I think the most fun I had was writing bots. BingoBot, Chess/Checkers, Trivia, CustomsAide, and several dozen custom bots for various administrative purposes - These bots gave me a chance to be inventive, to boldly go where no man had gone before", said HamFon. HamFon's Bots indeed revolutionized Active Worlds and the way users "interacted" with it.
HamFon's amiable demeanor also earned him a special place in the heart of the AW Community, as was evidenced by the large turnout at a "roast" in his honor this past week.
We here at Activeworlds Corp. appreciate the vision and dedication that Nelson brought to Active Worlds!
In honor of HamFon's last Bot of the Month Club article, Brant has graciously offered to share with us his latest bot - Demeter.
Demeter is a fully functional terrain editor that allows all citizens, regardless of world rights, to change the terrain under and around their buildings. A long history and many complicated features make Demeter unique among bots.
While many believe that the application simply appeared out of the blue, it was actually in the planning since November 2001. At the time, SW Chris of SW City approached me and asked about the possibilities of moving AlphaWorld's SW City to AWTeen. Chris, of course, wanted AWTeen to provide him with as many features not available in AlphaWorld as possible. Discussions were held for several weeks on topics ranging from Thor (AWTeen's weather simulator) to new objects and everything in between. One interesting point in the discussions was that of terrain. Obviously, Activeworlds Corp. couldn't be bothered to edit the terrain in a world the size of AlphaWorld, since the function was only available to world Caretakers. Thus, I promised SW Chris that we would figure out a way for him to edit the terrain in SW City should he choose to change worlds. In the end, the talks about moving the city fell apart on January 2, 2002, when Activeworlds descended into chaos.
It wasn't until next March, after I returned from a short vacation, that I considered terrain in a more detailed manner. With the release of version 3.3 planned to occur sometime soon, it was decided that one way to begin drawing new faces to the community would be to produce a technological advancement that wasn't available in any other world. A terrain editor for non-Caretakers was something that the AW browser overlooked, and seemed simple enough to implement at the time. Thus, I begin programming the project.
I started in early April, creating a C++ project and working on it for about a week. I quickly realized that, while C++ might be more efficient, I had already produced a great deal of Visual Basic source code dealing with all sorts of functions from the Activeworlds SDK. Development could be finished faster by switching languages to use this pre-written code. Thus, I produced a set of classes that I hoped would make Demeter extremely easy to develop, and they did.
The original plan was to use up to fifty bot instances to scan the world, since each instance could have only one outstanding query at a time. When a new terrain session would be requested, the application would spawn a new instance to query and keep in live update the area around the person in question. After the querying finished, the program would search for an object with the action "create name terrain$," the name chosen because of its unusual $ character that would be unlikely to be found in existing objects. By moving this object around, the application would detect changes to its height and location, and modify the terrain in the current cell to the height at which the "terrain object" was currently positioned.
While a solution to the problem, this method was not very intuitive because it required an extremely complex and processor-intensive encroachment checking routine. The program had to query the area in question for at least 100 meters in all directions, scan through all of the objects, and determine if any were in a state of encroachment for a given cell. The routine worked as planned, but took several seconds to do so. Since the routine would be called each time the terrain was changed, two seconds per call was unacceptable. I made a post to the news.activeworlds.com/sdk newsgroup to see if anyone had any better ideas, and Grimble offered to help.
We quickly decided that the best way to improve the registry checking routine would be to remove it altogether. If an object the size of a full cell was used as a marker, it could be placed in every cell that was modified by the terrain editor. Thus, newly placed terrain objects would encroach into that cell and modifying others' buildings would not be possible. All of the encroachment checking would be done on the server end, saving processor time for Demeter. In addition, the world server encroachment code was already written and tested, while writing our own code to perform the same task would take ages and would have required extensive testing.
By the time that Grimble hopped aboard, 3.3 was almost released. By that time, a significant portion of the program had been finished, but we didn't even have a concrete idea of exactly how the terrain would be implemented! On May 31, Grimble and I immediately noticed a problem - the elevation points of the terrain were located in the corners of each cell, while the textured area was to the northwest of the elevation point. Grimble suggested that the terrain markers now be placed centered on the elevation points instead of over each cell, which would make the editor's interface much easier to use.
At this point, Grimble continued working on the application itself, while I concentrated mostly on the accompanying tasks. Robbie and I created a terrain.rwx placeholder to be placed at each elevation point. The object, while simple, has several important characteristics. The plane is level with the terrain under it, while gridlines flow to the exact center of the object for easy positioning. A transparent cube surrounds the object in order to facilitate selection of the terrain placeholder when it's hidden in a hole or in a deep valley. Finally, the red quadrant of each object (which always points to the northwest) specifies which direction in which the texture for this particular elevation point is applied.
In addition, I also considered the issue of textures for Demeter. While AWGate already had some terrain textures available on its path, the default ground texture for the Gate was different from AWTeen's. It was immediately apparent that the fall_g ground texture would have to be the default terrain texture in order to be compatible with existing buildings. Thus, I again contacted Robbie, who volunteered to create textures to be used in AWTeen. He delivered in record time - a day later I had received an E-Mail containing 35 JPEG files with the appropriate textures. The textures include grass, dirt, mud, desert, and snow, as well as all the appropriate transitions, and are the same textures currently available in AWTeen.
Meanwhile, Grimble implemented an ingenious method of caching the terrain markers over the world for later manipulation using binary search algorithms. In the end, while Demeter should have taken much more memory and CPU power than any other bot that is currently active in AWTeen, Thor and the Xelagots currently running take almost three times more CPU power than Demeter, even when there are fifty to sixty people in the world at once. Without Grimble's skill in making projects as small as possible, Demeter would never have succeeded. Ironically, what I had thought would be a simple task turned out to take hundreds of hours of work to get running efficiently.
Demeter was finished in early June, but wasn't released until almost three weeks later, during AWTeen's Generations Day. The reason for the delay was a letter sent to Rick Noll (a.k.a. E N Z O) on June 6 asking him if he would attend Generations Day, where Demeter and several other projects would be unveiled. The unveiling was delayed for two and a half weeks while AWTeen's volunteers waited for a reply. In the end, we just decided to go ahead with the event. Demeter's unveiling went off without a hitch, with the exception of a bug wherein the program would lose track of terrain markers upon a disconnection from the world server. The problem was easily fixed. By the way, E N Z O did show up after all, but that's for another newsletter article :)
Behind the scenes, because of the caching system, Demeter does not know or need to know about all of the terrain markers in the entire world. When users say "d:begin" to start a new terrain session, Demeter begins tracking their locations and queries the area around them as they move. All of the markers found are entered into the master "cache," which is searched each time a marker is added to determine whether there are two markers in the same cell. When a user says "d:hide" or "d:show," all of the markers within twenty-five meters of his or her current position are made invisible or visible. When a user says "d:hide all" or "d:show all," all of the markers currently on record for a certain citizen number are hidden or shown, NOT all of the markers in unknown places that haven't been visited by any people recently.
Other commands for Demeter include the "d:seed" command, which wasn't particularly difficult to implement but opens up a variety of applications. One of the biggest problems in a public building world is that many areas out in the middle of nowhere do not have any objects nearby with which to begin building. "d:seed" is useful not only because it creates a terrain object with the default texture at the user's current height, but also because users can change the model of the object to whatever they choose, eliminating the need for citizens to log in bots to seed objects in a particular area.
Also of note is the ability to specify and rotate textures for any cell in the world. To specify a texture, the user only has to include the texture number in the description field of the terrain.rwx marker. Rotating textures is easy - simply include the rotation of the texture in degrees after the texture number, separated by a comma. Holes can be accomplished in a similar manner, by simply typing "hole" in the description field of an object. More information is available at http://www.awcommunity.org/awteen/demeter.html. I invite everyone to visit AWTeen and to start a new building (with terrain) today!
Overall, the most difficult part of the entire process was working through some of the abnormalities within the Activeworlds browser. For example, many users of Demeter now complain about how textures don't connect smoothly to each other, most noticeably in transitional areas. Apparently, 9 9 9 is reportedly working on resolving this issue in the next version of the browser, but it caused quite a bit of confusion during the development process. In addition, what Grimble and I once thought another problem with Demeter is actually a problem with the Activeworlds browser - sometimes terrain data stops downloading and gravity never enables. This problem wreaked havoc (and continues to wreak havoc) during our testing sessions, because some users were able to see the terrain updates as normal, while other users had encountered the bug and could see only flat ground. As far as we can tell, this problem can be remedied by clearing the cache folder each time it pops up.
To conclude the last ever Bot of the Month article, it would only be fair to pay tribute to HamFon, one of Activeworlds' most celebrated developers, without whom Demeter as well as every other Activeworlds bot would not exist. HamFon has made so many contributions to the community that an attempt to mention them all in one paragraph would be insulting, because I would inevitably have to leave out a great number. I hope that I speak for all members of the community in saying that HamFon was a great asset to Activeworlds Corp. He will be sorely missed.
If you're interested in finding out more about how to use the SDK, visit the SDK site for information!
Know of a bot that you'd like to see featured as the Bot of the Month? If so, contact us at email@example.com.
|Active Worlds | Newsletter Home | Newsletter Archive | Contact Us | Disclaimer|