Python Learning Week 11 (Solution)

Mini Project: Adversarial Search or Playing Games with Python Game name: Tic Tac Toe (Using: The Minimax Algorithm)      PROJECT REPORT TIC TAC TOE IN PYTHON In this project we have created TIC TAC TOE game using minimax algorithm inpython. The game is created using Tkinter which is a standard GUI library for python.Tkinter provides […]
Read More

Python Learning Week 7 (Solution)

Task 1 Implement Greedy Best First Search Algorithm for the given example, if starting node is Arad and goal node is Bucharest.   CODE: GRAPH = {‘Arad’:[[‘Zerind’,374],[‘Timisoara’,329],[‘Sibiu’,253]],          ‘Zerind’:[[‘Oradea’,380],[‘Arad’,366]],          ‘Oradea’:[[‘Sibiu’,253]],          ‘Sibiu’:[[‘Rimniciu Vilcea’,193],[‘Fagaras’,178],[‘Arad’,366]],          ‘Fagaras’:[[‘Sibiu’,253],[‘Bucharest’,0]],          ‘Rimniciu Vilcea’:[[‘Pitesti’,98],[‘Craiova’,160],[‘Sibiu’,253]],          ‘Timisoara’:[[‘Lugoj’,244],[‘Arad’,366]],          ‘Lugoj’:[[‘Mehadia’,241]],          ‘Mehadia’:[[‘Lugoj’,244],[‘Dorbeta’,242]],          ‘Dobreta’:[[‘Mehadia’,241],[‘Craiova’,160]],          ‘Pitesti’:[[‘Craiova’,160],[‘Bucharest’,0]],          ‘Craiova’:[[‘Pitesti’,98],[‘Dobreta’,242],[‘Rimniciu Vilcea’,193]],          ‘Bucharest’:[[‘Giurgiu’,77],[‘Urziceni’,80],[‘Fagaras’,178],[‘Pitesti’,98]],          ‘Giurgiu’: [[‘Bucharest’,0]],          ‘Urziceni’:[[‘Vaslui’,199],[‘Hirsova’,151],[‘Bucharest’,0]],          ‘Vaslui’:[[‘Lasi’,226],[‘Urziceni’,80]],          ‘Lasi’:[[‘Neamt’,234],[‘Vaslui’,199]],          ‘Neamt’:[[‘Lasi’,226]],          ‘Hirsova’:[[‘Eforie’,161],[‘Urziceni’,80]],          ‘Eforie’:[[‘Hirsova’,151]] } def gbfs(GRAPH, start, end):     explored = []     queue = [start]     while queue:         print (queue)         node = queue.pop(0)         if node not […]
Read More

Create a GUI program in Python that can play 15-puzzle game

CODE: import queue import random class Board: def __init__(self): self.board = [list(range(1, 5)), list(range(5, 9)), list(range(9, 13)), list(range(13, 16)) + [‘*’] ] self.goal = [] for i in self.board: self.goal.append(tuple(i)) self.goal = tuple(self.goal) self.empty = [3, 3] def __repr__(self): string = ” for row in self.board: for num in row: if len(str(num)) == 1: string […]
Read More