misc changes
Co-authored-by: Marcin Matoga <marmat35@st.amu.edu.pl> Co-authored-by: Sebastian Piotrowski <sebpio@st.amu.edu.pl>
This commit is contained in:
parent
3f4b73373a
commit
512e20b52e
10
astar2.py
10
astar2.py
@ -406,8 +406,14 @@ class SweeperAgent:
|
||||
|
||||
|
||||
@staticmethod
|
||||
def run_manual_map(self,start_map, goal_map):
|
||||
def run_manual_map(self,start_map, goal_map, orientation = "default"):
|
||||
if orientation == "default":
|
||||
self.orientation = SweeperAgent.set_orientation(start_map)
|
||||
else:
|
||||
self.orientation = orientation
|
||||
|
||||
|
||||
|
||||
goal_orientation = SweeperAgent.set_goal_orientation(goal_map)
|
||||
|
||||
SweeperAgent.set_allowed(self.allowed_points, start_map)
|
||||
@ -423,6 +429,8 @@ class SweeperAgent:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@staticmethod
|
||||
def run(self):
|
||||
self.orientation = SweeperAgent.set_orientation()
|
||||
|
34
main.py
34
main.py
@ -34,6 +34,7 @@ class Game:
|
||||
self.wentyl_bezpieczenstwa = 0
|
||||
self.minefield = False
|
||||
self.minefield_start_map = "Looper_maps/start_map"
|
||||
self.orientation_save = "default"
|
||||
# ExampleGenerator.generate(ExampleGenerator)
|
||||
|
||||
def load_data(self, map_name = "main_map.txt"):
|
||||
@ -166,6 +167,9 @@ class Game:
|
||||
if event.key == pg.K_F9 and self.wentyl_bezpieczenstwa == 0:
|
||||
#genetic_lib_runner = GeneticalWithLib()
|
||||
#genetic_lib_runner.run()
|
||||
|
||||
#print(str(self.player.get_direction()).upper())
|
||||
|
||||
self.wentyl_bezpieczenstwa = 1
|
||||
if event.key == pg.K_F10 and self.wentyl_bezpieczenstwa == 0:
|
||||
self.player.ai_mode = "tree"
|
||||
@ -186,15 +190,30 @@ class Game:
|
||||
if self.minefield == True:
|
||||
if event.key == pg.K_1 and self.wentyl_bezpieczenstwa == 0:
|
||||
agent = SweeperAgent()
|
||||
if self.minefield_start_map == "Looper_maps/start_map":
|
||||
player_moves = SweeperAgent.run_manual_map(agent, self.minefield_start_map, "Looper_maps/mine1_map")
|
||||
self.minefield_start_map = "Looper_maps/mine1_map"
|
||||
else:
|
||||
player_moves = SweeperAgent.run_manual_map(agent, self.minefield_start_map, "Looper_maps/mine1_map", orientation=self.orientation_save)
|
||||
|
||||
self.minefield_start_map = 'Looper_maps/mine1_map'
|
||||
self.orientation_save = self.orientation_reverse(str(self.player.get_direction()).upper())
|
||||
|
||||
|
||||
self.graph_move(player_moves)
|
||||
|
||||
self.wentyl_bezpieczenstwa = 1
|
||||
if event.key == pg.K_2 and self.wentyl_bezpieczenstwa == 0:
|
||||
agent = SweeperAgent()
|
||||
if self.minefield_start_map == "Looper_maps/start_map":
|
||||
player_moves = SweeperAgent.run_manual_map(agent, self.minefield_start_map, "Looper_maps/mine2_map")
|
||||
self.minefield_start_map = "Looper_maps/mine2_map"
|
||||
else:
|
||||
player_moves = SweeperAgent.run_manual_map(agent, self.minefield_start_map, "Looper_maps/mine2_map", orientation=self.orientation_save)
|
||||
|
||||
self.minefield_start_map = 'Looper_maps/mine2_map'
|
||||
self.orientation_save = self.orientation_reverse(str(self.player.get_direction).upper())
|
||||
|
||||
self.graph_move(player_moves)
|
||||
|
||||
self.wentyl_bezpieczenstwa = 1
|
||||
if event.key == pg.K_3 and self.wentyl_bezpieczenstwa == 0:
|
||||
agent = SweeperAgent()
|
||||
@ -255,7 +274,16 @@ class Game:
|
||||
def minefield_looping(self):
|
||||
pass
|
||||
|
||||
|
||||
def orientation_reverse(self, orientation):
|
||||
if orientation == 'LEFT':
|
||||
return 'RIGHT'
|
||||
if orientation == 'RIGHT':
|
||||
return 'LEFT'
|
||||
if orientation == 'UP':
|
||||
return 'DOWN'
|
||||
if orientation == 'DOWN':
|
||||
return 'UP'
|
||||
pass
|
||||
|
||||
def graph_move(self, moves):
|
||||
for i in moves:
|
||||
|
@ -39,6 +39,8 @@ class Player(pg.sprite.Sprite):
|
||||
self.y = copy.deepcopy(self.resetY)
|
||||
self.direction = copy.deepcopy(self.resetDirection)
|
||||
|
||||
def get_direction(self):
|
||||
return self.direction
|
||||
|
||||
def set_direction(self, direction):
|
||||
self.direction = direction
|
||||
|
Loading…
Reference in New Issue
Block a user