Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create the slider puzzle game in python 3 , it should be a 3x3 grid and have each square be a number 1 through 8

Create the slider puzzle game in python 3, it should be a 3x3 grid and have each square be a number 1 through 8 with one blank square. Each square should be a button in Tkinter. Only Tkinter and Math may be imported. I've attached what I have so far below.

class eight_puzzel: def _init__(self): self.moves = dict() self.moves[0] = [1, 3] self.moves[1] = [0, 2, 4] self.moves[2] = [1, 5] self.moves[3] = [0, 4, 6] self.moves[4] = [3, 5, 7] self.moves[5] = [2, 4, 8] self.moves[6] = [3, 7] self.moves[7] = [4, 6, 8] self.moves[8] = [5, 7]

self.config = ['1', '2', '3', '4', '5', '6', '7', '8', ' '] shuffle(self.config)

def display(self): if self.window != None: self.window = Tk()

def gui_move(self, event): self.move(self.button_locs(event.widget)

def move(self, tile): tile_loc = self.config.index(str(tile)) blank_loc = self.config.index(' ') if tile_loc in self.moves[blank_loc]: self.config[tile_loc] = ' ' self.config[blank_loc] = str(tile) self.display()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Classify delivery styles by type.

Answered: 1 week ago