Skip to content

Commit a41bed9

Browse files
authored
Merge pull request #190 from jxd136/dev
smooth is not good
2 parents 4386298 + 9f7db73 commit a41bed9

2 files changed

Lines changed: 9 additions & 12 deletions

File tree

logic/pve/GameLogic/board.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,15 @@ def manhattan(self, x1: int, y1: int, x2: int, y2: int) -> int:
194194
return abs(x1 - x2) + abs(y1 - y2)
195195

196196
def nearest_market(self, x: int, y: int) -> Optional[Tuple[int, int]]:
197-
"""Return (mx, my) of market with Manhattan distance ≤ 1, or None."""
197+
"""Return nearest market within Manhattan distance ≤ 1, or None."""
198+
best = None
199+
best_dist = 9999
198200
for mx, my in self.market_positions:
199-
if self.manhattan(x, y, mx, my) <= 1:
200-
return (mx, my)
201-
return None
201+
d = self.manhattan(x, y, mx, my)
202+
if d <= 1 and d < best_dist:
203+
best = (mx, my)
204+
best_dist = d
205+
return best
202206

203207
def nearest_resource(self, x: int, y: int) -> Optional[ResourcePoint]:
204208
"""Return nearest non-depleted resource within harvest range (≤ 2)."""

logic/pve/official_evaluator.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import argparse
3131
import importlib
3232
import json
33-
import math
3433
import os
3534
import sys
3635
from pathlib import Path
@@ -47,11 +46,6 @@
4746
from RLInterfaces import BaseAgent
4847

4948

50-
def _smooth_score(score: float, scale: float = 1000.0) -> float:
51-
"""Bounded score smoothing using tanh followed by sigmoid."""
52-
z = math.tanh(score / scale)
53-
return 1.0 / (1.0 + math.exp(-z))
54-
5549
def load_agent(submission_dir: str, model_path: Optional[str], env: GameEnvironment) -> BaseAgent:
5650
"""
5751
Dynamically load contestant's Agent class from submission_dir/agent.py.
@@ -129,8 +123,7 @@ def evaluate(
129123
action = agent.get_action(obs)
130124
obs, _reward, terminated, truncated, info = env.step(action)
131125
ep_len += 1
132-
raw_score = info.get("score", 0.0)
133-
ep_score = _smooth_score(raw_score)
126+
ep_score = info.get("score", 0.0)
134127
done = terminated or truncated
135128

136129
scores.append(ep_score)

0 commit comments

Comments
 (0)