Ht3313461349

304 views

Published on

International Journal of Engineering Research and Applications (IJERA) is an open access online peer reviewed international journal that publishes research and review articles in the fields of Computer Science, Neural Networks, Electrical Engineering, Software Engineering, Information Technology, Mechanical Engineering, Chemical Engineering, Plastic Engineering, Food Technology, Textile Engineering, Nano Technology & science, Power Electronics, Electronics & Communication Engineering, Computational mathematics, Image processing, Civil Engineering, Structural Engineering, Environmental Engineering, VLSI Testing & Low Power VLSI Design etc.

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
304
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Ht3313461349

  1. 1. Vishal Kesri, Manoj Kumar Mishra / International Journal of Engineering Research andApplications (IJERA) ISSN: 2248-9622 www.ijera.comVol. 3, Issue 3, May-Jun 2013, pp. 1346-13491346 | P a g eA new approach to solve n-queens problem based on seriesVishal Kesri, Manoj Kumar MishraSchool of Computer Engineering KIIT University, IndiaAbstractThe N-queens problem is a popularclassic puzzle where numbers of queen were to beplaced on an n x n matrix such that no queen canattack any other queen. The Branching Factorgrows in a roughly linear way, which is animportant consideration for the researchers.However, many researchers have cited the issueswith help of artificial intelligence search patternssay DFS, BFS and backtracking algorithms. Theproposed algorithm is able to compute oneunique solution in polynomial time when chessboard size is greater than 7. This algorithm isbased on 8 different series. For each series adifferent approach is taken to place the queen ona given chess board.General Terms: N-Queen, Knight move, NP-hard.Keywords: Analyzer, Move, Rule, Partz.I. INTRODUCTIONThe n-queens problem is proposed for thefirst time in 1850 by Carl Gauss. It is to determine aplacement of n queens on an n × n chessboard, suchthat no two queens can attack each other [3]. Thisproblem falls in a special class of problems wellknown as NP hard, whose solution cannot be foundout in polynomial time. Let’s consider the 8-queenproblem, which is computationally very expensivesince the total number of possible arrangementsqueen is 64! / (56! x 8!) ~ 4.4 x 109and the totalnumber of possible solutions are 92 [1]. But thereexists only 12 unique solutions. There are somesolutions that are to be the same and can be obtainedone from the other by taking rotations or symmetry.The n-queen problem follows the same rules as in 8-queen problem with N queens and an n x nchessboard. Current knowledge of total number ofsolutions of n-queens problem can be viewed fromthe Table 1.A. ApplicationsThe N-queen problem can be applied inmany different areas, like parallel memory storageschemes, VLSI testing, traffic control and deadlockprevention. It is also applicable to find solutions ofthose problems which require permutations liketravelling salesman problem [1].N: Unique Solution Distinct Solution1 1 12 0 03 0 04 1 25 2 106 1 47 6 408 12 929 46 35210 92 72411 341 268012 1787 1420013 9233 7371214 45752 365596Table 1: The number of total and unique solutionsfor theN-Queens problemII. N-QUEENS PROBLEM DEFINATIONThe n-queens Problem of size n, whereneed to place n queen into n × n chessboard, so thatno two queen can attack each other that is no two ofthem are on the same row, column, or diagonal.Therefore the rules to obtain the solution of n-queens problem are follows [5]:1. Only one queen can placed in each row2. Only one queen can placed in each column3. At any time maximum one queen can be in thediagonal.Suppose two queen are placed at position (i, j) and(k, l). Then they are on the same diagonal only ifA. NotationHere some notations are defined, which areused in the propose algorithm .These notations aredefined in table 2.Symbols DefinitionS1 Positive Integer Series-A1S2 Positive Integer Series-A2S3 Positive Integer Series-A3S4 Positive Integer Series-A4
  2. 2. Vishal Kesri, Manoj Kumar Mishra / International Journal of Engineering Research andApplications (IJERA) ISSN: 2248-9622 www.ijera.comVol. 3, Issue 3, May-Jun 2013, pp. 1346-13491347 | P a g eS5 Positive Integer Series-A5S6 Positive Integer Series-A6S7 Positive Integer Series-A7S8 Positive Integer Series-A8R1 Rule-1, used to get the solution.R2 Rule-2, used to get the solution.MV1 It is first move function, whichdefines the pattern of placing thequeens.MV2 It is second move function, whichdefines the pattern of placing thequeens.MV3 It is third move function, whichdefines the pattern of placing thequeens.‘n’ Given number of queen (Input Size)‘Cij’ Cell position of the chess board.Table-2: List of SymbolsIII. SERIESThe Proposed algorithm is a combinationof two rules and eight distinct series. These seriesare given below:A. Series- A1The Series- A1 is used to get the solution such that:B. Series- A2The Series- A2 is used to get the solution such that:C. Series- A3The Series- A3 is used to get the solution suchthat:D. Series- A4The Series- A4 is used to get the solution such that:E. Series- A5The Series- A6 is used to get the solution suchthat:F. Series- A6The Series- A6 is used to get the solution such that:G. Series- A7The Series- A7 is used to get the solution suchthat:H. Series- A8The Series- A8 is used to get the solution suchthat:IV. RULESThere are two Rules, which is used with aparticular series to achieve a solution for a givenchess board. Some series do not need any of therules, such as Series-A.Analyzer: The core of these rules is an analyzerfunction. The function of the analyzer is describedas below.Step-1: initialize the cell ‘Cij’ of chess board to zero,except where, ‘Cij’ already acquired by a queen.0 Q 0 0 00 0 0 0 Q0 0 0 0 00 0 0 0 00 0 Q 0 0Figure-1: Put Zero in remaining ‘Cij’Step-2: In the beginning take any queen and add ‘1’to the value of its attacking cells. Then this step isrepeated for each queen as shown in figure 2.1 Q 3 2 22 2 3 2 Q2 3 3 3 21 2 2 2 31 2 Q 1 2Figure-2: The value of each ‘Cij’ after step 2The ‘Cij’ values shown in the figure 2 indicates thatthe position Cij is attacked by that many queens e.g.‘C23’ has an integer value 3, that means this cell isattacked by 3 different queens e.g. by C12 ,C25 ,C53.
  3. 3. Vishal Kesri, Manoj Kumar Mishra / International Journal of Engineering Research andApplications (IJERA) ISSN: 2248-9622 www.ijera.comVol. 3, Issue 3, May-Jun 2013, pp. 1346-13491348 | P a g eFirst Rule: First rule is applied to find thesolution lies in the series S2 from the solution of S1.Algorithm of First Rule is described below:Algorithm for “Rule”Step-1: If the solution falls in any one of the series(S1, S3)Step-2: Increase the dimension of the chess board byone, that is row +1 and column +1Step-4: Call Analyzer function with this updateddimensionsStep-5: Place a queen, where “Cij= =0”Algorithm-1: Describe Steps of first RuleSecond Rule: Second rule is applied to find thesolution lies in the series S6 from the solution of S5.The conditions for the second rule is “remove thequeen from Cij If Cin = = C1j = = 1 and |i-1| ≠ |n-j|.And place queens at the positions C1j and Cin.Algorithm of second Rule is described below:Algorithm of Second RuleStep-1: If the solution falls in any one of theseries (S5)Step-2: Increase the dimension of the chessboard by one, that is row +1 and column +1Step-3: Call Analyzer function with thisupdated dimensionsStep-4: Remove Queen from CijStep-5: Call Analyzer function with thisupdated dimensionsStep-6: Place queen, where “Cij= =0”Algorithm-2: Describe Steps of second RuleTable 3 show which series those rules apply:S1 S2 S3 S4 S5 S6 S7 S8R1        R2        Table-3V. Move FunctionMV function shows us the pattern ofplacing queen on chess board. There is three MoveFunctions defined namely MV1, MV2 and MV3. Themove function along with a particular series definesthe placement of queens on the chess board. Thealgorithm for placing queen according to pattern isdescribed below:Move-1: This function increases the row value ofthe chess board by 3 and reduces the column valueby 1. Algorithm-3 for MV1 is given below.Algorithm for “MV1”/* The Place of first queen depend on series *//* i = row value */Cij Place First Queenfora=1 to a ≤ ni = i+3;j = j-1;Cij Place Queena = i;Algorithm-3: Algorithm for MV1 functionMove-2: This function increases the row value ofthe chess board by 2 and reduces the column valueby 1. Algorithm-4 for MV2 is given below.Algorithm for “MV2”/* The Place of first queen depend on series *//* i = row value */Cij Place First Queenfora=1 to a ≤ ni = i+2;j = j-1;Cij Place Queena = i;Algorithm-4: Algorithm for MV2 functionMove-3: This function decreases the row value ofthe chess board by 2 and increase column value by 3or decrease column value by 1. Algorithm-5 forMV3 is given below.Algorithm for “MV3”/* The Place of first queen depend on series *//* i = row value, j = Column */count = 0;Cij Place First Queenfora=n to a ≥ 1i = i-2;if (count % 2 =0 )j = j+3;elsej = j-1;Cij Place Queena = i;Algorithm-5: Algorithm for MV3 function
  4. 4. Vishal Kesri, Manoj Kumar Mishra / International Journal of Engineering Research andApplications (IJERA) ISSN: 2248-9622 www.ijera.comVol. 3, Issue 3, May-Jun 2013, pp. 1346-13491349 | P a g eTable-4 shows, which move function is applied onwhat series.S1 S2 S3 S4 S5 S6 S7 S8MV1        MV2        MV3        Table-4Algorithm for n-queensThe proposed algorithm finds a uniquesolution of n-queens problem, which is describedbelow:Algorithm to solve n-queens ProblemStep1:Step2: If{Call “MV1”, where i = 1 && j = n/3Call “MV1”, where i = 2 && j = (n/3) *2Call “MV1”, where i = 3 && j = n}Step3: If{Get the solution of “n-1” chess board/* n-1 chess board ∈ S1 */Apply ‘R1’}Step4: If{Call “MV1”, where i = 2 && j = (n-1)/3Call “MV1”, where i = 1 && j = (n-1/3)*2+1Call “MV1”, where i = 3 && j = n}Step5: If{Get the solution of “n-1” chess board/* n-1 chess board ∈ S3 */Apply ‘R1’}Step6: If{Call “MV2”, where i = 1 && j = n/2Call “MV3”, where i = n && j = (n/2) + 2}Step7: If{Call “MV2”, where i = 2 && j = (n-1)/2Call “MV3”, where i = n && j = (n-1)/2 +2Apply ‘R2’}Step8: If{Call “MV2”, where i = 1 && j = (n/2) + 1Call “MV3”, where i = n && j = (n/2) + 3Place Queen At Cij, Where i = 2 && j = 1}Step9: If{Call “MV2”, where i = 1 && j = (n-1) /2+2Call “MV3”, where i = n && j = (n-1) /2) + 4Place Queen At Cij, Where i = 1 && j = 1Place Queen At Cij, Where i = 3 && j = 2}Algorithm-6: Algorithm for Calculate Solution ofN-QueenVI. DISADVANTAGEThe proposed algorithm provides only oneunique solution when chess board size is greaterthan 7 and the algorithm is not able to provide allthe solutions. By Rotation of chess board we can getfew more solutions but those solutions are notdistinct.VII. CONCLUSION AND FUTUREWORKThis Algorithm provides only one uniquesolution for n > 7. This method can be enhanced infuture to find all other solutions.REFERENCES[1] V. Kesri, Va. Kesri and P. Ku. Pattnaik.“An Unique Solution for N queen Problem”.International Journal of ComputerApplications.Vol:43 Issue:12 pp: 1-6, 2012.[2] Gutiérrez-Naranjo, Miguel A., Martínez –del - Amor Miguel A. , Pérez-HurtadoIgnacio, and Pérez-Jiménez Mario J. February02, 2009. “Solving the N-Queens Puzzle withP Systems”, 7th Brainstorming Week onMembrane Computing, volume 1, pp199-210.[3] Letavec, C. and Ruggiero, J. 2002. “The n-queen problem”, Informs Transaction onEducation, volume 2 number 3, May 2002.[4] Uninformed Search Analysis of the N-queensProblem, Ben Sauerwine, September 20,2003. Available at:http://www.andrew.cmu.edu/user/bsauerwi/research/P1.pdf[5] Russell, S. and Norvig, P. “ArtificialIntelligence A Modern Approach”, SecondEdition, pp 139-140.[6] Ellis Horowitz, Sartaj Sahni, SanguthevarRajasekaran, “Fundamental of computerAlgorithm (pp 339)”.[7] S.Ahmadi V. Kesri, and Va. Kesri.“Clustering in backtracking for solution of N-queen Problem”. Third InternationalConference on Contemporary Issues inComputer and Information Sciences CICIS2012

×