On Tuesday 05 August 2008 17:44, Julien Cornuwel wrote:
> 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...
Doh indeed.
>
> Maybe this would be more human-readable ?
>
> if(newRank == -1 || trusterScore.getRank()) < newRank)
> newRank = trusterScore.getRank();
Probably.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20080805/163c148d/attachment.pgp>