CSE2AIF/CSE4002 Artificial Intelligence Fundamentals Report Sample

Problem Description

The Tower of Hanoi Problem

Tower of Hanoi is a mathematical game consisting of three pegs (P1, P2 and P3) and a stack of disks of different diameters. Disks can slide onto any peg. The game starts with all disks stacked on P1 and ends at the point where all disks stacked on P3. The game player is required to move all disks from P1 to P3 using P2 as a buffer. Three rules must be followed when playing the game

(1) Only one disk may be moved at a time.

(2) Each move involves taking a disk on the top of a peg and place it on the top of another peg.

(3) A disk of a larger diameter should never be placed on top of a disk of a smaller diameter.

The diagrams below demonstrate the starting state and goal state of the game with 5 disks.

Requirements

In this assignment, students are required to solve the Tower of Hanoi (with five disks) using state space search algorithms implemented in Python.

Two state space search algorithms: (1) a blind search (depth-first search with depth limit) and (2) a heuristic (A*) search algorithms must be included to complete the assignment.

The completion of the assignment consists of two steps as listed below.

Step 1 Problem Analysis and Design

Before writing the python code, students are required to perform an analysis in order to determine the best design to solve the problem. This includes

(1) The representation of the state

(2) The representation of the state space

(3) The design of the heuristic evaluation function in the A* algorithm

The problem analysis and design should be documented in the analysis and design document.

Step 2 Coding

Write the Python program to implement the design created in Step 1

The program must implement both Depth-First Search and A* Search algorithms. When running the program, it should output

(1) The state space with each unsafe state marked and made a dead end.

(2) The action plan (the path from the initial state to the goal state) generated by the Depth-first search algorithm.

(3) The action plan generated by the A* algorithm.

Marking Scheme

The assignment will be marked based on the following criteria:

• Quality of the analysis and design document [30 marks]

o Design of the state representation (5 marks)

o Selection of the heuristic function and the effectiveness of the function (15 marks)

o Program Structure design (classes, functions, parameters and output etc.) (10 marks)

• Executable of the Python program and correctness of the output [70 marks]

o Correctly output of the state space (20 marks)

o Correctly generate and output the action plan from Depth-first search algorithm (20 marks)

o Correctly generate and output the action plan from the A* search algorithm (30 marks)

Solution

Introduction

In order to move a stack of discs from one peg to another in the Tower of Hanoi issue, you must adhere to certain guidelines. In this study, The learner has used state-space search methods, namely Depth-First Search (DFS) with a depth restriction and A* search algorithm, to solve the Tower of Hanoi issue. University Assignment Help, In order to solve the issue, all discs must be moved from the starting peg to the desired peg while using the intermediate peg as a buffer. The objective is to reach a condition where all of the discs are piled on the target peg in the proper sequence, and the rules indicate that only one disc may be moved at a time and that larger discs cannot be stacked on top of smaller discs.

The problem-solving strategy, including the representation of the state and state space, as well as the design of the heuristic evaluation function for the A* algorithm, will be analyzed and designed in the report.

Problem Analysis and Design

State Representation

The state representation in the Tower of Hanoi issue is essential for following the arrangement of the discs on the pegs. The current state may be accurately captured and made easier for the search engines by an appropriate state representation (Chen and Decary, 2020). The state is often represented in this situation as a list of three pegs, each containing a stack of discs. Any acceptable data structure, such as integers, can be used to represent the discs themselves. A state with five discs, for instance, can be represented as [[5, 4, 3, 2, 1], [], []], where the first peg initially has no discs and the other two pegs are originally empty. This model enables simple state modification during the

State Space Representation

All potential states that could be attained when solving the Tower of Hanoi problem are included in the state space model (Chowdhary, 2020). The state space includes all possible permutations of disc placements across the three pegs since each state reflects the arrangement of discs on the three pegs. Each state in the state space may be represented as a node in a graph, with the valid transitions between states serving as the edges. The edges of the graph reflect the legal movements that may be done to change from one state to another, and each node represents a unique configuration of discs on the pegs. The search algorithms must be successfully guided by the state space representation in order to discover the answer.

Heuristic Evaluation Function in A* Algorithm

