File size: 1,103 Bytes
14b6f9b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | from env.environment import CodeGuardianEnv
from env.models import Action
env = CodeGuardianEnv()
obs = env.reset()
done = False
step_cycle = ["detect", "risk", "fix"]
step_index = 0
while not done:
print("\n--- NEW STEP ---")
print("Code:", obs.code)
current_action = step_cycle[step_index]
if current_action == "detect":
action = Action(
action_type="detect",
detected_issues=["wrong operator"],
risk_level=None,
suggested_fix=None
)
elif current_action == "risk":
action = Action(
action_type="risk",
detected_issues=None,
risk_level="low",
suggested_fix=None
)
elif current_action == "fix":
action = Action(
action_type="fix",
detected_issues=None,
risk_level=None,
suggested_fix="return a + b"
)
obs, reward, done, info = env.step(action)
print("Action:", current_action)
print("Reward:", reward)
print("Info:", info)
step_index = (step_index + 1) % 3 |