回答編集履歴
1
追記
test
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
単純にループで処理すればよいでのは?
|
2
|
+
|
3
|
+
また、移動範囲も制限しました。範囲を越えた移動はキャンセルするようにしています。
|
2
4
|
|
3
5
|
```Python
|
4
6
|
|
5
7
|
import random
|
8
|
+
|
9
|
+
from pprint import pprint
|
6
10
|
|
7
11
|
|
8
12
|
|
@@ -12,14 +16,30 @@
|
|
12
16
|
|
13
17
|
|
14
18
|
|
15
|
-
for i in range(
|
19
|
+
for i in range(100):
|
16
20
|
|
17
21
|
rand_0 = random.randint(0,3)
|
18
22
|
|
19
|
-
|
23
|
+
pos = [data[-1][0]+c[rand_0][0], data[-1][1]+c[rand_0][1]]
|
20
24
|
|
21
25
|
|
22
26
|
|
27
|
+
# 移動範囲の制限=移動しないように
|
28
|
+
|
29
|
+
if pos[0] < 0: pos[0] = 0
|
30
|
+
|
31
|
+
if pos[0] > 12: pos[0] =12
|
32
|
+
|
33
|
+
if pos[1] < 0: pos[1] = 0
|
34
|
+
|
35
|
+
if pos[1] > 12: pos[1] =12
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
data.append(pos)
|
40
|
+
|
41
|
+
|
42
|
+
|
23
|
-
print(data) # [[10, 10], [10, 11], [9, 11], [8, 11], [9, 11]]
|
43
|
+
pprint(data) # [[10, 10], [10, 11], [9, 11], [8, 11], [9, 11]]
|
24
44
|
|
25
45
|
```
|