0% found this document useful (0 votes)
114 views11 pages

Artificial Intelligence Project

This document describes an artificial intelligence project to develop an AI agent that can solve the Sokoban puzzle game using various algorithms. It introduces the Sokoban game and describes modeling it as a search problem with start and goal states. It then explains several algorithms implemented - backtracking, depth-first search, breadth-first search, uniform cost search, A* search, and the use of hashing as a pruning technique. Preliminary results found A* search with Manhattan distance heuristic had the best performance on small levels but convolutional neural networks worked better on large levels due to time constraints of other approaches.

Uploaded by

Haima Naqvi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
114 views11 pages

Artificial Intelligence Project

This document describes an artificial intelligence project to develop an AI agent that can solve the Sokoban puzzle game using various algorithms. It introduces the Sokoban game and describes modeling it as a search problem with start and goal states. It then explains several algorithms implemented - backtracking, depth-first search, breadth-first search, uniform cost search, A* search, and the use of hashing as a pruning technique. Preliminary results found A* search with Manhattan distance heuristic had the best performance on small levels but convolutional neural networks worked better on large levels due to time constraints of other approaches.

Uploaded by

Haima Naqvi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

ARTIFICIAL INTELLIGENCE PROJECT:

SOKOBAN GAME

Submit to: Miss Hameeza Ahmed

Project Members:
Midha Sohail (CS-18103)
Maham Akhlaq(CS-18083)
Zubia Naeem(CS-18010)
Syeda Haima Batool Naqvi(CS-18022)
INTRODUCTION:
Artificial Intelligence is becoming instrumental in a variety of applications. Games
serve as a good breeding ground for trying and testing these algorithms in a
sandbox with simpler constraints in comparison to real life. In this project, we aim
to develop an AI agent that can solve the classical Japanese game of Sokoban
using various algorithms and heuristics and compare their performances through
standard metrics. In this progress report, we delve deeper into the ideas
furnished is (1) pointing out the game mechanics in a straightforward manner (2)
describing the states and explaining how it is modeled in our algorithms (3)
detailing our algorithms to calculate the best moves for the levels of the game (4)
defining proper pruning techniques that are implemented to ameliorate the
performance of the algorithm (5) providing results and comparing the developed
algorithm using standard metrics of evaluation. We conclude with the next steps
we plan to take up to finish this project.

Scope:
Solving Sokoban is a NP-Hard problem, PSPACEComplete [1] and it has been an
active area of research. The branching factor of the Sokoban game is very high
and with each iteration, it has an exponential number of pushes and moves.
Therefore it needs proper heuristics that can help in eliminating redundant search
states. The backtracking algorithm limitations are evident when the size of the
puzzle is huge. Solving Sokoban has useful applications in robotics, especially
motion planning [4]. The robotic movement in a constrained space can be simpli
ed to Sokoban
1. General Game Mechanism:
Sokoban, literally referring to a warehouse keeper, was created by Hiroyuki
Imabayashi and is a cult classic. This game is a transportation puzzle where
the playing arena is composed of a grid of squares. Some of the squares are
marked as crates where the player has to push to a storage location in the
warehouse. Some of the squares are marked as walls which act as
constraints where the player as well as the crates cannot enter.
The initial state consists of a player at a certain x,y location on the grid and
certain locations marked as crates(or boxes) and target stores. The player
can move horizontally or vertically (four directions - Up, Down,Left and
Right). The player can push at most a single box into an empty space that is
not a wall or another box. The player is not allowed to pull the boxes too.
There are equal number of crates and target locations and the player
succeeds once all crates are in target storage locations. The player fails if a
crate gets locked up in a corner or with another crate with the storage
locations(or location) being unoccupied.

2. Literature Review:
From the literature study, we gather that the algorithm for solving this
highly popular transportation game is researched extensively and various
implementations have been formulated for quickly solving this problem
with better efficiency.

3. State and Modeling:


The game of sokoban can alternatively be considered as a search problem
where we essentially look out for boxes and storage locations. So
intuitively, it has a valid start state and end state. The start state is the state
given by the original game developer whereas the end state is the state
when all crates are transferred to proper storage locations. The actions can
be moving in all directions with a cost associated with it which leads to the
successor state.

Fig: Game model

