Another attempt to correct resource placement discoloration

This commit is contained in:
Marcus Str. 2024-12-24 09:05:27 +01:00
parent 59cae087a4
commit c2d4915114

View File

@ -229,6 +229,11 @@ class mstr_tileprep:
textfile.write(newline)
# Find neighborinf tiles
def _findNeighbors(self, tv, th):
return [ (tv+1, th), (tv, th+1), (tv-1, th), (tv, th-1) ]
# Walk through the now existing data files and make sure we always pick the correct
# sources for every tile, thus evading previous edge detection errors
def _placeTileSources(self, mlat, mlng):
@ -237,7 +242,7 @@ class mstr_tileprep:
edge_end = [0,0,0,0] # top, right, bottom, left
# Array with info we need
resinfo = ["", ""] # Touch, Resource numbers, contrast
resinfo = ["", ""] # Touch, Resource numbers
# Go through everything until the end is reached (no more options left)
end_reached = False
@ -251,17 +256,29 @@ class mstr_tileprep:
resinfo[0] = self._getResourceTouch(tv, th)
resinfo[1] = self._getResourceInfo(tv, th)
# Only do the following steps if we have nothing stored
if resinfo[1] == "0":
self._storeResourceInfo(tv, th, self._selectResources())
resinfo[1] = self._getResourceInfo(tv, th)
neighbors = self._findNeighbors(tv, th)
neighborinfo = ["",""]
for n in range(0, len(neighbors)):
neighborinfo[0] = self._getResourceTouch(neighbors[n][0], neighbors[n][1])
neighborinfo[1] = self._getResourceInfo(neighbors[n][0], neighbors[n][1])
if "b" in neighborinfo[0] and neighborinfo[1] != "0":
resinfo[1] = neighborinfo[1]
break
# Store info. At this point we either have neighboring data, or
# we need to select something
if resinfo[1] == "0": resinfo[1] = self._selectResources()
self._storeResourceInfo(tv, th, resinfo[1])
# Move forward
if "t" in resinfo[0]:
tv=tv+1
rinfo = self._getResourceInfo(tv, th)
if rinfo == "0": self._storeResourceInfo(tv, th, resinfo[1])
else:
edge_end[0] = 1
# Go east
tv = self._tile_v
th = self._tile_h
@ -270,17 +287,29 @@ class mstr_tileprep:
resinfo[0] = self._getResourceTouch(tv, th)
resinfo[1] = self._getResourceInfo(tv, th)
# Only do the following steps if we have nothing stored
if resinfo[1] == "0":
self._storeResourceInfo(tv, th, self._selectResources())
resinfo[1] = self._getResourceInfo(tv, th)
neighbors = self._findNeighbors(tv, th)
neighborinfo = ["",""]
for n in range(0, len(neighbors)):
neighborinfo[0] = self._getResourceTouch(neighbors[n][0], neighbors[n][1])
neighborinfo[1] = self._getResourceInfo(neighbors[n][0], neighbors[n][1])
if "l" in neighborinfo[0] and neighborinfo[1] != "0":
resinfo[1] = neighborinfo[1]
break
# Store info. At this point we either have neighboring data, or
# we need to select something
if resinfo[1] == "0": resinfo[1] = self._selectResources()
self._storeResourceInfo(tv, th, resinfo[1])
# Move forward
if "r" in resinfo[0]:
th=th+1
rinfo = self._getResourceInfo(tv, th)
if rinfo == "0": self._storeResourceInfo(tv, th, resinfo[1])
else:
edge_end[1] = 1
# Go south
tv = self._tile_v
th = self._tile_h
@ -289,17 +318,29 @@ class mstr_tileprep:
resinfo[0] = self._getResourceTouch(tv, th)
resinfo[1] = self._getResourceInfo(tv, th)
# Only do the following steps if we have nothing stored
if resinfo[1] == "0":
self._storeResourceInfo(tv, th, self._selectResources())
resinfo[1] = self._getResourceInfo(tv, th)
neighbors = self._findNeighbors(tv, th)
neighborinfo = ["",""]
for n in range(0, len(neighbors)):
neighborinfo[0] = self._getResourceTouch(neighbors[n][0], neighbors[n][1])
neighborinfo[1] = self._getResourceInfo(neighbors[n][0], neighbors[n][1])
if "t" in neighborinfo[0] and neighborinfo[1] != "0":
resinfo[1] = neighborinfo[1]
break
# Store info. At this point we either have neighboring data, or
# we need to select something
if resinfo[1] == "0": resinfo[1] = self._selectResources()
self._storeResourceInfo(tv, th, resinfo[1])
# Move forward
if "b" in resinfo[0]:
tv=tv-1
rinfo = self._getResourceInfo(tv, th)
if rinfo == "0": self._storeResourceInfo(tv, th, resinfo[1])
else:
edge_end[2] = 1
# Go west
tv = self._tile_v
th = self._tile_h
@ -308,14 +349,25 @@ class mstr_tileprep:
resinfo[0] = self._getResourceTouch(tv, th)
resinfo[1] = self._getResourceInfo(tv, th)
# Only do the following steps if we have nothing stored
if resinfo[1] == "0":
self._storeResourceInfo(tv, th, self._selectResources())
resinfo[1] = self._getResourceInfo(tv, th)
neighbors = self._findNeighbors(tv, th)
neighborinfo = ["",""]
for n in range(0, len(neighbors)):
neighborinfo[0] = self._getResourceTouch(neighbors[n][0], neighbors[n][1])
neighborinfo[1] = self._getResourceInfo(neighbors[n][0], neighbors[n][1])
if "r" in neighborinfo[0] and neighborinfo[1] != "0":
resinfo[1] = neighborinfo[1]
break
# Store info. At this point we either have neighboring data, or
# we need to select something
if resinfo[1] == "0": resinfo[1] = self._selectResources()
self._storeResourceInfo(tv, th, resinfo[1])
# Move forward
if "l" in resinfo[0]:
th=th-1
rinfo = self._getResourceInfo(tv, th)
if rinfo == "0": self._storeResourceInfo(tv, th, resinfo[1])
else:
edge_end[3] = 1