MCPcopy Create free account
hub / github.com/Astropulse/hexmap / build_numbers

Function build_numbers

map.py:1025–1048  ·  view source on GitHub ↗

Numbers grid rules: - Tiles in NON_RESOURCE_TILES get number 0, except: - Exactly one (and only one) 7 exists, placed on a tile inside the largest connected sand/dunes region. - All other tiles use Catan dice probabilities excluding 7.

(cfg: Config, tilemap: np.ndarray)

Source from the content-addressed store, hash-verified

1023
1024
1025def build_numbers(cfg: Config, tilemap: np.ndarray) -> np.ndarray:
1026 """
1027 Numbers grid rules:
1028 - Tiles in NON_RESOURCE_TILES get number 0, except:
1029 - Exactly one (and only one) 7 exists, placed on a tile inside the largest connected sand/dunes region.
1030 - All other tiles use Catan dice probabilities excluding 7.
1031 """
1032 nums = np.zeros((cfg.rows, cfg.cols), dtype=np.int16)
1033
1034 seven_rc = _pick_single_desert_seven(cfg, tilemap)
1035
1036 for r in range(cfg.rows):
1037 for c in range(cfg.cols):
1038 t = str(tilemap[r, c])
1039 if seven_rc is not None and (r, c) == seven_rc:
1040 nums[r, c] = 7
1041 continue
1042
1043 if t in NON_RESOURCE_TILES:
1044 nums[r, c] = 0
1045 else:
1046 nums[r, c] = _sample_catan_number_no7(cfg, r, c)
1047
1048 return nums
1049
1050
1051def save_map_json(cfg: Config, tilemap: np.ndarray, dy: np.ndarray, numbers: np.ndarray, path: str) -> None:

Callers 1

mainFunction · 0.85

Calls 2

_sample_catan_number_no7Function · 0.85

Tested by

no test coverage detected