Page 1 of 1
Free Your Code
Posted: Sun May 19, 2013 11:15 am
by loafingcoyote
For far too long I've let far too much code languish on my hard drive, unreleased. I've always been a bit of a perfectionist and the truth is that perfectionism is an enemy of productive work. That will end now. This is the thread where I finally release my pent up code to the Hugo speaking world.
The first item, NpcMove.h version 2, is done. You can find it
here on HbE. This version is now, no kidding, several hundred times more efficient than the original. The old version was so flawed that it's a wonder it worked at all. Version 2.0 is thoroughly tested and I don't anticipate it being changed much in the future.
The next items to be released in a timely manner:
- 1. GotoRoom.h - A Magnetic Scrolls type "go to [room]" extension, first introduced in C.H.U.M.S.
2. MapMaker.h - My random map generating routines, also first introduced in C.H.U.M.S.
3. Hugo Rap - A reactive agent planner for Hugo.
If anyone else has code that needs to see the light of day then you're welcome to release it here also. It can be an extension, game or whatever. It may not be perfect but, hey,
who cares? Come on...free your code!
-lc
Posted: Mon May 20, 2013 12:51 pm
by Roody_Yogurt
I was going to say, sadly, that I didn't think I had anything sitting around, but lo and behold, I had a couple things that I hadn't officially added to HbE yet.
First off is just an update to Cardinal Teulbach's CanGo extension, which does exit-listing. My extension is include-able and cleans up some code. It's called CanGoLite.
The second one is my attempt to write a better exit-listing extension. It uses object management instead of arrays to keep track of stuff. It's called NewCanGo.
I've talked about these things at Not Dead Hugo, so they might not be completely new to people, but hey, at least they have HbE pages now.
Glad to see you freed your code. I'm especially looking forward to playing with the Magnetic Scrolls room-traveling extension!
Everybody, free your code!
Posted: Mon May 20, 2013 3:40 pm
by loafingcoyote
Roody_Yogurt wrote:First off is just an update to Cardinal Teulbach's CanGo extension, which does exit-listing. My extension is include-able and cleans up some code. It's called CanGoLite.
The second one is my attempt to write a better exit-listing extension. It uses object management instead of arrays to keep track of stuff. It's called NewCanGo.
Thank you for your participation. CanGo is one of the most useful extensions imaginable so it's exciting to have
two new and improved version to pick from. Awesome work Roody, as usual!
Roody_Yogurt wrote:Glad to see you freed your code. I'm especially looking forward to playing with the Magnetic Scrolls room-traveling extension!
That's coming soon, maybe tonight. The minimal demo game that comes with it is almost done. I'll be interested to see your reaction to it. I think you'll be surprised at how I did it and probably start to have an idea how you could make your own(likely improved)version. You'll understand what I'm talking about when you see it ;)
-lc
Posted: Tue May 21, 2013 8:39 pm
by loafingcoyote
Alright, GotoRoom.h has been
set free. Anyone familiar at all with NpcMove.h will notice a lot of similarly between the two. In fact, the same code does the heavy lifting for both. Tomorrow I'll write up a proper HbE page and try to finish the demo game. After a long day at work I'm just too weary to do that tonight.
Also due tomorrow is my map making extension. It does what it was written to do but still needs a lot of work. I'll release it in a beta state, but that's okay; it doesn't have to be
perfect. Hopefully I'll have time to knock that out and keep this momentum going!
-lc
Posted: Wed May 22, 2013 3:49 pm
by Roody_Yogurt
You're right; seeing the code
did inspire me to go take my own swing at it, although your code definitely looks nicely configurable and robust. I just wanted to try see how well I could use my existing extensions towards the problem.
My design uses my "findpath.h" extension (although I found a bug in it while writing today's code, so a new version is up at HBE), which in turn uses the character scripting system.
My grammar is pretty much the same as yours:
Code: Select all
verb "go", "walk"
* DoGo
* "to" anything DoGoto
* "in"/"into"/"inside"/"through" object DoEnter
* "out"/"off" object DoGo
* "out"/"outside" DoExit
* anything DoGoto
Now, my only concern with that is that I ran into some problems in "The Next Day" where using the anything token caused me some trouble where there were objects-similarly-named-to-rooms because in Hugo, a nearby object always overrides a not-nearby room, no matter how much parser_rank-tweaking you do. It's very possible that my problems were caused by bad code, though.
The next bit of code is:
Code: Select all
include "findpath.h"
routine DoGoTo
{
if object.type ~= room
{
if FindObject(object)
{
! &DoGo *should* redirect to DoEnter in applicable circumstances
return Perform(&DoGo, object)
}
"You can't go to that!"
return false
}
elseif object = location
{
"You are already there."
return false
}
local a
MakePath(location,object)
a = SetPath(player)
If not a
{
"You can't get there from here."
return false
}
! take the first step of our journey
RunScripts
! check that we have more steps in our journey and that nothing
! important has happened
while ( (FindScript(player)~= MAX_SCRIPTS) and event_flag ~= 2)
{
main
}
}
! replaced CharMove to allow usage for the player character
replace CharMove(char, dir)
{
#ifclear NO_OBJLIB
local newroom, a
if dir.type ~= direction
return
newroom = parent(char).(dir.dir_to)
if newroom.type = door
{
a = newroom
newroom = a.between #((parent(char) = \
a.between #1) + 1)
if a is not open
{
if char in location or newroom = location
{
self = a
""
OMessage(door, 5)
}
}
elseif newroom = location or char in location
a = 0
}
if char in location and not a
{
Message(&CharMove, 1, char, dir)
if not event_flag
event_flag = true
}
if char = player
{
MovePlayer(newroom)
}
else
move char to newroom
#ifset DEBUG
if debug_flags & D_SCRIPTS
{
print "["; CThe(char); IsorAre(char, true); " now in: ";
print capital parent(char).name; ".]"
}
#endif
if char ~= player
{
if char in location and not a
{
Message(&CharMove, 2, char, dir)
event_flag = true
}
elseif char in location
event_flag = true
}
#endif ! ifclear NO_OBJLIB
run parent(char).after
return true
}
So, my system uses "findpath.h" to write the path steps to a character script for the player character. If you need to interrupt the walking, you have to set event_flag to 2.
Anyhow, the funniest side effect of doing it this way is that the player character picks up NPC's supernatural ability to go through doors, opening and closing them without using up a turn.
Posted: Wed May 22, 2013 10:07 pm
by loafingcoyote
I knew when you saw that I used my pathfinding routine for this you wouldn't be able to resist tying it yourself! I'm glad you did. I really like the way the movement messages look. The most impressive feature is the fact that you were able to include Findpath without modification(not counting the bug, of course). I'll put it to the test and let you know how it goes!
Roody_Yogurt wrote:Now, my only concern with that is that I ran into some problems in "The Next Day" where using the anything token caused me some trouble where there were objects-similarly-named-to-rooms because in Hugo, a nearby object always overrides a not-nearby room, no matter how much parser_rank-tweaking you do. It's very possible that my problems were caused by bad code, though.
This is a tricky issue. I've been fortunate that it hasn't been a real problem for me yet, but I haven't used it in anything but small games. This is an issue that will probably take a little effort to work through.
All right, tonight's code release is
MapMaker. It is very rough but stable; it hasn't failed me yet. There are a lot of planned features that are not yet implemented. Again I'm short of time tonight, so a proper HbE page will probably have to wait for the weekend. The important thing is that this code has been released from bondage. What a relief!
-lc
Posted: Wed Mar 09, 2016 8:52 pm
by Roody_Yogurt
The other day, I was looking for something in this base and was reminded of this thread and was like, wow, yeah, that was a great idea!
I think we should turn "Free Your Code" Day into an annual holiday.