Muditsharmaaa commited on
Commit
918114d
·
1 Parent(s): 48b62e2

Final Phase 2 Fix

Browse files
Files changed (2) hide show
  1. graders.py +9 -34
  2. openenv.yaml +13 -16
graders.py CHANGED
@@ -1,53 +1,28 @@
1
  from typing import List, Any
2
 
3
- # A trajectory is typically passed as a list of dictionaries containing step data
4
- # e.g., [{"reward": 0.5, "done": False, "info": {"correct_decisions": 2, "total_batch": 3}}, ...]
5
-
6
  def _calculate_base_score(trajectory: List[dict]) -> float:
7
- """Helper function to calculate the average reward across all steps."""
8
  if not trajectory:
9
- return 0.0
10
 
11
  total_reward = sum(step.get("reward", 0.0) for step in trajectory)
12
- max_possible_reward = len(trajectory) * 1.0 # 1.0 is max reward per step
13
 
14
  if max_possible_reward == 0:
15
- return 0.0
16
 
17
  score = total_reward / max_possible_reward
18
- return max(0.0, min(1.0, score)) # Clamp between 0.0 and 1.0
 
19
 
20
  def grade_easy(trajectory: List[dict], env_state: Any = None) -> float:
21
- """
22
- Easy Task: Did the agent manage to get at least a 30% success rate?
23
- This proves it understands the basic JSON schema and can make a 'mint' decision.
24
- """
25
  score = _calculate_base_score(trajectory)
26
- # If they hit 30% efficiency, we give them full marks for the easy task
27
- return 1.0 if score >= 0.3 else (score / 0.3)
28
 
29
  def grade_medium(trajectory: List[dict], env_state: Any = None) -> float:
30
- """
31
- Medium Task: The agent needs to successfully filter out the bad wallets/scores.
32
- Requires at least 60% overall efficiency.
33
- """
34
  score = _calculate_base_score(trajectory)
35
- # Scales up to 1.0 based on hitting the 60% benchmark
36
- if score >= 0.6:
37
- return 1.0
38
- return max(0.0, score)
39
 
40
  def grade_hard(trajectory: List[dict], env_state: Any = None) -> float:
41
- """
42
- Hard Task: Strict grading.
43
- The agent must achieve near perfection (90%+) and not run out of gas
44
- (which would result in a premature 'done' flag with low rewards).
45
- """
46
  score = _calculate_base_score(trajectory)
47
-
48
- # If the episode ended early because they wasted gas on bad mints, penalize heavily
49
- if len(trajectory) < 5 and trajectory[-1].get("reward", 0.0) < 0:
50
- return 0.0
51
-
52
- # Standard raw score, very hard to get 1.0 unless the agent is flawless
53
- return score
 
1
  from typing import List, Any
2
 
 
 
 
3
  def _calculate_base_score(trajectory: List[dict]) -> float:
 
4
  if not trajectory:
5
+ return 0.01
6
 
7
  total_reward = sum(step.get("reward", 0.0) for step in trajectory)
8
+ max_possible_reward = len(trajectory) * 1.0
9
 
10
  if max_possible_reward == 0:
11
+ return 0.01
12
 
13
  score = total_reward / max_possible_reward
14
+ # Clamp between 0.01 and 0.99 to satisfy "strictly between 0 and 1"
15
+ return max(0.01, min(0.99, score))
16
 
17
  def grade_easy(trajectory: List[dict], env_state: Any = None) -> float:
 
 
 
 
18
  score = _calculate_base_score(trajectory)
19
+ # Return 0.95 for success instead of 1.0
20
+ return 0.95 if score >= 0.3 else max(0.01, score)
21
 
22
  def grade_medium(trajectory: List[dict], env_state: Any = None) -> float:
 
 
 
 
23
  score = _calculate_base_score(trajectory)
24
+ return 0.95 if score >= 0.6 else max(0.01, score)
 
 
 
25
 
26
  def grade_hard(trajectory: List[dict], env_state: Any = None) -> float:
 
 
 
 
 
27
  score = _calculate_base_score(trajectory)
28
+ return 0.95 if score >= 0.9 else max(0.01, score)
 
 
 
 
 
 
openenv.yaml CHANGED
@@ -2,24 +2,21 @@ version: "1.0"
2
  name: "blockchain_certificate_admin"
3
  description: "An agent acts as a smart contract administrator, processing student certificates. It must validate scores, check for 42-character 0x wallet addresses, and manage its gas balance to successfully mint."
4
 
5
- # Pointers to the Pydantic models we wrote in Step 2
6
- observation_space: "models:BlockchainObservation"
7
- action_space: "models:BlockchainAction"
8
- reward_space: "models:BlockchainReward"
 
9
 
10
- # Pointer to the core engine we wrote in Step 3
11
- environment: "env:BlockchainEnv"
12
 
13
- # The 3 mandatory tasks ranging from Easy to Hard
14
  tasks:
15
- - name: "easy_mint"
16
- description: "Mint completely valid certificates without making syntax errors."
17
- grader: "graders:grade_easy"
18
 
19
- - name: "medium_filter"
20
- description: "Successfully identify and reject invalid requests (e.g., scores under 70, malformed wallets)."
21
- grader: "graders:grade_medium"
22
 
23
- - name: "hard_gas_management"
24
- description: "Process a full batch of complex requests over multiple steps without running out of gas due to penalizations."
25
- grader: "graders:grade_hard"
 
2
  name: "blockchain_certificate_admin"
3
  description: "An agent acts as a smart contract administrator, processing student certificates. It must validate scores, check for 42-character 0x wallet addresses, and manage its gas balance to successfully mint."
4
 
5
+ # Updated to the specific keys the validator expects
6
+ models:
7
+ observation: "models:BlockchainObservation"
8
+ action: "models:BlockchainAction"
9
+ reward: "models:BlockchainReward"
10
 
11
+ env: "env:BlockchainEnv"
 
12
 
13
+ # The 3 mandatory tasks with fixed paths
14
  tasks:
15
+ - id: "easy_minting"
16
+ grader: "graders.grade_easy"
 
17
 
18
+ - id: "medium_gas_management"
19
+ grader: "graders.grade_medium"
 
20
 
21
+ - id: "hard_perfectionist"
22
+ grader: "graders.grade_hard"