Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1830 route tracing failure #221

Open
slapphappyjazz opened this issue May 17, 2020 · 17 comments
Open

1830 route tracing failure #221

slapphappyjazz opened this issue May 17, 2020 · 17 comments
Assignees
Labels
Milestone

Comments

@slapphappyjazz
Copy link

We encountered a bug playing 1830 on rails2.1beta1, in which the route tracing algorithm failed to trace a route through two separate paths across an number 43 tile. See hex D8 in the final position on the attached screenshot.
Screenshot 2020-05-16 18 29 16
The Erie should be able to trace a route from its home city, around the tight curve on D8, up to B16 and back around the top, through the straight on D8 to E7 and beyond. Rails failed to find this and all the track placed beyond that point was done by map correction (and entering the income for the Erie by hand).
I attach the game file from the end of the game (which doesn't load properly, possibly because we engaged correction mode).
1830_20200516_1727_EndOfGameRound_.zip

@neutronc
Copy link
Contributor

My first guess is that tile #43 has a bug in its tile definition.

@neutronc
Copy link
Contributor

Found the problem but dont know why it happening:
NetworkIterator is crawling over the vertexes in the vertex list the Verex exists but the iterator refuses to follow it. NetworkIterator.next() line 114 in NetworkIterator.java if you load and set a breakpoint there it should bring you in debug mode to that function with all vertices for the provided save game.
Load the game in Debug Mode let it run, use the game history to go back to the previous turn, set the breakpoint in the NetworkIterator or in NetworkGraph.Java at line 373 thats where the iterator is starting. If you have a look at the Graph before you will find the edge vertice D8.SW->E7.NE thats where the route calculation fails...
My Brain is now fuzzed for tonight maybe someone else has more luck.

@neutronc neutronc added the bug label May 18, 2020
@neutronc neutronc added this to the Rails 2.2 milestone May 18, 2020
@jklap
Copy link
Contributor

jklap commented May 19, 2020

If you delete action 747 and then 779 the file will load cleanly

@jklap
Copy link
Contributor

jklap commented May 19, 2020

It also looks like there are two routes that could be taken with the same end revenue..

  • ... E9 -> D8 -> D10 -> ... B16 ... B10 -> C9 -> D8 -> E7 ...
  • ... E9 -> D8 -> C9 -> B10 ... B16 .. D10 -> D8 -> E7 ...

Pretty sure this is the root of the issue.

When the path is built coming in via D8.SE, we add both D8.NE and D8.E and continue to trace D8.E which eventually leads us back to D8.NE. But when we look at the path from D8.NE to D8.SW we ignore it as D8.NE is marked as greedy and D8.SW is not. So this logic then fails to add D8.SW in addUnseenChildrenOf:

if (!greedy || edge.isGreedy()) {
    NetworkVertex oppositeV = Graphs.getOppositeVertex(graph, edge, vertex);
    log.debug("Iterator: Neighbor is {}", oppositeV);
    encounterVertex(oppositeV, edge);
}

@neutronc
Copy link
Contributor

neutronc commented May 19, 2020

ok and how can we fix that ? :)
I do understand that the revenue path is correct but the route path used to allow laying tiles should show the alternative path as possible as well

@jklap
Copy link
Contributor

jklap commented May 19, 2020

Haven't spent any time looking at the code except for the hour or so last night so I don't have the full context of how it's currently implemented and am (very) likely missing detail.

But I wonder if it can only be fixed by separating the list of possible paths and tracking them only from the location they are accessible from. As the routes from an edge are determined they are added to a "global" list. The "global" list right now is what I think is causing the issue. I've never worked on network graphs before so caveat ;)

I highly suspect resolving this issue is not going to be a minor effort as it seems it is an issue with the overall fundamental logic?

I don't think the revenue path is correct -- at the end of the game it's only showing a run terminating at A11 when in fact it should run through to F2

Current code:
Screen Shot 2020-05-19 at 7 25 21 AM

My testing (but not usable code hack):

Screen Shot 2020-05-19 at 7 26 22 AM

@erik-vos
Copy link
Contributor

Maybe off-topic here, but I have started to look at 18Scan, and today I have already seen at least two cases where route tracing goes astray. I wonder what has happened with that code in the past years that I haven't participated, because once these things worked fine.
(I have never worked with the routing code, so I can't help at this time).
BTW I have checked tile 43 and it looks OK.

@jklap
Copy link
Contributor

jklap commented May 19, 2020

@erik-vos can you provide the specifics for those two cases? Whether or not it is the same issue we should look into it also.

@erik-vos
Copy link
Contributor

Sure. Perhaps I can best open a new issue for that?

@jklap
Copy link
Contributor

jklap commented May 19, 2020

Sure

@erik-vos
Copy link
Contributor

This is #229.

@jklap
Copy link
Contributor

jklap commented May 20, 2020

Testing a fix-- impact is an increase search time (due to revisiting some nodes). Need to verify (somehow) it doesn't have an never-ending search scenario.

FYI @slapphappyjazz I hate to be the bearer of bad news but I'm pretty sure your Erie revenue is not $540.....

Pretty sure it's $560 ;)

Screen Shot 2020-05-20 at 5 24 19 PM

@neutronc
Copy link
Contributor

Hi @jklap,
whats the status on the fix ? :) would love to push out a new release.

@neutronc neutronc modified the milestones: Rails 2.2, 2.3 Jun 19, 2020
@jklap
Copy link
Contributor

jklap commented Jun 22, 2020

The change I've been testing seems to work, certainly addresses the problem BUT there are a couple of maps I've tested with with lots of circular paths and it can take a very long time (30 seconds+) to resolve. Been looking at how I can prune the search paths but am still working on understanding the code too

@jklap
Copy link
Contributor

jklap commented Jun 22, 2020

FYI, if someone would like to additional test, it's a single line change- remove the following line from NetworkIterator.encounterVertex():

if (stack.contains(v)) return;

@erik-vos
Copy link
Contributor

Done, but I see no difference with your saved file, trimmed after action 747.

@erik-vos
Copy link
Contributor

erik-vos commented Mar 8, 2024

Looked again, to check if my work on issue #547 (reworking vertex/train specs to eliminate the ignoreMinors stuff) had any effect here. Not so, but I discovered that the problem is fixed by placing an extra token on any city north of Erie, except D10 south.

About greed, see also #478.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants