Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
Bug in do_drag( )
Oct 8, 2017, 12:40 am
By GatewaySysop
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Beastmaster 6D sound files
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, Yahoo!, DotBot

Members: 0
Guests: 4
Stats
Files
Topics
Posts
Members
Newest Member
476
3,704
19,231
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » AFKMud Support & Development » help search seems to be a bit...
Forum Rules | Mark all | Recent Posts

help search seems to be a bit off
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Oct 18, 2011, 5:48 am
Go to the top of the page
Go to the bottom of the page

drmike
Fledgling
GroupMembers
Posts16
JoinedOct 9, 2011

It's interesting that when I search for paladin, I get the anti-paladin help file.

Maybe my server needs an exorcism? :)

Any suggestions on how to deal with that?

I also noticed that there wasn't an entry for monks. At least I don't see one and it falls back to using 'monk damage'. Anyone ever write up a good one?

thanks
       
Post is unread #2 Feb 23, 2012, 11:07 am   Last edited Feb 23, 2012, 11:10 am by Kronotross
Go to the top of the page
Go to the bottom of the page

Kronotross
Fledgling
GroupMembers
Posts5
JoinedFeb 23, 2012

I realize that this is several months after the fact and that I've been posting a lot in a relatively short amount of time, but I also ran across some help difficulties and I figured I'd record the problem I found and the fix I did.

At the heart of the help approximation is the string::find function that looks for your argument inside the keyword of each help file until it finds one that contains your argument. For drmike here, he was searching for "paladin", but alphabetically the first entry that contains that argument is "anti-paladin". The fact that there is a help file with the keyword of exactly "paladin" never comes up.
For me, I was looking for a refresher on the intricacies of "redit" but was only given "credit".

Right off the bat, there's a large efficiency hit that's going to happen because the search is performed on a List of help_data structs, so the only way to be sure that there is no entry that does not precisely match the argument is to search every single one every time, because what if zzz is a helpfile?

So at line 221 of help.cpp I now have:
help_data* bHelp=NULL;
int lev, diff, bDiff=10;


So now diff will track how close each string::find is, bDiff will be the best difference so far, and bHelp will be what help file that best difference was.
My compiler didn't like it when I tried to "help_data* pHelp, bHelp = NULL;" so that is why bHelp gets its own line.

Then in the main loop, at line 258 in help.cpp I made the bulk of the changes:
  if( !(argall.compare(pHelp->keyword) ) ) // bingo
	return pHelp;

  if( ( diff = (pHelp->keyword).find( argall ) ) != string::npos ) 
  { // then the argument is somewhere in the keyword
	if(!diff) //As close to the front as possible: 0
		return pHelp;
		
	if ( diff < bDiff )
	{ // then the match is closer to the front of the word than our best case
		bDiff = diff;
		bHelp = pHelp;
	}
  }
}
return bHelp; 


Now "help redit" returns redit and "help dventure" returns adventure. If nothing is ever found by string::find, bHelp is never changed from NULL and so the usual behavior continues from there.

Sorry for being long-winded, but I wanted to properly convey the problem because I feel my solution is non-ideal. With a List, I don't see any other method that doesn't include non-ideal accuracy or N iterations being common. I could see replacing it with a Map with keywords for keys so any exact match circumvents a loop, but I'm not crazy enough to make that big of a change. Today.

Hope this helps anybody who comes across it.
       
Post is unread #3 Feb 25, 2012, 5:46 am
Go to the top of the page
Go to the bottom of the page

Kronotross
Fledgling
GroupMembers
Posts5
JoinedFeb 23, 2012

I guess there's an edit timer on this forum or I would have just edit my fix.

I wasn't aware "keyword" can be a list of many keywords, and so can be much longer than 10 characters long. This makes my solution even more inefficient as, for example, "help start" will never have a diff less than ~15 or so, so it will never match exactly to break the loop, nor will it reach diff=0 to break the loop.

Anyway, for now making bDiff unreasonably big like 99 makes it so you can access help files with long keywords.
       
Pages:<< prev 1 next >>