Skip to content

Commit b1793a3

Browse files
committed
update script
1 parent 0c123e3 commit b1793a3

File tree

1 file changed

+70
-30
lines changed

1 file changed

+70
-30
lines changed

scripts/analyze_hammer_suggestions.py

Lines changed: 70 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@
2626
tactics at each location, both with and without the +suggestions flag.
2727
2828
Output includes:
29-
- Count of locations solvable by each subset of enabled tactics
29+
- Three categories based on +suggestions impact:
30+
* Regressions: worked without +suggestions but failed with +suggestions
31+
* Improvements: failed without +suggestions but worked with +suggestions
32+
* Neutral: same result with/without +suggestions
33+
- For each category, a binary table showing tactic combinations
3034
- Grid format showing binary patterns (1=tactic works, 0=doesn't)
31-
- Separate tables for base tactics and +suggestions variants
3235
3336
Normalization:
3437
- Removes 'try ' prefix from tactics
@@ -141,25 +144,6 @@ def print_table(counts, tactics, title):
141144
# Sort subsets by binary representation for consistent display
142145
all_subsets.sort(key=lambda s: format_subset(s, tactics), reverse=True)
143146

144-
# Print header
145-
print(f"\n{'Subset':<40} {'Count':>8}")
146-
print("-" * 50)
147-
148-
total = 0
149-
for subset in all_subsets:
150-
count = counts.get(subset, 0)
151-
total += count
152-
if count > 0 or subset == frozenset(): # Show zero count for empty set
153-
subset_str = '{' + ', '.join(sorted(subset)) + '}' if subset else '{}'
154-
print(f"{subset_str:<40} {count:>8}")
155-
156-
print("-" * 50)
157-
print(f"{'Total locations':<40} {total:>8}")
158-
159-
# Print grid format
160-
print(f"\n{title} - Grid Format")
161-
print("=" * len(title))
162-
163147
# Create a mapping from binary pattern to count
164148
pattern_counts = {}
165149
for subset in all_subsets:
@@ -186,6 +170,50 @@ def print_table(counts, tactics, title):
186170
print()
187171

188172

173+
def categorize_locations(locations, base_tactics):
174+
"""
175+
Categorize locations into three groups based on +suggestions impact:
176+
- regression: base works but +suggestions doesn't for at least one tactic
177+
- improvement: +suggestions works but base doesn't for at least one tactic (and no regressions)
178+
- neutral: same result for all tactics with/without +suggestions
179+
180+
Returns three dicts mapping location -> frozenset of tactics that worked.
181+
"""
182+
regression_locs = {}
183+
improvement_locs = {}
184+
neutral_locs = {}
185+
186+
for location, suggestions in locations.items():
187+
has_regression = False
188+
has_improvement = False
189+
190+
base_working = set()
191+
sugg_working = set()
192+
193+
for tactic in base_tactics:
194+
base_works = tactic in suggestions
195+
sugg_works = f'{tactic} +suggestions' in suggestions
196+
197+
if base_works:
198+
base_working.add(tactic)
199+
if sugg_works:
200+
sugg_working.add(f'{tactic} +suggestions')
201+
202+
if base_works and not sugg_works:
203+
has_regression = True
204+
if sugg_works and not base_works:
205+
has_improvement = True
206+
207+
if has_regression:
208+
regression_locs[location] = frozenset(base_working)
209+
elif has_improvement:
210+
improvement_locs[location] = frozenset(sugg_working)
211+
else:
212+
neutral_locs[location] = frozenset(base_working)
213+
214+
return regression_locs, improvement_locs, neutral_locs
215+
216+
189217
def output_analysis(locations, enabled_tactics):
190218
"""Output analysis tables."""
191219
print(f"Found {len(locations)} unique locations with suggestions")
@@ -199,18 +227,30 @@ def output_analysis(locations, enabled_tactics):
199227

200228
print(f"\nAnalyzing tactics: {', '.join(base_tactics)}")
201229

202-
# Tactics with +suggestions
230+
# Categorize locations
231+
regression_locs, improvement_locs, neutral_locs = categorize_locations(locations, base_tactics)
232+
233+
print(f"\nRegressions: {len(regression_locs)} locations")
234+
print(f"Improvements: {len(improvement_locs)} locations")
235+
print(f"Neutral: {len(neutral_locs)} locations")
236+
237+
# Create +suggestions tactic names for display
203238
suggestions_tactics = [f'{t} +suggestions' for t in base_tactics]
204239

205-
# Analyze base tactics
206-
base_support = check_tactic_support(locations, base_tactics)
207-
base_counts = count_subsets(base_support)
208-
print_table(base_counts, base_tactics, "Counts without +suggestions")
240+
# Print regression table (base tactics that worked)
241+
if regression_locs:
242+
regression_counts = count_subsets(regression_locs)
243+
print_table(regression_counts, base_tactics, "REGRESSIONS (worked without +suggestions, failed with +suggestions)")
244+
245+
# Print improvement table (+suggestions tactics that worked)
246+
if improvement_locs:
247+
improvement_counts = count_subsets(improvement_locs)
248+
print_table(improvement_counts, suggestions_tactics, "IMPROVEMENTS (failed without +suggestions, worked with +suggestions)")
209249

210-
# Analyze +suggestions tactics
211-
sugg_support = check_tactic_support(locations, suggestions_tactics)
212-
sugg_counts = count_subsets(sugg_support)
213-
print_table(sugg_counts, suggestions_tactics, "Counts with +suggestions")
250+
# Print neutral table (base tactics, since same as +suggestions)
251+
if neutral_locs:
252+
neutral_counts = count_subsets(neutral_locs)
253+
print_table(neutral_counts, base_tactics, "NEUTRAL (same result with/without +suggestions)")
214254

215255

216256
def main():

0 commit comments

Comments
 (0)