4. Algorithms:
Sokoban has many unique properties which are not there in other similar
problems as Rubiks cube or Lloyd Fifteen Puzzle. Moves are irreversible so
making a bad move can make you lose the game. Given the game
mechanics, several factors are taken into account for deciding on an
optimal algorithm: (1) There is a need for returning a set of moves quickly
because the game is played real time also. Consequently, an algorithm that
is able to produce moves in a short amount of processing time and returns
a strong move is desirable. (2) The constraint added to game. Constraints in
this game refers to the walls that are present inside the outer boundary
and restrict the path of the player. (3) The depth to which the search is
constructed. Since this search problem can lead to multitudes of states and
can at times lead to infinite search depths, once concern is to know how
much the algorithm can explore in the search space.
Given these considerations, we decided to evaluate considerable number
of algorithms and compare them based on their space/time complexities.
The strength of the algorithms in this space lies in their ability to quickly
determine sequences of moves that yield relatively strong results. We have
implemented four algorithms namely backtracking, Depth First Search
(DFS), Breadth First Search (BFS) and Uniform Cost Search (UCS) and shown
their results.

 Baseline ( Backtracking Algoritm):


The baseline of the project is the backtracking search algorithm. the
backtracking algorithm is one of the simplest recursive algorithms
and forms the baseline for our project but is seldom used widely
because of its high time complexity. It just recurses to all states and
finds the minimum cost in reaching the goal. The space complexity is
O(D) and the time complexity is O(b **D) which is very high.
 Depth First Search:
Depth First Search (DFS) is a special case of backtracking search
algorithm. The search starts from the root and proceeds to the
farthest node before backtracking. The difference between this and
the backtracking is that this stops the search once a goal is reached
and does not care if it is not minimum. The space and time
complexities, on the worst case, are the same as the baseline
algorithm but stops when it finds the solution.

 Breadth First Search:


Breadth First Search (BFS), as the name says, explores the search
space in the increasing order of the depth and the costs of traveling
from one state to another is assumed to be a positive number.
Typically, this algorithm is often associated with the concept of stack
and queue and pushing and popping from the stack. Due to the
larger states explored at shorter depths, the space complexity is very
high of about O(b** d ) and the time complexity is O(b** d ).
 Uniform Cost Search:
For any search problem, Uniform Cost Search (UCS) is the better
algorithm than the previous ones. The search algorithm explores in
branches with more or less same cost. This consist of a priority queue
where the path from the root to the node is the stored element and
the depth to a particular node acts as the priority. UCS assumes all
the costs to be non negative. While the DFS algorithm gives
maximum priority to maximum depth, this gives maximum priority to
the minimum cumulative cost.
 A* Algorithm:
A* algorithm is one of the popular technique used in path finding and
graph traversals. This algorithm completely relies on heuristics for
computing the future cost of a problem. This algorithm is equivalent
to the uniform cost search with modified edge cost. This heuristics is
chosen according to the case where the algorithm is implemented,
thus emphasizing the importance of domain knowledge. This
algorithm is consistent if the modified cost is greater than zero.

 Hashing:
Hashing is a well known pruning method used to tune the algorithm
to perform better. It follows the logic that decision which leads to the
states that are already visited are considered as suboptimal. So all
the states are stored in the hash table and at each point, a
comparison is made between the current state and the stored state.
If there is a match, the same action corresponding to the one in the
hashing table is avoided.
5. Glimpse view of Sokoban:
6. CONCLUSION:
We have implemented many algorithms for developing an AI agent for
Sokoban game. We experimented with some of the pruning techniques and
observed that most of the algorithms were having similar moves in playing
the game but their performances differed in the time and the states
explored. Given a smaller dimension of level, A* algorithm with Hungarian
distance metric computed by Manhattan distance found to have better
performance than the other algorithms considered. But given a larger
dimensions of the level, all the algorithms are constrained by time and the
Convolutional Neural Network had fairly decent performance.

7. REFERENCES:
[1] Dor, Dorit, and Uri Zwick. ”SOKOBAN and other motion planning
problems.” Computational Geometry 13.4 (1999): 215-228. [2]
http://pavel.klavik.cz/projekty/solver/solver.pdf [3] Li, Zheng, et al.
”Object-oriented Sokoban solver: A serious game project for OOAD and AI
education.” Frontiers in Education Conference (FIE), 2014 IEEE. IEEE, 2014.
*4+ Taylor, Joshua, and Ian Parberry. ”Procedural generation of Sokoban
levels.” Proceedings of the International North American Conference on
Intelligent Games and Simulation. 2011

You might also like