ZhiyuanZeng commited on
Commit
7769657
·
1 Parent(s): e9c193a

add os env-variable in RlveGym initialization

Browse files
Files changed (1) hide show
  1. server/RLVE_Gym_environment.py +24 -7
server/RLVE_Gym_environment.py CHANGED
@@ -8,6 +8,7 @@
8
  RLVE-Gym Environment Implementation.
9
  """
10
 
 
11
  from typing import Optional, Tuple
12
  import random
13
 
@@ -27,13 +28,33 @@ class RlveGymEnvironment(Environment):
27
 
28
  def __init__(
29
  self,
30
- environment_identifier: str = "Multiplication",
31
- difficulty: int = 0,
32
  answer_markers: Optional[Tuple[str, str]] = None,
33
- initial_seed: int = 0,
34
  ):
35
  """Initialize the RLVE_Gym environment."""
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  self._state = RlveGymState(
38
  seed=initial_seed,
39
  problem_input=None,
@@ -41,10 +62,6 @@ class RlveGymEnvironment(Environment):
41
  sum_accuracy=0,
42
  )
43
 
44
- self.environment_identifier = environment_identifier
45
- self.difficulty = difficulty
46
- self.answer_markers = answer_markers
47
-
48
  self.problem = None
49
 
50
  def reset(self) -> RlveGymObservation:
 
8
  RLVE-Gym Environment Implementation.
9
  """
10
 
11
+ import os
12
  from typing import Optional, Tuple
13
  import random
14
 
 
28
 
29
  def __init__(
30
  self,
31
+ environment_identifier: str = None,
32
+ difficulty: int = None,
33
  answer_markers: Optional[Tuple[str, str]] = None,
34
+ initial_seed: int = None,
35
  ):
36
  """Initialize the RLVE_Gym environment."""
37
 
38
+ if environment_identifier is not None :
39
+ self.environment_identifier = environment_identifier
40
+ else :
41
+ self.environment_identifier = os.getenv("RLVEGYM_ENVIRONMENT_IDENTIFIER", default = "Multiplication")
42
+
43
+ if difficulty is not None :
44
+ self.difficulty = difficulty
45
+ else :
46
+ self.difficulty = int(os.getenv("RLVEGYM_DIFFICULTY", default = "0"))
47
+
48
+ if answer_markers is not None :
49
+ self.answer_markers = answer_markers
50
+ else :
51
+ self.answer_markers = (os.getenv("RLVEGYM_ANSWER_MARKER_START", default = r"<answer>"), os.getenv("RLVEGYM_ANSWER_MARKER_END", default = r"</answer>"))
52
+
53
+ if initial_seed is not None :
54
+ pass
55
+ else :
56
+ initial_seed = int(os.getenv("RLVEGYM_INITIAL_SEED", default = "0"))
57
+
58
  self._state = RlveGymState(
59
  seed=initial_seed,
60
  problem_input=None,
 
62
  sum_accuracy=0,
63
  )
64
 
 
 
 
 
65
  self.problem = None
66
 
67
  def reset(self) -> RlveGymObservation: