Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Hypothesis tests for TradeCodes #71

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
26fd6b4
Add hypothesis to requirements
CyberiaResurrection Oct 10, 2023
1d2d561
Bump ruff requirement
CyberiaResurrection Nov 9, 2023
9f95c06
Fix ruff complaints in Calculation folder
CyberiaResurrection Nov 9, 2023
59a1a16
Empty-guard allegiance reduction
CyberiaResurrection Nov 11, 2023
16e0ce0
Fix ruff complaints in root folder
CyberiaResurrection Nov 9, 2023
4a1112b
Add initial hypothesis test for TradeCodes
CyberiaResurrection Oct 21, 2023
3ef2f71
Extend tradeCodes hypothesis check to round-trips
CyberiaResurrection Oct 21, 2023
f8b4d60
Add common-use allowed trade pairs
CyberiaResurrection Oct 23, 2023
cb57afb
Stich together split homeworld codes when creating TradeCode object
CyberiaResurrection Oct 23, 2023
f255237
Add remaining common-use trade code pair
CyberiaResurrection Oct 23, 2023
27cc8bd
Handle homeworlds with unknown populations
CyberiaResurrection Nov 1, 2023
68c91b3
Assorted trade-code fixes and blast damage fixen
CyberiaResurrection Nov 10, 2023
7cfa3e9
Enforce no trade-code duplication
CyberiaResurrection Nov 10, 2023
2e9f42b
Add accumulated bunch of previously-problematic trade codes
CyberiaResurrection Nov 10, 2023
d969bf9
Unpack compact Chirper/Droyne trade codes
CyberiaResurrection Nov 10, 2023
34d45d7
Explain ok_pairs rationale
CyberiaResurrection Nov 10, 2023
0bf6f10
Update allowed residuals
CyberiaResurrection Nov 10, 2023
0057594
Fix more test blowups
CyberiaResurrection Nov 10, 2023
8022215
Trim malformed trade codes when parsing starlines
CyberiaResurrection Nov 11, 2023
27276da
Move malformed code trimming inside TradeCode ctor
CyberiaResurrection Nov 11, 2023
86e5f82
Add unicode char for RS Omega
CyberiaResurrection Nov 11, 2023
a44abf7
Sort codes before rebuilding initial_codes string
CyberiaResurrection Nov 11, 2023
21f6d92
Unpack homeworlds in stat calculation
CyberiaResurrection Nov 11, 2023
656d3b6
Compile homeworld-match regex
CyberiaResurrection Nov 12, 2023
cc82a16
Compile sophont-list and dieback-world regexen
CyberiaResurrection Nov 12, 2023
d44e72c
Start enforcing strict Trav5 sophont codes
CyberiaResurrection Nov 13, 2023
c9a5840
Wring out sophont and homeworld list generation
CyberiaResurrection Nov 13, 2023
492eb26
Exclude new-type sophont codes from invalid-pair checks
CyberiaResurrection Nov 13, 2023
f423a0b
Start verifying major-race homeworlds
CyberiaResurrection Nov 14, 2023
5fb7f98
Handle explicit populations for major race homeworlds
CyberiaResurrection Nov 14, 2023
4629990
Verify major races can share homeworlds
CyberiaResurrection Nov 14, 2023
ed93f5c
Explicitly reject multiple W-pop sophont codes
CyberiaResurrection Nov 14, 2023
40d1e67
Fix test blast damage
CyberiaResurrection Nov 14, 2023
2886f6e
Drop dead code
CyberiaResurrection Nov 14, 2023
6efdc20
Handle <4-char codes in StatCalculation
CyberiaResurrection Nov 14, 2023
4b7fe40
Add stub total-checks
CyberiaResurrection Nov 14, 2023
12bb779
Dodge homeworld-importance jam-ups in star lines
CyberiaResurrection Nov 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions PyRoute/Calculation/RouteCalculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,21 @@ def unilateral_filter(self, star):
@return: Whether the star can be unilaterally filtered
"""
return False

def is_sector_trade_balanced(self):
pass

def is_sector_pass_balanced(self):
pass

def is_allegiance_trade_balanced(self):
pass

def is_allegiance_pass_balanced(self):
pass

def multilateral_balance_trade(self):
pass

def multilateral_balance_pass(self):
pass
2 changes: 1 addition & 1 deletion PyRoute/Calculation/TradeCalculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def get_trade_between(self, star, target):
"This route from " + str(star) + " to " + str(target) + " has already been processed in reverse"

try:
rawroute, diag = astar_path_indexes(self.galaxy.stars, star.index, target.index, self.galaxy.heuristic_distance_indexes)
rawroute, _ = astar_path_indexes(self.galaxy.stars, star.index, target.index, self.galaxy.heuristic_distance_indexes)
except nx.NetworkXNoPath:
return

Expand Down
8 changes: 4 additions & 4 deletions PyRoute/Calculation/TradeMPCalculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def intrasector_process(working_queue, processed_queue):
continue

try:
rawroute, diag = astar_path_indexes(tradeCalculation.galaxy.stars, star.index, neighbor.index,
rawroute, _ = astar_path_indexes(tradeCalculation.galaxy.stars, star.index, neighbor.index,
tradeCalculation.galaxy.heuristic_distance_indexes)
except nx.NetworkXNoPath:
continue
Expand Down Expand Up @@ -82,7 +82,7 @@ def long_route_process(working_queue, processed_queue):
break

try:
route, diag = astar_path_indexes(tradeCalculation.galaxy.stars, star, neighbor,
route, _ = astar_path_indexes(tradeCalculation.galaxy.stars, star, neighbor,
tradeCalculation.galaxy.heuristic_distance_indexes)
except nx.NetworkXNoPath:
continue
Expand Down Expand Up @@ -153,7 +153,7 @@ def calculate_routes(self):

# This is the multiprocess method, which contains all the logic for using multi-process in the parent (core) process
# When this is completed, all the child process should be completed.
def start_mp_services (self):
def start_mp_services(self):
global tradeCalculation
tradeCalculation = self

Expand Down Expand Up @@ -281,7 +281,7 @@ def get_trade_between(self, star, target):
f"This route from {star} to {target} has already been processed in reverse"

try:
rawroute, diag = astar_path_indexes(self.galaxy.stars, star.index, target.index, self.galaxy.heuristic_distance_indexes)
rawroute, _ = astar_path_indexes(self.galaxy.stars, star.index, target.index, self.galaxy.heuristic_distance_indexes)
except nx.NetworkXNoPath:
return

Expand Down
2 changes: 1 addition & 1 deletion PyRoute/DeltaDebug/DeltaReduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def is_initial_state_interesting(self):
sectors = self.sectors
args = self.args

interesting, msg, _ = self._check_interesting(args, sectors)
interesting, _, _ = self._check_interesting(args, sectors)

if not interesting:
raise AssertionError("Original input not interesting - aborting")
Expand Down
4 changes: 4 additions & 0 deletions PyRoute/DeltaPasses/AllegianceReducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def run(self, singleton_only=False):
continue

temp_sectors = best_sectors.allegiance_subset(raw_lines)
temp_lines = len(temp_sectors.lines)
if 0 == temp_lines:
# nothing to do, move on
continue

interesting, msg, _ = self.reducer._check_interesting(self.reducer.args, temp_sectors)
# We've found a chunk of input and have _demonstrated_ its irrelevance,
Expand Down
7 changes: 5 additions & 2 deletions PyRoute/StatCalculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,19 +228,22 @@ def add_alg_stats(self, area, star, alg):
self.max_tl(algStats, star)

def add_pop_to_sophont(self, stats, star):

total_pct = 100
default_soph = 'Huma'
home = None
for sophont in star.tradeCode.sophonts:
soph_code = sophont[0:4]
soph_pct = sophont[4:]

if 4 == len(sophont):
soph_code = sophont[0:3]
soph_pct = sophont[3:]

if soph_pct == 'A':
default_soph = soph_code
continue

soph_pct = 100.0 if soph_pct == 'W' else 0.0 if soph_pct in ['X', 'A'] else \
soph_pct = 100.0 if soph_pct == 'W' else 0.0 if soph_pct in ['X', 'A', '?'] else \
5.0 if soph_pct == '0' else 10.0 * int(soph_pct)

if any([soph for soph in star.tradeCode.homeworld if soph.startswith(soph_code)]):
Expand Down
Loading