AI Lab file 2024
Assignment 1 Problem – Write a program to find out the next state of a given 8-puzzle problem. Solution : import heapq # Define the goal state goal_state = [[1, 2, 3], [4, 5, 6], [7, 8, 0]] # Define the possible moves moves = [(0, 1), (0, -1), (1, 0), (-1, 0)] def heuristic(state): # Manhattan distance heuristic distance = 0 for i in range(3): for j in range(3): if state[i][j] != 0: goal_row, goal_col = (state[i][j] - 1) // 3, (state[i][j] - 1) % 3 ...
Keep it up
ReplyDeleteI feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details
ReplyDeletenebosh igc courses in chennai