Bug 2889 - botlib fuzzy relations: interpolation bug
Status: RESOLVED FIXED
Alias: None
Product: ioquake3
Classification: Unclassified
Component: Misc
Version: 1.33 SVN
Hardware: All All
: P2 minor
Assignee: Thilo Schulz
QA Contact: ioquake3 bugzilla mailing list
URL:
Depends on:
Blocks:
 
Reported: 2006-10-05 12:11 EDT by cyrri
Modified: 2007-05-21 11:22:42 EDT
1 user (show)

See Also:


Attachments
fixed weight interpoation (1.55 KB, patch)
2006-10-25 04:04 EDT, cyrri
fixed weight interpoation (1.55 KB, patch)
2006-10-25 04:05 EDT, cyrri

Description cyrri 2006-10-05 12:11:59 EDT
be_ai_weight.c  ->  FuzzyWeight_r()
bugged:

//the scale factor
scale = (inventory[fs->index] - fs->value) / (fs->next->value - fs->value);
//scale between the two weights
return scale * w1 + (1 - scale) * w2;


fixed:

//the scale factor
scale = 1.0*(inventory[fs->index] - fs->value) / (fs->next->value - fs->value);
//scale between the two weights
return (1 - scale) * w1 + scale * w2;


http://www.quakesrc.org/forums/viewtopic.php?t=5374&postdays=0&postorder=asc&start=211
Comment 1 Thilo Schulz 2006-10-12 08:51:48 EDT
Thank you, it's fixed.
Comment 2 Thilo Schulz 2006-10-12 09:14:12 EDT
I had to revert parts of your fix to:

return scale * w1 + (1 - scale) * w2;

As your change would result in errors when playing a normal botmatch.
However, I added a few more float casts for precision reasons.
Comment 3 cyrri 2006-10-15 05:28:07 EDT
by errors you mean that bots never change weapons, right? i just recognized another bug related to default cases in the fuzzy relations. they get the value MAX_INVENTORYVALUE (999999) assigned, and therefor scale between the default and any lower case will always be 0. with scale 0 and the correct weighting [ return (1 - scale) * w1 + scale * w2 ] w1 will be returned. for the weapon relations, w1 is always 0, since they all have this line before the default case:
[ case 1: return 0; ]

as fix i suggest:

//the scale factor
if(fs->next->value == MAX_INVENTORYVALUE) // is fs->next the default case?
	return w2;	// can't interpolate, return default weight
else
	scale = (float) (inventory[fs->index] - fs->value) / (fs->next->value - fs->value);
Comment 4 Thilo Schulz 2006-10-18 08:10:04 EDT
No, by errors I mean red lines saying: "Error: Weapon number out of range!" or something like that.
Please turn your suggestions into patches (this is not difficult to do with tortoise svn client) which I can test then. If the error described is gone I'll apply it.
Comment 5 Thilo Schulz 2006-10-18 08:11:41 EDT
To be more precise: turn your suggestions into *one* patch only.
Comment 6 cyrri 2006-10-25 04:04:27 EDT
Created attachment 1124 [details]
fixed weight interpoation
Comment 7 cyrri 2006-10-25 04:05:03 EDT
Created attachment 1125 [details]
fixed weight interpoation

test
Comment 8 cyrri 2006-10-25 04:26:44 EDT
edit:
oops it worked. i got this error and thought the submission failed:
Unknown field id: attachments.isobsolete at globals.pl line 115.

both patches are identical.
your "out of range" error is the one i meant. all weapon relations return weight 0, weapon number 0 is chosen, which is out of range.
Comment 9 Thilo Schulz 2006-10-25 17:21:35 EDT
comitted, thanks.
Comment 10 Ryan C. Gordon 2007-05-21 11:22:42 EDT
Setting a QA contact on all ioquake3 bugs, even resolved ones. Sorry if you get a flood of email from this, it should only happen once. Apologies for the incovenience.

--ryan.