A heuristic evaluation function is created in the A* search algorithm for the Tower of Hanoi problem to estimate the cost or distance from the current state to the destination state. The heuristic function's goal is to direct the search process by giving a reliable estimate of the remaining expense (Estevez et al., 2019). The number of discs that are still off the intended peg might be a good heuristic function in this situation. The heuristic function can prioritize states that are near the desired state and perhaps produce more effective search pathways by taking into account the number of discs still needing to be relocated. The efficiency and optimality of the A* algorithm's search phase heavily depend on how well the heuristic function performs.

Program Structure Design

Overview of the program structure, including classes, functions, and parameters

The method used to solve the Tower of Hanoi problem using DFS and A* may be organized as follows:

Classes:

For this implementation, no particular classes are needed.

Functions:

get_valid_moves(state): The method get_valid_moves(state) gives a list of all possible moves from a given state.

dfs(state, depth_limit, moves): Depth-first search with a depth limit is carried out by this function, dfs(state, depth_limit, moves). A boolean result indicating whether a solution was discovered returned together with the current state, depth limit, and list of moves (Masood and Ahmad, 2021).

astar(state): The A* search algorithm is implemented via the function astar(state). When a solution is found, it returns the solution state; otherwise, it returns None. It accepts the beginning state as input.

h(state): The A* algorithm's heuristic evaluation function. It accepts a state as an input and outputs a projected cost for the remaining expenses.
Parameters:

initial_state: A list of three pegs with discs that represent the Tower of Hanoi problem's start state.
depth_limit: The DFS algorithm's maximum depth allowance.

Explanation of the input and output requirements

To make the problem-solving process easier and deliver the required outcomes, the Tower of Hanoi program includes certain input and output criteria. The starting state of the issue, which depicts how the discs are arranged on the pegs, is one of the input requirements. The conventional representation of this starting state is a list of three pegs, each of which holds a stack of discs. The output specifications call for providing the findings and pertinent data (Pereira and Borysov, 2019). The first step is to output the state space with the dangerous states indicated, which show the situations when the game's rules are broken (for example, by piling a larger disc on top of a smaller one). This makes it possible to see the state space and makes it easier to follow the development of the search algorithms.

The Depth-First Search (DFS) algorithm's action plan, which depicts the flow of events from the starting point to the desired state, must be output by the program. Similar to this, the A* algorithm's action plan output should reflect the best possible order of steps.

Depth-First Search (DFS) Algorithm

To solve the Tower of Hanoi issue in state space, people frequently utilize the Depth-First Search (DFS) method. DFS traverses the search space as far as it can along each branch before turning around.

A depth limit can be used to construct the DFS algorithm to assure termination and prevent infinite loops. It starts in the starting state and explores neighboring states until it reaches a goal state or the depth limit.

The stages of the DFS algorithm are as follows:

Push the initial state onto an empty stack when it has been created.

The stack is not yet empty, but:

a. Select a state from the stack's top.

b. Verify that the state that sprang up is the desired state. If so, indicate success.

c. Using the get_valid_moves method, generate each valid move from the current state.

i. Apply the move to create a new state for each valid move.

ii. Add the newly created state to the stack.

Return failure if the stack runs out of space without reaching the desired state.

During the search process, it is crucial to maintain track of the states that were visited in order to prevent returning states and getting stuck in cycles.

A list of moves can be kept, and the DFS algorithm can construct the action plan from it. The transitions from the starting state to the desired state are shown in this list (Raffort et al., 2020). The series of actions that resulted in the solution may be recovered by going backward from the target state to the starting state.
A* Search Algorithm

The Tower of Hanoi issue is frequently solved using the A* search algorithm, an informed state-space search technique. It incorporates aspects of both greedy best-first search and breadth-first search. A* assesses each state based on the total route cost—the cost incurred to get there from the starting point—and a heuristic function that calculates the remaining cost to get there. It gives states with lower overall expenses priority, increasing the likelihood that it will investigate viable avenues (Rodríguez et al., 2020). A* seeks the best answer by repeatedly extending the states with the lowest cost. The efficiency and efficacy of the A* search algorithm heavily depend on how well the heuristic function performs.

Results and Output

Presentation of the state space with marked unsafe states

Figure 1: Code of the Starting state and Goal state
(Source: Generated and Acquired by the learner)

