Closed a5sk4s closed 9 years ago
That's interesting, if so then a _safe fix is in order.
Could you be a little more specific about the case you are looking at?
For a 5 player double elimination I can rescore the match that send a player down
to a WO match in LB fine. Otherwise, if right
is a WO match, then so is the current one so you cannot rescore it anyway. Unless I am missing something.
This was my manual test with a 5 player tournament:
d = new Duel(5, { last: Duel.LB });
d.score({ s: 1, r: 1, m: 2 }, [0,1]);
d.unscorable({ s: 1, r: 1, m: 2 }, [1,0]);
'S1 R1 M2 cannot be re-scored'
m = d.findMatch({ s: 1, r: 1, m: 2 });
d._safe(m)
false
This is the relevant part of the loser bracket before
{ id: { s: 2, r: 1, m: 1 },
p: [ -1, 0 ],
m: [ 0, 1 ] },
{ id: { s: 2, r: 1, m: 2 },
p: [ -1, -1 ],
m: [ 0, 1 ] },
{ id: { s: 2, r: 2, m: 1 },
p: [ 0, 0 ] },
{ id: { s: 2, r: 2, m: 2 },
p: [ -1, 0 ] },
and after the d.score({ s: 1, r: 1, m: 2 }, [0,1]);
call
{ id: { s: 2, r: 1, m: 1 },
p: [ -1, 5 ],
m: [ 0, 1 ] },
{ id: { s: 2, r: 1, m: 2 },
p: [ -1, -1 ],
m: [ 0, 1 ] },
{ id: { s: 2, r: 2, m: 1 },
p: [ 0, 5 ] },
{ id: { s: 2, r: 2, m: 2 },
p: [ -1, 0 ] },
I think the fact that match { s: 2, r: 1, m: 1 }
is a walkover match interferes with the re-scoring.
Please let me know if I can help in any other way.
Oh yeah, I see now. This is a nice find.
Since .score
will change both LBR1M1 and LBR2M1 correctly so it's only an unscorable problem with the new fine grained access control in the _safe virtual. We want to ensure that the LBR2M1 match is not already scored before we blindly allow re-scoring WBR1M2.
Technically it is impossible for the relevant LBR2 match to be scored without also the WBR2 match right
of the one we are re-scoring in WBR1 to also be scored. Unfortunately, a similar argument does not hold if you drop on top of a WO marker in LBR2 from WBR2 (then you can have played LBR3 match without WBR3 being touched). Thus, no short-cuts can be really be made; _safe must always check [right
, down
, down ∘ right
] are all unplayed when exists (similar to how _progress does it).
I'll make a fix for this soon. Have written up a test for the cases discussed. Thanks for reporting this :+1:
Fixed in duel@3.0.1
Thanks again :]
Your welcome. It's been my pleasure. Thanks for the quick turnaround.
the recent enhancement to allow rescoring under certain conditions (see: https://github.com/clux/tournament/issues/20) fails if either left or down is a walkover game - the down case can occur in the first round of double elimination tournaments
is it sufficient fix the criteria in the _safe routine for the walkover games, by looking one level deeper?