-
Notifications
You must be signed in to change notification settings - Fork 9
/
continue_obsmap_test.py
executable file
·39 lines (27 loc) · 1.73 KB
/
continue_obsmap_test.py
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
#coding:utf-8
from game import MyContinueGame
from map_ import MyContinueObsMap
from usv import MyContinueUSV
from CircleObstacle import CircleObstacle
if __name__ == '__main__':
'''开始游戏:
map.py: class MyContinueObsMap(BasicMap):
usv.py: class MyContinueUSV(BasicPlaneUSV):
Game.py: class MyContinueGame(BasicGame):(增加障碍物是否随机移动开关:False-静态障碍物 True-随机移动障碍物)
CircleObstacle.py: 圆形障碍物
continue_obsmap_test.py: 主函数
'''
test_map = MyContinueObsMap(100, 100)
test_map.set_target(18.0, 18.0) #目标终点,(注:初始点的设定要合法--即在map缩小ship.radius的范围)
test_friendly_ship = MyContinueUSV(uid=0, x=12.0, y=50.0, env=test_map) #USV友艇起始点,(注:初始点的设定要合法--即在map缩小ship.radius的范围)
test_friendly_ship.set_as_friendly()
test_map.add_ship(test_friendly_ship)
# 静态矩形障碍物区域(注:初始位置的设定要合法,即在map缩小obs.radius的范围)
obs1 = CircleObstacle(uid=0, x=10.0, y=10.0, radius=1, env=test_map);test_map.addobs(obs1)
obs2 = CircleObstacle(uid=1, x=40.0, y=40.0, radius=1, env=test_map);test_map.addobs(obs2)
obs3 = CircleObstacle(uid=2, x=70.0, y=60.0, radius=1, env=test_map);test_map.addobs(obs3)
obs4 = CircleObstacle(uid=3, x=15.0, y=34.0, radius=1, env=test_map);test_map.addobs(obs4)
print('game-start:初始地图:\n',test_map.env_matrix());print('\n')
game = MyContinueGame(True) #False表示障碍物不随机移动; True表示障碍物随机移动
game.set_map(test_map)
game.start()