CSC 361 Artificial Intelligence- Assignment Problem

Assignment Help Computer Engineering
Reference no: EM132402383

CSC 361 Artificial Intelligence, King Saud University, Saudi Arabia

The n-puzzle consists of n square tiles, labeled numerically from 1 to n. They are arranged in a random ordering within a square tray that is just large enough to hold n+1 tiles (see fig. 1, n = 15). The tiles should then be slid around the tray until they are in the correct ordering as shown in fig. 2, with the blank space at the bottom-right hand corner. The tiles must not be picked out of the tray.

In this programming assignment you are asked to find the optimal solution using A* of a n-puzzle, where n <= 128, if the n-puzzle is solvable. The solution is a set of actions (the minimum number of moves) that need to be performed in order to solve the puzzle.

1 Input

Your program takes as input a text file that represents the n-puzzle to be solved. The file below represents a 15-puzzle.

The first line of the text file is n (the size of the n-puzzle).

Starting from line 2 in the input file, each line represents one row of the n-puzzle.

The characters are separated by a blank character. The empty tile is represented by the number zero.

2 Output

Your program must display:

• The input (display the board you are going to solve).

• The Hamming distance of the input puzzle.

• The Manhattan distance of the input puzzle.

• Whether the input board is a goal or not.

• The number of inversions in the input puzzle.

• Whether the input puzzle is solvable or not.

• If solvable, display the solution and the length of the solution.

The following output is obtained for the input file described in the previous section.

3 Formula for determining solvability

Not all configurations are solvable. For example, the configuration in fig 3 is not solvable.

There is a method to check whether any given puzzle is solvable. First, consider the tiles written out in a row.

An inversion is a pair of tiles (a,b) such that a appears before b, but a > b. For example, if, in a 4 x 4 grid, number 12 is top left, then there will be 11 inversions from this tile, as numbers 1-11 come after it. For example, on the grid of fig.4, we have:

• the 12 gives us 11 inversions

• the 1 gives us none

• the 10 gives us 8 inversions

• the 2 gives us none

• the 7 gives us 4 inversions

• the 11 gives us 6 inversions

• the 4 gives us one inversion

• the 14 gives us 6

• the 5 gives us one

• the 9 gives us 3

• the 15 gives us 4

• the 8 gives us 2

• 2 from the 13

• one from the 6

So there are 49 inversions in this example. The solution state (the goal) has always zero inversions.

To know if a puzzle is solvable or not, use the following rules:

• If the grid width is odd, then the number of inversions in a solvable situation is even.

• If the grid width is even, and the blank is on an even row counting from the bottom (second-last, fourth-last etc), then the number of inversions in a solvable situation is odd.

• If the grid width is even, and the blank is on an odd row counting from the bottom (last, third-last, fifth-last etc) then the number of inversions in a solvable situation is even.

That gives us this formula for determining solvability:

((grid width odd) and (#inversions even)) or

((grid width even) and ((blank on odd row from bottom) == (#inversions even)))

4 Implementation

You need to implement the class State and the class Solver, in addition to the class Test that contains the method main and the method:
public static State readBoard(String s) throws Exception that reads a puzzle from a text file (input file described previously) and returns a State object. This method throws an exception if the format of the input file is not correct or the file does not exists.

The method public List<State> neighbors() returns a list of all neighbors of the current state. A board can have 4 neighbors maximum depending on the position of the blank tile. When generating the neighbors, use the following order for the actions:

1. move the blank tile to the previous row if possible.

2. move the blank tile to the next row if possible.

3. move the blank tile to the previous column if possible.

4. move the blank tile to the next column if possible.

5 Deliverable

You must deliver:

1. Source code (commented): class Solver, class State, class Test in addition to any other class you implemented.

2. A report containing the following sections:

(a) Introduction

(b) Problem formulation

(c) The evaluation function: explain the cost function and the heuristic used.

(d) Design: write a detailed description of how the project was designed. The description should be readable by less technical people, and at the same time helpful for more technical people. Use tables, uml and diagrams if needed.

(e) Implementation: write a detailed description of the most important implementation parts. Use code snippets if needed.

(f) Results: include some run samples with a brief discussion.

(g) Conclusion

Attachment:- Project.rar

Reference no: EM132402383

Questions Cloud

What type of reliability problem is this : What type of reliability problem is this? stability, equivalence, internal consistency, or inter-rater reliability?
Examine how kincaid short fiction girl illustrates ethos : Examine how Kincaid's short fiction "Girl" illustrates ethos namely the speaker's credibility ; is she a knowledgeable and compassionate parent?
Effectiveness of a vitamin supplementation program : Suppose a new study is interested in the effectiveness of a vitamin supplementation program at reducing resting heart rate.
H/617/0736 Business Law Assignment Problem : H/617/0736 Business Law Assignment Help and Solution - University Centre Colchester, UK. Assignment Title - Legal Solutions Handbook
CSC 361 Artificial Intelligence- Assignment Problem : CSC 361 Artificial Intelligence Assignment Help and Solutions, King Saud University, Saudi Arabia-You need to implement the class State and the class Solver.
Management leadership of organizational development : The Key to successful management leadership of organizational development in today's era of dynamic changes is thereby embedded in leader's thoughts and feeling
Building given that the crime took place on a tuesday : Find the probability that he was in the COB1 building given that the crime took place on a Tuesday.
Strategic philanthropy-locus of control and ethical culture : Pick one of the following terms for your research: Strategic philanthropy, locus of control, ethical culture, ethical awareness, or normative approach.
Check the nonskewness criteria : Check the nonskewness criteria. Is a large-sample hypothesis test about p appropriate?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd