-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Julien Cornuwel a ?crit :
> Matthew Toseland a ?crit :
>> On Tuesday 05 August 2008 15:31, Julien Cornuwel wrote:
>>> Matthew Toseland a ?crit :
>>>
>>>>> +                 if(trusterScore.getCapacity() > 0) {
>>>>> +                         newScore += trusterScore.getCapacity() * 
>>>>> trusterTrust.getValue() / 
>> 100;
>>>>> +                         if(newRank == -1 || newRank > 
>>>>> trusterScore.getRank())
>>>>> +                                 newRank = trusterScore.getRank();
>>>> Surely this should be || newRank < trusterScore.getRank()? Larger numbers 
>> =
>>>> less trusted, right?
>>> Nope, that code gets the lowest truster's capacity (most trusted),
>>> different from -1.
>> You are fetching rank here, not capacity. Lower is better for rank (unless 
>> it's -1). No?
> 
> That's right, how did my code happen to work with that ?!? Surely we'll
> have to do more extensive testing later...

Doh ! I was reading your code ! Not mine.
Let's take an example...

An identity receives 4 trusts from ranks 3, 4, 1 and 2.

loop1 : newRank = -1, trusterRank = 3, as (newRank==-1) newRank = 3
loop2 : newRank = 3, trusterRank = 4, as !(3 > 4) newRank stays at 3
loop3 : newRank = 3, trusterRank = 1, as (3 > 1) newRank = 1
loop4 : newRank = 1, trusterRank = 2, as !(1 > 2) newRank stays at 1

At the end of he loop, newRank is incremented to 2. We get a value of 2,
which is what we want.

Maybe my code isn't clear, but the fact is that it works...

Maybe this would be more human-readable ?

if(newRank == -1 || trusterScore.getRank()) < newRank)
        newRank = trusterScore.getRank();
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFImINemY5qNqKdYw0RAqmEAKCkE472aiI31t6DyE9/yVainhAo7QCdHjNa
UCb8SYfwgm9E5jOR67zMhaI=
=/2wf
-----END PGP SIGNATURE-----

Reply via email to