Gold Rush - Inconsistent ladder results?


#1

Hi.

I’ve been working on the Gold Rush ladder, and my latest submission seems to sometimes show me a loss, but when I review the match, it is a win.

So, I think there’s a component in my code that may be causing this, because I did not see this occur with my older code.

I’m not sure exactly what component might be causing it, but these are some additions I did:

Calculate the cosine of the coin to the enemy’s directional vector. SAMPLE:

var cos = Vector.normalize(Vector.subtract(enemy.pos, items[i].pos)).dot(Vector.normalize(Vector.add(enemy.pos, new Vector(this.enemyVectorX, this.enemyVectorY))));

Although I made a few other changes, they don’t apply anything that I haven’t previously done. The Vector.dot() seems to be the only new thing I introduced.

Link to a reported loss that shows as success when reviewing:

My username is “NoJuice4u”.


#2

Sadly the link seems to be of little value, as for me I got an introduction into the level and some default code.

In general what you did is the compact way. The compact way is, well, compact, but does not facilitate readability.
Maybe there is a part in there which causes floating point problems or something.

However, it has already been reported for other gamemodes that the result you see does not have to correspond with the computed result. It is currently not exactly known why that is, but as the results are cloud-computed a wide-scale cheating seems unlikly (unless someone set up a dozen computers to simulate biased matches, in which I’d leave them be. I mean who got a dozen computers for something like this?).

The only solution I can propose is to try and look at other matches, hoping they show the actual happenings.

Other thread about this:
http://discourse.codecombat.com/t/cavern-survival-optimal-strategy-game-breaking/2002/19?u=j_f_b_m


#3

Ok, I’ll test around changing the way I use the values I get from Vector.dot() and Math.cos(). Maybe there’s some weird interaction where the floating point value is calculated to a different precision depending on whether the simulation is run on the browser versus the headless client.


#4

Don’t know if it’s linked, but I also got strange results with my old code in Greed.
For the ranking, I lost all the matches, but a lot of simulation show me a win.


#5

So, I refactored my code a bit, and my losses now show as losses. Here’s a comparison:

Old Code:

var cos = Vector.normalize(Vector.subtract(enemy.pos, items[i].pos)).dot(Vector.normalize(Vector.add(enemy.pos, new
Vector(this.enemyVectorX, this.enemyVectorY))));
… SKIPPED LINES …
if (cos < 0.8) multiplier = desiredFactor;

New Code(pseudocode):

var isDesired = (Vector.normalize(a).dot(Vector.normalize(b))) < Math.cos(35)
… SKIPPED LINES …
if (isDesired) multiplier = desiredFactor;

The main difference, is that the cosine of 35 is roughly 0.819152044… The old method compared cos against 0.8, and I think the browser rounded my “cos” value differently from the headless client.

My new code was a “wild-ass guess” attempt to try to move the processing to a lower level, where the rounding error might not happen because maybe the problem occurs when it translate the JavaScript to whatever common language that the simulation gets run on.

This new code is giving me more consistent results so far, 2 losses shown, and both losses are still losses when I review the fight. It hasn’t simulated enough for it to be definitive, so I will need to wait a bit to get more result data.


#6

Dunno if its considered bad manners to also post this here, but I opened https://github.com/codecombat/codecombat/issues/2134 which is what appears to be going on. The mysterious losses seem to be real, but not for the match that is reported as lost.


#7

I’m also getting losses that replaying the game gives a win. Is there a way to get a linkable match ID so I can share it?

Also, this is not just restricted to gold rush, it happens often in other arena’s as well.


#8

So, the issue no longer occurs after the refactoring I did. I have no idea how to prove my hypothesis, until I manage to deploy a local version of codecombat to debug further.

I’ve hit some issues building the code base, so I’ll take a crack at building codecombat locally when I have free time.

For those affected by this issue, I suppose you can get around this issue by passing functions into functions until you get the result you want.

You’ll end up with nearly-unreadable code, but I suspect storing a floating point value into a variable has a chance to get rounded off when you pass it to another function.