Course Solutions Uncategorized (Solved) : Code 8 Puzzle Problem Solved Bfs Please Add Function Code Find Number Nodes Explored Soon Q32902733 . . . .

(Solved) : Code 8 Puzzle Problem Solved Bfs Please Add Function Code Find Number Nodes Explored Soon Q32902733 . . . .

 

THIS IS A CODE FOR 8 PUZZLE PROBLEM SOLVED BY BFS . PLEASE ADD AFUNCTION TO THIS CODE TO FIND THE NUMBER OF NODES EXPLORED ! ASSOON AS POSSIBLE!!!! THE FUNCTION SHOULD BE IN THIS CODE AND INPYTHON

import copy

import time

start=time.clock()

#global count

“””start_state=[[1,2,3],[4,5,6],[7,8,0]]

goal_state=[[1,2,3],[0,4,5],[7,8,6]]”””

start_state=[[1,2,5],[3,4,0],[6,7,8]]

goal_state=[[0,1,2],[3,4,5],[6,7,8]]

def left_shift(pres_state):

global count

temp_state=copy.deepcopy(pres_state)

for i in range(3):

for j in range(3):

if temp_state[i][j]==0 and j>0:

count=count+1

(temp_state[i][j-1],temp_state[i][j])=(temp_state[i][j],temp_state[i][j-1])

return temp_state

return pres_state

def right_shift(pres_state):

global count

  

temp_state=copy.deepcopy(pres_state)

for i in range(3):

for j in range(3):

if temp_state[i][j]==0 and j<2:

count+=1

(temp_state[i][j+1],temp_state[i][j])=(temp_state[i][j],temp_state[i][j+1])

return temp_state

return pres_state

  

def upper_shift(pres_state):

global count

temp_state=copy.deepcopy(pres_state)

for i in range(3):

for j in range(3):

if temp_state[i][j]==0 and i>0:

count+=1

(temp_state[i-1][j],temp_state[i][j])=(temp_state[i][j],temp_state[i-1][j])

return temp_state

return pres_state

def lower_shift(pres_state):

global count

  

temp_state=copy.deepcopy(pres_state)

for i in range(3):

for j in range(3):

if temp_state[i][j]==0 and i<2:

count+=1

(temp_state[i+1][j],temp_state[i][j])=(temp_state[i][j],temp_state[i+1][j])

return temp_state   

return pres_state

class Node:

def __init__(self,pres_state,parent,visited):

self.pres_state=pres_state

self.parent=parent

self.visited=False

def print_path(pres_node):

  

l=[]

while pres_node.parent!=None:

l.append(pres_node.pres_state)

pres_node=pres_node.parent

l.reverse()

for i in

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

(Solved) : 40 41 42 30 Many License Plates Made Using Either Three Uppercase English Letters Followed Q36203671 . . . .(Solved) : 40 41 42 30 Many License Plates Made Using Either Three Uppercase English Letters Followed Q36203671 . . . .

Hi, please help me <br/><img src="https://media.cheggcdn.com/media%2F191%2F191fd6c4-a530-4aac-a007-927016b5b8df%2Fimage.png" alt="media%2F191%2F191fd6c4-a530-4aac-a007-92" aria-describedby="d3f"/><img src="https://media.cheggcdn.com/media%2Fc7c%2Fc7cc9790-4ff4-473e-bc58-27d0a2716855%2Fimage.png" alt="40. 41. 42. 30. How many license plates can be made using either three uppercase English letters followed by three