Add a penalty when getting on and off a train
This commit is contained in:
parent
f1868aba04
commit
9786182cd3
@ -180,10 +180,7 @@ dijkstra_cost dijkstra_get_weight_from_distance(struct dijkstra_node *node_a,
|
||||
|
||||
switch (net_type) {
|
||||
case TRAINLINE:
|
||||
scale = 5.0;
|
||||
break;
|
||||
case ACCESS:
|
||||
scale = 0.5;
|
||||
scale = 8.0;
|
||||
break;
|
||||
default:
|
||||
scale = 1.0;
|
||||
|
@ -112,6 +112,11 @@ struct dijkstra_node *dijkstra_search_process_queue(struct dijkstra_search *sear
|
||||
for (l = node->paths; l != NULL; l = l->next) {
|
||||
path = (struct dijkstra_path*) l->data;
|
||||
cost = state->cost + path->weight;
|
||||
if (state->cheapest_path && path->net_meta->type == ACCESS) { // If we just jumped onto an access path
|
||||
if (state->cheapest_path->net_meta->type != ACCESS) {// and we came from a non-access path (getting on or off)
|
||||
cost += (DIJKSTRA_ACCESS_PENALTY * 100.0); // add a penalty
|
||||
}
|
||||
}
|
||||
|
||||
connection = dijkstra_node_get_connection(node, path);
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
#define DIJKSTRA_SEARCH_MAX_ITERATIONS 5000
|
||||
|
||||
#define DIJKSTRA_ACCESS_PENALTY 300.0
|
||||
|
||||
struct dijkstra_state {
|
||||
struct dijkstra_path *cheapest_path;
|
||||
dijkstra_cost cost;
|
||||
|
Loading…
Reference in New Issue
Block a user