Decide to write from scratch again, but much more simplistic

This commit is contained in:
emil
2024-10-29 03:57:47 +03:00
parent 0db4105710
commit 7271a80bd0
2 changed files with 62 additions and 1 deletions
+4 -1
View File
@@ -234,12 +234,14 @@ def read_input():
return inpt
def move(x, y):
neo.update_open_set()
for i in neo.open_set:
print(i.position)
if map.get_cell(x, y) in neo.open_set: #TODO: FIX CHECK
neo.set_position(x, y)
print(f"m {x} {y}")
else:
print("ERROR: CAN'T MOVE HERE")
neo.update_open_set()
map = Map((8, 8))
@@ -254,6 +256,7 @@ pg.display.set_caption("Matrix Universe")
running = True
#pg.time.delay(7000)
neo.set_position(0, 0) #TODO: ITS TEMPORARY
neo.update_open_set()
move(0, 0)
read_initial_inputs()
pg.time.delay(1500)
+58
View File
@@ -0,0 +1,58 @@
def get_position_input():
position_input_list = (input().split(" "))
position_input_tuple = ()
for i in position_input_list:
position_input_tuple += (i,)
return position_input_tuple
def get_walkable_cells():
walkable_cells = []
potential_positions = []
potential_positions.append((neo[0], neo[1] + 1))
potential_positions.append((neo[0], neo[1] - 1))
potential_positions.append((neo[0] - 1, neo[1]))
potential_positions.append((neo[0] + 1, neo[1]))
for i in potential_positions:
if i[0] in range(MAP_SIZE) and i[1] in range(MAP_SIZE):
walkable_cells.append(i)
return walkable_cells
def get_g(cell:tuple):
return abs((neo[0] - cell[0]) + (neo[1] - cell[1]))
def get_h(cell:tuple):
return abs((keymaster[0] - cell[0]) + (keymaster[1] - cell[1]))
def get_f(cell:tuple):
return get_g(cell) + get_h(cell)
def set_position(new_postion:tuple):
neo = new_postion
MAP_SIZE = 8
map = []
start = (0, 0) #initial position of Neo
neo = start #position of Neo
keymaster = () #position of Keymaster
perception_radius = input()
position_input = get_position_input()
keymaster = (position_input[0], position_input[1])
print(neo)
print(get_walkable_cells())
while (True):
position_input = get_position_input()
set_position(position_input)
print(neo)
print(get_walkable_cells())