Skip to content

Adding Tkinter GUI #661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 20, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added Depth-First Tree Search
  • Loading branch information
apb7 committed Dec 18, 2017
commit f2e1a12208c3276b5fb3163e3f381359418664ff
22 changes: 19 additions & 3 deletions gui/romania_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import math
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from search import *
from search import breadth_first_tree_search as bfts
from search import breadth_first_tree_search as bfts, depth_first_tree_search as dfts
from utils import Stack, FIFOQueue, PriorityQueue
from copy import deepcopy
root = None
Expand Down Expand Up @@ -370,6 +370,14 @@ def breadth_first_tree_search(problem):
return tree_search(problem)


def depth_first_tree_search(problem):
"""Search the deepest nodes in the search tree first."""
global frontier,counter
if counter == -1:
frontier=Stack()
return tree_search(problem)

# TODO: Remove redundant code.
def on_click():
'''
This function defines the action of the 'Next' button.
Expand All @@ -384,7 +392,14 @@ def on_click():
display_final(final_path)
next_button.config(state="disabled")
counter += 1

elif "Depth-First Tree Search" == algo.get():
node = depth_first_tree_search(romania_problem)
if node is not None:
final_path = dfts(romania_problem).solution()
final_path.append(start.get())
display_final(final_path)
next_button.config(state="disabled")
counter += 1

def reset_map():
global counter, city_coord, city_map, next_button
Expand All @@ -408,7 +423,8 @@ def main():
start.set('Arad')
goal.set('Bucharest')
cities = sorted(romania_map.locations.keys())
algorithm_menu = OptionMenu(root, algo, "Breadth-First Tree Search")
algorithm_menu = OptionMenu(
root, algo, "Breadth-First Tree Search", "Depth-First Tree Search")
Label(root, text="\n Search Algorithm").pack()
algorithm_menu.pack()
Label(root, text="\n Start City").pack()
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy