回答編集履歴
3
5x5の件
test
CHANGED
File without changes
|
2
5x5の件
test
CHANGED
@@ -140,7 +140,7 @@
|
|
140
140
|
|
141
141
|
pass
|
142
142
|
|
143
|
-
if action == 1 and self.hunter_Position_X ==
|
143
|
+
if action == 1 and self.hunter_Position_X == -1:
|
144
144
|
|
145
145
|
pass
|
146
146
|
|
@@ -148,7 +148,7 @@
|
|
148
148
|
|
149
149
|
pass
|
150
150
|
|
151
|
-
if action == 3 and self.hunter_Position_Y ==
|
151
|
+
if action == 3 and self.hunter_Position_Y == -1:
|
152
152
|
|
153
153
|
pass
|
154
154
|
|
1
5x5の件
test
CHANGED
@@ -24,17 +24,17 @@
|
|
24
24
|
|
25
25
|
def __init__(self):
|
26
26
|
|
27
|
-
self.hunter_Position_X=random.randint(0,
|
27
|
+
self.hunter_Position_X=random.randint(0,4)
|
28
|
-
|
28
|
+
|
29
|
-
self.hunter_Position_Y=random.randint(0,
|
29
|
+
self.hunter_Position_Y=random.randint(0,4)
|
30
30
|
|
31
31
|
# print("鬼の初期位置は"+str(self.hunter_Position_X),self.hunter_Position_Y)
|
32
32
|
|
33
33
|
#selfでグローバル変数化している。鬼のx,y座標をランダムに配置。
|
34
34
|
|
35
|
-
self.fugitive_Position_X=random.randint(0,
|
35
|
+
self.fugitive_Position_X=random.randint(0,4)
|
36
|
-
|
36
|
+
|
37
|
-
self.fugitive_Position_Y=random.randint(0,
|
37
|
+
self.fugitive_Position_Y=random.randint(0,4)
|
38
38
|
|
39
39
|
# print("逃亡者の初期位置は"+str(self.fugitive_Position_X),self.fugitive_Position_Y)
|
40
40
|
|
@@ -42,9 +42,9 @@
|
|
42
42
|
|
43
43
|
while self.hunter_Position_X == self.fugitive_Position_X and self.hunter_Position_Y == self.fugitive_Position_Y:
|
44
44
|
|
45
|
-
self.hunter_Position_X=random.randint(0,
|
45
|
+
self.hunter_Position_X=random.randint(0,4)
|
46
|
-
|
46
|
+
|
47
|
-
self.hunter_Position_Y=random.randint(0,
|
47
|
+
self.hunter_Position_Y=random.randint(0,4)
|
48
48
|
|
49
49
|
#print(self.hunter_Position_X,self.hunter_Position_Y)
|
50
50
|
|
@@ -78,7 +78,7 @@
|
|
78
78
|
|
79
79
|
low = np.array([0, 0, 0, 0])
|
80
80
|
|
81
|
-
high = np.array([
|
81
|
+
high = np.array([4, 4, 4, 4])
|
82
82
|
|
83
83
|
self.observation_space = gym.spaces.Box(low, high, dtype=np.int64)
|
84
84
|
|
@@ -108,11 +108,13 @@
|
|
108
108
|
|
109
109
|
# print("学習回数は",self.learn_count)
|
110
110
|
|
111
|
+
|
112
|
+
|
111
113
|
if action == 0 and self.hunter_Position_X < 5:
|
112
114
|
|
113
115
|
self.hunter_Position_X += 1
|
114
116
|
|
115
|
-
if action == 1 and self.hunter_Position_X > 0:
|
117
|
+
if action == 1 and self.hunter_Position_X >= 0:
|
116
118
|
|
117
119
|
self.hunter_Position_X -= 1
|
118
120
|
|
@@ -120,7 +122,7 @@
|
|
120
122
|
|
121
123
|
self.hunter_Position_Y += 1
|
122
124
|
|
123
|
-
if action == 3 and self.hunter_Position_Y > 0:
|
125
|
+
if action == 3 and self.hunter_Position_Y >= 0:
|
124
126
|
|
125
127
|
self.hunter_Position_Y -= 1
|
126
128
|
|
@@ -210,19 +212,19 @@
|
|
210
212
|
|
211
213
|
def reset_position(self):
|
212
214
|
|
213
|
-
hunter_Position_X=random.randint(0,
|
215
|
+
hunter_Position_X=random.randint(0,4)
|
214
|
-
|
216
|
+
|
215
|
-
hunter_Position_Y=random.randint(0,
|
217
|
+
hunter_Position_Y=random.randint(0,4)
|
216
|
-
|
218
|
+
|
217
|
-
fugitive_Position_X=random.randint(0,
|
219
|
+
fugitive_Position_X=random.randint(0,4)
|
218
|
-
|
220
|
+
|
219
|
-
fugitive_Position_Y=random.randint(0,
|
221
|
+
fugitive_Position_Y=random.randint(0,4)
|
220
222
|
|
221
223
|
while hunter_Position_X == fugitive_Position_X and hunter_Position_Y == fugitive_Position_Y:
|
222
224
|
|
223
|
-
hunter_Position_X=random.randint(0,
|
225
|
+
hunter_Position_X=random.randint(0,4)
|
224
|
-
|
226
|
+
|
225
|
-
hunter_Position_Y=random.randint(0,
|
227
|
+
hunter_Position_Y=random.randint(0,4)
|
226
228
|
|
227
229
|
print("リセットされました!!!")
|
228
230
|
|