You are on page 1of 20

An Efficient Classification

Scheme for Classical Maze


Problems

Under the guidance


Of
Manish k. Thakur

Submitted by :Utkarsh Sharma(10303414


M.Tech CSE
JIIT Noida

Contents
Introduction
Need

of classification
Maze problems
Existing solution approaches
Classification scheme
Proposed algorithms
Comparative analysis
Conclusion

Introduction
Maze

problems :- Commonly known as board


games

Maze

problems :- concerned by both scientific


community and non technical users.

Well

suited to test heuristic and metaheuristic


approaches.

PSO

based approaches are nowadays being


applied on to various problem domains.

Need of classification
Classification

of any problem domain makes the


task of finding the solution more easy and
efficient.

Maze

problems constitutes a wide problem


domain with a large number of problems lying in
it.

Most

of the maze problems are similar in some


characteristics with a few modifications.

No

proper taxonomy present for the maze


problems.

Maze problems
1)
2)
3)
4)
5)
6)
7)
8)
9)
10)

Knight tour
Tic Tac Toe
N-queen
Sudoku
Light up
Rat in a Maze
N- puzzle
Slither- link
Tetris
Pac-man

Classification scheme
1.

Based upon winning condition :1.


2.

2.

Based upon initial board


configuration :1.
2.

3.

Fixed
Dynamic

Empty
Filled

Based upon state of board (b/w


solution)
1.
2.

Fixed
Dynamic

Classification
Scheme(Contd..)

Based upon the above classification


scheme total of 8 classes are formed,
but not all the 8 classes exists at
present. The applicable classes are :-

1.
2.
3.
4.

Class
Class
Class
Class

A(empty, fixed , fixed)


B(filled , fixed, dynamic)
C(filled , dynamic, dynamic)
D(filled , dynamic, fixed)

Existing approaches
Ant colony based algorithm for Knights tour

Initialize the chessboard with a small amount of


pheromone on each cell, in our experiment it is
Trow,col,k=10-6.

For each cycle Evaporate pheromones

For each starting square start an ant

Select next move based on probability calculation. The


probability is calculated as Probk= (Trow, col, k ) /(Trow,col,k)j
the cell with highest probability is calculated.

Move to new square, if tour complete save it else go to


step 4.

Update the pheromone matrix based upon the tour


formed.

Contd
Backtracking based algorithm for Knights
tour
Select

the start square


Make the start square as the current square
Repeat steps 4 to 6 until current = destination
Create a list of all possible moves from this
square.
Select the next square by the warndoffs
heuristic.
Make it current square

Genetic algorithm based algorithm for light


up.
1)
2)
3)
4)
5)
6)

Generate initial population


Evaluate the fitness of each individual in the
population
Select best-ranking individuals to reproduce.
Create new generation through crossover and
mutation evaluate the individual fitness.
Until (terminating condition) repeat step (ii) to
(iv)
Return best chromosome

Ant colony based algorithm for light up


1)

For iteration from 1 to max_iteration repeat steps 2 to


9.

2)

Best =(n x m) + num(black_cells)

3)

For k=1 to num of ants repeat steps 4 to 6

4)

Sol[k]=ant(k).buildsolution()

5)

If (cost(Sol[k])==0) then print (Sol[k]); Halt

6)

If (cost(Sol[k])<best) best=cost(Sol[k])

7)

For k=1 to num_of_ants repeat steps 8 to 9

8)

If(cost(Sol[k])==best)

9)

ant(k).update pheromone()

Algorithms Proposed

1-Ant based Algorithm for Tic Tac Toe

1)

Initialization of Goal matrix, adjacency graph. Distribute some


initial pheromone on each node e.g. 0.1 and making the status as
unused.

2)

Make the first random move.

3)

According to opponents move the ant take a tour of length 3.

4)

From the tours found deposit pheromone on each edge of those


tours which lies in the winning set.

5)

The next move by the algorithm will be on the node having the
highest pheromone value.

6)

Repeat the steps 3-5 until the game wins or draw.

Algorithm proposed(contd)

ACO based Algorithm for Rat in a Maze


1) First the adjacency matrix is constructed for the graph, Define
source and destination.
2) Initialize the ant movement from the start node, with number of
ants let n, the destination for the ants is not fixed they will stop
their tour when their will be no possible move from their position.
3) Initialize the pheromone matrix.
4) Calculate the probability matrix, by the given formulae:

Prob[x][y] =Phero[x][y]*(1/adj[x][y])/ ni,j=1 (phero[i][j]*adj[i][j])


5)

The paths of all n ants are stored and the path with the end
node as the
destination node with the shortest node count
is considered as the result.

6)

The edges of the resultant path will receive the pheromone


value and as
pheromone increases the probability of
selecting this path will also increase.

Comparison For Knights


tour
Order/Technique

Execution time for


Backtracking (sec)

Execution time for


ACO (sec)

8x8

0.037 approx.

0.031 approx.

16 x 16

2.8 approx.

1.9 sec approx

24 x 24

37.19 approx.

19.5 approx.

Comparison for Rat in a


maze
Backtracking
Easy (in sec)

Difficult(in sec)

ACO
Easy (in sec)

Difficult(in sec)

8x8

30(approx)

36(approx)

30(approx)

32(approx)

16 x 16

40(approx)

49(approx)

36(approx)

38(approx)

24 x 24

55(approx)

64(approx)

50(approx)

51(approx)

Comparison for Light up


problem
Size
Time taken by ACO
Time taken by
(in sec)

Genetic algorithm (in


sec)

10 x 10

0.05 approx.

9approx.

15 x 15

5.2 approx.

20 approx.

25 x 25

20.9 approx.

120 approx.

Comparative analysis for Tic


Tac Toe
Algo.

Decision Tree Based


Draw(%)
Win(%)

ACO Based
Draw(%)
Win(%)

Level
Easy

20

80

95

Medium

30

70

92

Hard

45

55

12

82

Comparison for Sudoku


Technique

Accuracy

Avg. Time(in sec)

Simulated Annealing

0.64

40.20

Genetic algorithm

0.13

75.75

Hybrid

0.47

67.66

Comparison for N-queen

[20]

Average number of fitness function(in 10


runs)
SA
TS
GA

492.8

182.0

400.0

10

947.8

472.5

4910.0

30

2159.9

4654.5

91790.0

50

2848.6

22662.5

1759230.0

75

6091.3

81030.0

571170.0

100

7872.7

206910.0

887770.0

200

21708.2

2399940.0

2287960.0

Conclusion
After

classification the problems which come


under class A are simple routing related
problems.

the

comparative analysis proves that the ant


colony approach or swarm based approaches
can perform better for class A problems.

Backtracking

approaches are not the suitable


approach for the class B problems.

You might also like