Commit ab1bf200 authored by Julian Rudolf's avatar Julian Rudolf
Browse files

ui changes

parent f858eab8
......@@ -99,7 +99,7 @@ block_size = path = apple_size = 30
apple_count = 3
bomb_count = 1
bomb_switch_time = 7000
apple_win_count = 10
apple_win_count = 5
pygame.display.set_caption("Snake Game")
pygame.display.set_icon(purple_head)
clock = pygame.time.Clock()
......@@ -426,27 +426,35 @@ class Snake:
crash = True
# print(str(self.id) + ' '+str([[int(i[1]/30), int(i[0]/30)] for i in reversed(self.list)]))
if self.shield and self.process is not None and self.process.exitcode is not None:
if self.shield and self.process is not None and self.process.exitcode is not None and False:
self.crash_prob = self.crash_prob_queue.get()
print('pid: ' + str(self.process.pid))
# print("done early id " + str(self.id) + ' ' + str(self.crash_prob) + ' ' + 'pid: ' + str(self.process.pid))
self.process.close()
self.process = None
self.color_prob(self.crash_prob)
# shield recalc nur wenn gegnerische Schlange 1 nach crossing
# nur wenn nicht alle 0.0
# wenn eigene schlange bei crossing -> process töten(?)
if check_if_after_crossing(self.enemy_norm_snake.pos[1] / block_size,
self.enemy_norm_snake.pos[0] / block_size, self.enemy_norm_snake.direction):
if self.shield and self.process is None and self.shield_snake.shield_calc_dist():
print("Starting recalc")
ps = self.shield_snake.copy()
es = self.enemy_snake.copy()
self.process = mp.Process(target=get_shield, args=(self.crash_prob_queue, ps, es))
self.process.start()
print("ps: nodes " + str(self.shield_snake.nodes) + " edges " + str(self.shield_snake.edges) + ' dist ' + str(
self.shield_snake.dist) + '\n' + 'es: nodes ' + str(self.enemy_snake.nodes) + " edges " + str(
self.enemy_snake.edges) + 'dist ' + str(self.enemy_snake.dist) + '\n' + 'process ' + str(
self.process.pid) + " started snake: " + str(self.id))
choice = True
try:
choice = all_good_choice(self.crash_prob)
except AttributeError:
choice = True
if not choice:
if check_if_after_crossing(self.enemy_norm_snake.pos[1] / block_size,
self.enemy_norm_snake.pos[0] / block_size, self.enemy_norm_snake.direction):
if self.shield and self.process is None:
print("Starting recalc")
ps = self.shield_snake.copy()
es = self.enemy_snake.copy()
self.process = mp.Process(target=get_shield, args=(self.crash_prob_queue, ps, es))
self.process.start()
print("ps: nodes " + str(self.shield_snake.nodes) + " edges " + str(self.shield_snake.edges) + ' dist ' + str(
self.shield_snake.dist) + '\n' + 'es: nodes ' + str(self.enemy_snake.nodes) + " edges " + str(
self.enemy_snake.edges) + 'dist ' + str(self.enemy_snake.dist) + '\n' + 'process ' + str(
self.process.pid) + " started snake: " + str(self.id))
self.draw_snake()
self.count += 1
......@@ -477,6 +485,14 @@ class Snake:
self.crash_prob_draw.append((red, [pos[0], pos[1], block_size, block_size]))
# checks if there is a prob != 0.0%
def all_good_choice(crash_prob):
for _, prob in crash_prob.items():
if prob != 0.0:
return False
return True
# checks if coordinates are one after crossing
def check_if_after_crossing(y, x, angle):
ret = False
......@@ -609,8 +625,8 @@ def gen_rand_apple(image):
def button(text, pos, color1, color2, action, text_color=black):
cur = pygame.mouse.get_pos()
click = pygame.mouse.get_pressed()
speed_select = ((int(res_x / 2 - 200), res_y - 415, 100, 30), (int(res_x / 2 - 320), res_y - 415, 100, 30), (int(res_x / 2 - 440), res_y - 415, 100, 30))
length_select = ((int(res_x / 2 + 340), res_y - 415, 100, 30), (int(res_x / 2 + 220), res_y - 415, 100, 30), (int(res_x / 2 + 100), res_y - 415, 100, 30))
speed_select = ((int(res_x / 2 - 200), res_y - 300, 100, 30), (int(res_x / 2 - 320), res_y - 300, 100, 30), (int(res_x / 2 - 440), res_y - 300, 100, 30))
length_select = ((int(res_x / 2 + 340), res_y - 300, 100, 30), (int(res_x / 2 + 220), res_y - 300, 100, 30), (int(res_x / 2 + 100), res_y - 300, 100, 30))
if pos[0] + pos[2] > cur[0] > pos[0] and pos[1] + pos[3] > cur[1] > pos[1]:
pygame.draw.rect(Display, color2, pos)
......@@ -829,26 +845,22 @@ def select_map():
global startsnake1, startsnake2
global snake_length
Display.fill(white)
pos1 = (-300, -100)
pos2 = (0, -100)
pos3 = (300, -100)
pos4 = (-300, 200)
pos5 = (0, 200)
pos6 = (300, 200)
pos1 = (-300, 0)
pos2 = (0, 0)
pos3 = (300, 0)
p1_pos = pos1
p2_pos = pos3
p1 = selection_rect(green, 200, 200, p1_pos)
p2 = selection_rect(red, 200, 200, p2_pos)
message_screen("Select the Map!", black, -350, "large")
message_screen("If different maps are selected, its random choice", grey, -300, "small")
message_screen("Map1", black, pos1[1], "small", pos1[0])
message_screen("Map2", black, pos2[1], "small", pos2[0])
image_screen(map3_icon, pos3)
message_screen("Map4", black, pos4[1], "small", pos4[0])
image_screen(map5_icon, pos5)
image_screen(map6_icon, pos6)
pygame.draw.rect(Display, black, (int(res_x / 2 + 220), res_y - 415, 100, 30), 8)
pygame.draw.rect(Display, black, (int(res_x / 2 - 320), res_y - 415, 100, 30), 8)
image_screen(map3_icon, pos1)
image_screen(map5_icon, pos2)
image_screen(map6_icon, pos3)
pygame.draw.rect(Display, black, (int(res_x / 2 + 220), res_y - 300, 100, 30), 8)
pygame.draw.rect(Display, black, (int(res_x / 2 - 320), res_y - 300, 100, 30), 8)
p1_map = maps.map3
p1_map_filename = '../Shield/maps/map3.pickle'
p1_start = maps.start3
p1_length = snake_length
while map_select:
for event in pygame.event.get():
......@@ -861,13 +873,12 @@ def select_map():
map = maps.map8
map_filename = '../Shield/maps/map8.pickle'
startsnake1, startsnake2 = maps.start8
snake_length = 4
return
elif event.key == pygame.K_LEFT and not p1_pos == pos1 and not p1_pos == pos4:
snake_length = 20
elif event.key == pygame.K_LEFT and not p1_pos == pos1:
pygame.draw.rect(Display, white, p1, 5)
p1_pos = (p1_pos[0] - 300, p1_pos[1])
p1.move_ip(-300, 0)
elif event.key == pygame.K_RIGHT and not p1_pos == pos3 and not p1_pos == pos6:
elif event.key == pygame.K_RIGHT and not p1_pos == pos3:
pygame.draw.rect(Display, white, p1, 5)
p1_pos = (p1_pos[0] + 300, p1_pos[1])
p1.move_ip(300, 0)
......@@ -875,99 +886,37 @@ def select_map():
pygame.draw.rect(Display, white, p1, 5)
p1_pos = (p1_pos[0], p1_pos[1] - 300)
p1.move_ip(0, -300)
elif event.key == pygame.K_DOWN and not p1_pos == pos4 and not p1_pos == pos5 and not p1_pos == pos6:
pygame.draw.rect(Display, white, p1, 5)
p1_pos = (p1_pos[0], p1_pos[1] + 300)
p1.move_ip(0, 300)
elif event.key == pygame.K_a and not p2_pos == pos1 and not p2_pos == pos4:
pygame.draw.rect(Display, white, p2, 5)
p2_pos = (p2_pos[0] - 300, p2_pos[1])
p2.move_ip(-300, 0)
elif event.key == pygame.K_d and not p2_pos == pos3 and not p2_pos == pos6:
pygame.draw.rect(Display, white, p2, 5)
p2_pos = (p2_pos[0] + 300, p2_pos[1])
p2.move_ip(300, 0)
elif event.key == pygame.K_w and not p2_pos == pos1 and not p2_pos == pos2 and not p2_pos == pos3:
pygame.draw.rect(Display, white, p2, 5)
p2_pos = (p2_pos[0], p2_pos[1] - 300)
p2.move_ip(0, -300)
elif event.key == pygame.K_s and not p2_pos == pos4 and not p2_pos == pos5 and not p2_pos == pos6:
pygame.draw.rect(Display, white, p2, 5)
p2_pos = (p2_pos[0], p2_pos[1] + 300)
p2.move_ip(0, 300)
if p1_pos == p2_pos:
pygame.draw.rect(Display, black, p1, 5)
else:
pygame.draw.rect(Display, p1_snake[1], p1, 5)
pygame.draw.rect(Display, p2_snake[1], p2, 5)
p1_map = maps.map3
p2_map = maps.map3
p1_map_filename = '../Shield/maps/map3.pickle'
p2_map_filename = '../Shield/maps/map3.pickle'
p1_start = maps.start3
p2_start = maps.start3
p1_length = snake_length
p2_length = snake_length
if p1_pos == pos3:
pygame.draw.rect(Display, p1_snake[1], p1, 5)
if p1_pos == pos1:
p1_map = maps.map3
p1_map_filename = '../Shield/maps/map3.pickle'
p1_start = maps.start3
p1_length = 20
elif p1_pos == pos5:
elif p1_pos == pos2:
p1_map = maps.map5
p1_map_filename = '../Shield/maps/map5.pickle'
p1_start = maps.start5
p1_length = 20
elif p1_pos == pos6:
elif p1_pos == pos3:
p1_map = maps.map6
p1_map_filename = '../Shield/maps/map6.pickle'
p1_start = maps.start6
p1_length = 20
if p2_pos == pos3:
p2_map = maps.map3
p2_map_filename = '../Shield/maps/map3.pickle'
p2_start = maps.start3
p2_length = 15
elif p2_pos == pos5:
p2_map = maps.map5
p2_map_filename = '../Shield/maps/map5.pickle'
p2_start = maps.start5
p2_length = 15
elif p2_pos == pos6:
p2_map = maps.map6
p2_map_filename = '../Shield/maps/map6.pickle'
p2_start = maps.start6
p2_length = 30
if p1_pos == p2_pos:
map = p1_map
map_filename = p1_map_filename
startsnake1, startsnake2 = p1_start
snake_length = p1_length
else:
rand = random.randint(0, 1)
if rand:
map = p1_map
map_filename = p1_map_filename
startsnake1, startsnake2 = p1_start
snake_length = p1_length
else:
map = p2_map
map_filename = p2_map_filename
startsnake1, startsnake2 = p2_start
snake_length = p2_length
button("Fast", (int(res_x / 2 - 200), res_y - 415, 100, 30), red, light_red, action="speed65")
button("Medium", (int(res_x / 2 - 320), res_y - 415, 100, 30), yellow, light_yellow, action="speed45")
button("Slow", (int(res_x / 2 - 440), res_y - 415, 100, 30), green, light_green, action="speed25")
button("Long", (int(res_x / 2 + 340), res_y - 415, 100, 30), red, light_red, action="length20")
button("Medium", (int(res_x / 2 + 220), res_y - 415, 100, 30), yellow, light_yellow, action="length15")
button("Short", (int(res_x / 2 + 100), res_y - 415, 100, 30), green, light_green, action="length10")
map_select = button("Got the Map", (int(res_x / 2 - 60), res_y - 425, 120, 50), light_blue, very_light_blue, action="loading")
map = p1_map
map_filename = p1_map_filename
startsnake1, startsnake2 = p1_start
snake_length = p1_length
button("Fast", (int(res_x / 2 - 200), res_y - 300, 100, 30), red, light_red, action="speed65")
button("Medium", (int(res_x / 2 - 320), res_y - 300, 100, 30), yellow, light_yellow, action="speed45")
button("Slow", (int(res_x / 2 - 440), res_y - 300, 100, 30), green, light_green, action="speed25")
button("Long", (int(res_x / 2 + 340), res_y - 300, 100, 30), red, light_red, action="length20")
button("Medium", (int(res_x / 2 + 220), res_y - 300, 100, 30), yellow, light_yellow, action="length15")
button("Short", (int(res_x / 2 + 100), res_y - 300, 100, 30), green, light_green, action="length10")
map_select = button("Got the Map", (int(res_x / 2 - 60), res_y - 315, 120, 50), light_blue, very_light_blue, action="loading")
clock.tick(30)
pygame.display.update()
......
......@@ -16,38 +16,45 @@
# lead to problems with the shield (edge length = 0)
# ------------------------------------------------------------------
# startpos1 = [[540, 300], [260, 300]]
# map1 = [[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
# [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
# [1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1],
# [1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1],
# [1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1],
# [1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1],
# [1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1],
# [1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1],
# [1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1],
# [1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1],
# [1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1],
# [1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1],
# [1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,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,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]]
#
start1 = [{"pos": [[2,4],[2,5],[2,6],[2,7],[2,8],[2,9],[2,10],[2,11],[2,12],[2,13],[2,14],[2,15],[2,16],[2,17],[3,17],[4,17],[5,17],[6,17],[6,18],[6,19]],
"vel": [[-1,0],[-1,0],[-1,0],[-1,0],[-1,0],[-1,0],[-1,0],[-1,0],[-1,0],[-1,0],[-1,0],[-1,0],[-1,0],[-1,0],[0,-1],[0,-1],[0,-1],[0,-1],[-1,0],[-1,0]],
"angle": 'left'},
{"pos": [[25,25],[25,24],[25,23],[25,22],[25,21],[25,20],[25,19],[25,18],[25,17],[25,16],[25,15],[25,14],[25,13],[25,12],[25,11],[25,9],[25,8],[24,8],[23,8],[22,8]],
"vel": [[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[1,0],[0,-1],[0,-1],[0,-1]],
"angle": 'right'}]
map1 = [[1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1],
[1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1],
[1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1],
[1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1],
[1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,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-1,0],[-1,0],[-1,0],[-1,0],[-1,0],[-1,0],[-1,0]],
......
......@@ -275,7 +275,7 @@ def graph_from_map(map):
nodes_map = wrap_around_edges(nodes_map)
#print('map')
#print(nodes_map)
print(nodes_map)
# add edges to the corresponding nodes
for i in range(len(nodes_map)):
......
No preview for this file type
No preview for this file type
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment