-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroughness.py
More file actions
27 lines (23 loc) · 1.45 KB
/
Copy pathroughness.py
File metadata and controls
27 lines (23 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import numpy as np
from ..arrays.continents import continents_logic_types
from ..arrays.logic_type import get_adjacent_logic_types
logic_types_roughness = {0: 0, 1: 1, 2: 2, 3: 4, 4: 3, 5: 0, 6: 0, 7: 5, 8: 3, 9: 3, 10: 1}
def data_to_lmpr(data_object):
# There exist three original maps on which this algorithm does not produce exactly the same output as the section
# included in the game files. Those are "The swords of the kings" and "Trophy hunt" in the game "Northland" and
# "Servant of the oracle" in the game "8th Wonder of the World". These discrepancies are considered negligible.
lmpr = np.zeros(shape=data_object.lsiz.shape_micro, dtype=np.uint8)
for y in range(2 * data_object.lsiz.height):
for x in range(2 * data_object.lsiz.width):
continent_type = data_object.laco[data_object.lmco[y, x]].type
if continent_type == 0: continue
elif continent_type == 2 or data_object.lmro[y, x] == 1: lmpr[y, x] = 1
else:
roughness_values = [logic_types_roughness[logic_type] for logic_type
in get_adjacent_logic_types(data_object, (x, y))
if logic_type in continents_logic_types[1]]
lmpr[y, x] = sum(roughness_values) // len(roughness_values)
return lmpr
def update_lmpr(data_object):
data_object.lmpr = data_to_lmpr(data_object)
return data_object