Figure 2: Output of the Starting state and Goal state
(Source: Generated and Acquired by the learner)

Display of the action plan generated by the DFS algorithm

Figure 3: Action plan generated by the DFS algorithm
(Source: Generated and Acquired by the learner)

Figure 4: Output of the Action plan generated by the DFS algorithm
(Source: Generated and Acquired by the learner)

Display of the action plan generated by the A* algorithm

Figure 5: Action plan generated by the A* algorithm
(Source: Generated and Acquired by the learner)

Figure 6: Output of the Action plan generated by the A* algorithm
(Source: Generated and Acquired by the learner)

Conclusion

Summary of the achieved results

In conclusion, the paper used state space search algorithms including Depth-First Search (DFS) and A* search to successfully solve the Tower of Hanoi issue (Tang et al., 2019). Action plans were successfully produced by the implemented algorithms from the beginning state to the objective state. The outcomes showed that DFS could locate a solution within a depth restriction and that the A* method was effective in locating the best solution. The research complied with the assignment's objectives and demonstrated how state space search techniques may be used to solve challenging issues.

Discussion on possible further improvements or extensions to the solution

Investigating different heuristic functions to increase the precision of cost predictions is one of the solution's potential future upgrades or expansions. For performance comparison, adopting different search algorithms like depth-first search with an iterative deepening or breadth-first search might be taken into consideration (Yan, 2022). Additionally, the creation of a GUI might offer an interactive visualization of the state space and movements, improving user experience and comprehension of the problem-solving procedure. The overall efficiency and effectiveness of the solution may benefit from these improvements and additions.

References

Chen, M. and Decary, M., 2020, January. Artificial intelligence in healthcare: An essential guide for health leaders. In Healthcare management forum (Vol. 33, No. 1, pp. 10-18). Sage CA: Los Angeles, CA: SAGE Publications.

Chowdhary, K.R., 2020. Fundamentals of artificial intelligence (pp. 603-649). New Delhi: Springer India.

Estevez, J., Garate, G. and Graña, M., 2019. Gentle introduction to artificial intelligence for high-school students using scratch. IEEE access, 7, pp.179027-179036.

Masood, A. and Ahmad, K., 2021. A review on emerging artificial intelligence (AI) techniques for air pollution forecasting: Fundamentals, application and performance. Journal of Cleaner Production, 322, p.129072.

Pereira, F.C. and Borysov, S.S., 2019. Machine learning fundamentals. In Mobility Patterns, Big Data and Transport Analytics (pp. 9-29). Elsevier.

Raffort, J., Adam, C., Carrier, M. and Lareyre, F., 2020. Fundamentals in artificial intelligence for vascular surgeons. Annals of vascular surgery, 65, pp.254-260.

Rodríguez-García, J.D., Moreno-León, J., Román-González, M. and Robles, G., 2020, October. Introducing artificial intelligence fundamentals with LearningML: Artificial intelligence made easy. In Eighth international conference on technological ecosystems for enhancing multiculturality (pp. 18-20).

Tang, J., Yuan, F., Shen, X., Wang, Z., Rao, M., He, Y., Sun, Y., Li, X., Zhang, W., Li, Y. and Gao, B., 2019. Bridging biological and artificial neural networks with emerging neuromorphic devices: fundamentals, progress, and challenges. Advanced Materials, 31(49), p.1902761.

Yan, Y., 2022. Machine learning Fundamentals. Machine Learning in Chemical Safety and Health: Fundamentals with Applications, pp.19-46.

Would you like to schedule a callback?
Send us a message and we will get back to you

Highlights

Earn While You Learn With Us
Confidentiality Agreement
Money Back Guarantee
Live Expert Sessions
550+ Ph.D Experts
21 Step Quality Check
100% Quality
24*7 Live Help
On Time Delivery
Plagiarism-Free

Uni Assignment Help
A+ Grade Assured

Assignment Support
Hello!
Struggling with your assignments? Get 30% OFF on your first order.

Chat with experts now!
×
Get Instant Help
University Assignment Help

Still Finding University Assignment Help? You’ve Come To The Right Place!


CAPTCHA
AU ADDRESS
81 Isla Avenue Glenroy, Mel, VIC, 3046 AU
CONTACT