Вы находитесь на странице: 1из 3

CS 404 - Articial Intelligence - Assignment 1 Solving Bloxorz using A* Search

G okhan ALCAN - 12079 November 2, 2012

Bloxorz is a game where the goal is to drop a 1 x 2 x 1 block through a hole in the middle of a board without falling off its edges. This block is represented as S or SS in the text version of map. If it is S, it means that block is vertical, if it is SS it means that block is horizantal. For the rst part, text le is took into an array with their exact coordinates as m x n matrix and their values suchs as X,0 or S. After that the points which have X values are marked as unreachable (their access became false). Then the main dict is created according to these avaiable points. 3 main property is thaught to add main dict such as 1- for each avaiable point, add it as a node with two same point like P-0-0P-0-0 (Block is on 0,0 point vertically) 2- for each avaiable point and its right point add it as a node with two different point like P-0-0-P-0-1 (Block is horizontal between 0,0 and 0,1) 3- for each avaiable point and its below point add it as a node with two different point like P-0-0-P-1-0 (Block is horizontal between 0,0 and 1,0) For each case blocks right and below neighbors are checked only, because it will create an UndirectedGraph, so it became complete. Additionally, for rst case (such as P-0-0-P-0-0) its location is specied as its own coordinates x,y, for second case (such as P-0-0-P-0-1) its location is specied as x, y+1 because its two node is on the same row and nally for the third case (such as P-0-0-P-1-0) its location is specied as x+1, y because its two node is on the same coloumn. Maybe one unsolved bug can be that two points are added to dict in increasing order such as P-0-0-0-1 exist but P-0-1-P-0-0 does not. In several trials it did not create any problem but in and Undirectioan Graph would it create such a problem I could not see. It exist as a possible bug. But a solved bug is that it was needed to 1

do a change in class Graph. It was made according to preconditioned dicts but we use a text le not a constant dict, it should vary according to tet le map. Thus to test it we needed to change the get function such as links = self.dict.setdefault(a[0], ) is modied and its parameters became simply (a, ). After all of these, I actually get a simple Undirectional Graph with specic locations and obviously problem is converted to a simple search problem. Thus naturally gave me a chance to apply sample Graph problem (e.g. romania graph) to my problem. In Graph Problem heuristic function was simple hypotenuse of two points but our actions are changing. Sometimes block goes by two somestimes just one. Just because of this, in some cases heuristic value h became equal to real cost g, which can not be accepted to sustain addmissibilty. To solve this, experimentally classical heuristic function (hypotenuse solution) is multiplied by 2/3 and it is reached that h is always less than real cost g. It became admissible. Experiments of heuristic function: Now lets think that we consider this case: SOOO SOOO OOXO For this case our blocks location in location dictionary will be (1,0) as explained before and goal is (2,2). Simple hypotenuse of these two points is nearly 2,23 thus h=2,23 and as it is obvious its real cost g = 3, which seems addmissible because h is less than g. Actually when initial and goal points are close to each other this is valid but what about when they are apart from each other. Lets see this gure: SOOO OOOO OOOO OOOX For this case our blocks location in location dictionary will be (0,0) and goal is (3,3). Simple hypotenuse of these two points is nearly 4,24 thus h = 4,24 and its real solution may be this way [P-0-1-P-0-2], [P-0-3-P-0-3], [P-1-3-P-2-3] and nally [P-3-3-P-3-3]. As it is obvious that g = 4. h is higher than g which can not be accepted. For higher distance h becomes higher than g as well. Thus, experimentally heuristic funtion is detected as (2/3)*hypotenuse of initial and goal points. For this example h = 4,24*(2/3) which is nearly h=2,86. h is less than g. This proportion made my heuristic function admissible. I have tried my program for several maps to detect any bug or mistake. Here are some of my maps, some of them are taken from real game and some of them are just made up. 2

Stage - 1 OOOXXXXXXX OOOOOOXXXX OOOSOOOOOX XOOSOOOOOO XXXXXOOGOO XXXXXXOOOX Stage - 3 XXXXXXOOOOOOOXX OOOOXXOOOXXOOXX OOOOOOOOOXXOOOO OSOOXXXXXXXOOGO OOOOXXXXXXXOOOO XXXXXXXXXXXXOOO Stage - 4 XXXXXXXXXXXXXXX XSOOOOOOOOOOOOX XOOOOOOOOOOOOOX XOOOOOOOOOOOOOX XXXXXXXXXXXXOOO XXXXXXXXXXXXXXO XXXXXXXXXXXXXXO XXXXXXXXXXXXOOO OOOOOOOOOOOOOOO GOOOOOOOOOOOOOO OOOOOOOOOOOOOOO

Вам также может понравиться