Professional Documents
Culture Documents
Ai Lab Assignment-1
Ai Lab Assignment-1
Ai Lab Assignment-1
2020-BCS-042
class State:
slf.state = state
slf.lvl = lvl
def calculate_moves(slf):
res_list = []
if row != 0:
if row != 2:
if col != 0:
if col != 2:
return res_list
def find_empty_cell(slf):
if slf.state[row][col] == 0:
temp_arr = copy.deepcopy(slf.state)
temp = temp_arr[initial_row][initial_col]
temp_arr[initial_row][initial_col] = temp_arr[final_row][final_col]
temp_arr[final_row][final_col] = temp
return temp_arr
cost = 0
cost += lvl
if arr[row][col] != goal[row][col]:
cost += 1
return cost
count = 0
states = [root]
while len(states) != 0:
current_node = states.pop()
children = current_node.calculate_moves()
costs = []
min_cost_index = costs.index(min(costs))
print(f"Step: {count+1}")
count += 1
print(row)
if children[min_cost_index] == goal:
else:
states.append(
initial_state = []
for i in range(3):
initial_state.append(list(map(int, input().split())))
goal_state = []
for i in range(3):
goal_state.append(list(map(int, input().split())))
solve(initial_state, goal_state)