﻿id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,phab_field
6422,Often no passable path on unknown map with 2 players,Langbart,,"A problem was noticed by `rollieoo` on a certain map, both opponents cannot reach each other.
* Forum: [https://wildfiregames.com/forum/topic/68685-two-halves-map/ Two halves map] (21/Jan/22)
==== to reproduce
* Set up a game
  * Player: 2
  * Maptype: Random
  * Map: Unknown
  * Landscape: Passes
* try to get your units across the mountain, often this won't work
[[Image(unknown_passes.jpg, 600px, center)]]

example: 

{{{
~/0ad/binaries/system/pyrogenesis -conf=mod.enabledmods:""mod public"" -quickstart -autostart=""random/unknown"" -autostart-seed=1563851758  -autostart-size=256 -autostart-player=-1
}}}


==== bisect
* It was not possible for me to find the changeset number.
* In a quick test in A24b, the mountain was overcomeable, but if you try a few times, the problem could also occur there.
* The problem also occurs in A23b.

==== solution (1)
A simple solution would be to adjust the map creation for 2 players `|| numPlayers == 2` so that there is always a lake in between.
[[Image(unknown_passes_lake.jpg, 600px, center)]]

[https://code.wildfiregames.com/source/0ad/browse/ps/trunk/binaries/data/mods/public/maps/random/unknown.js$656 Line 656] in Unknown.js 

{{{
#!js lineno=656
	if (randBool(2/5) *|| numPlayers == 2*)
	{
		g_Map.log(""Create central lake"");
		createArea(
			new ClumpPlacer(diskArea(fractionToTiles(0.1)), 0.7, 0.1, Infinity, mapCenter),
			[
				new SmoothElevationPainter(ELEVATION_SET, waterHeight, 3),
				new TileClassPainter(clWater)
			]);
	}
}}}

==== input from elexis (22/Jan/22)
{{{
[08:52:57] Langbart Hello, do you think the solution is good enough for https://trac.wildfiregames.com/ticket/6422 ?
[...]
[10:34:17] elexis making a lake is certainly a possibility but it changes the map gameplay a lot
[...]
[10:44:32] elexis so I guess either the placer isnt returning an area or the painter isnt doing something to it
[10:45:24] elexis same with the ""Fill area between the paths"" part, also Im not sure why that one paints clWater there when there isnt any water, probably to have nothing else placed there, but thats often asking for bugs like fish on land
[10:45:57] elexis better would be to add a specific class clPassage and have all the remaining statements make sure not to place on clPassage (water and land alike), but (probably) unrelated
[...]
[10:49:12] elexis could also be that the passage is too small on the given mapsize or something
[10:49:27] elexis yeah that looks like it
[...]
[10:55:53] elexis but its probably a wrong parameter in the mapscript rather than a rmgen library bug, judging by the screenshot
}}}

==== solution (2)
Replace `diskArea(fractionToTiles(0.05))` with `0`.
[https://github.com/0ad/0ad/blob/4f7d3f1f4dcef5d9b0f40dafd073857b8d30afb2/binaries/data/mods/public/maps/random/unknown.js#L666 Line 666] in Unknown.js 

{{{
#!js lineno=666
	else
	{
		g_Map.log(""Fill area between the paths"");
		createArea(
			new ClumpPlacer(*0*, 0.7, 0.1, Infinity, mapCenter),
			[
				new SmoothElevationPainter(ELEVATION_SET, heightMountain, 4),
				new TileClassPainter(clWater)
			]);
	}
}}}

[[Image(diskArea.jpg, 600px, center)]]
",defect,new,Should Have,Alpha 26,Maps,,,,
