Upcoming SlideShare
×

# An elementary navigation simulated in Java

1,024 views

Published on

Published in: Technology, News & Politics
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
1,024
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
10
0
Likes
0
Embeds 0
No embeds

No notes for slide

### An elementary navigation simulated in Java

1. 1. An Elementary Navigation Simulated in Java Presented by Jinho D. Choi
2. 2. Artificial Intelligence <ul><li>Artificial Intelligence - A branch of computer science dealing with the simulation of intelligent behavior in computers </li></ul><ul><li>Artificially Intelligent Car - A car that can move safely without human driving </li></ul><ul><li>Simulation - An examination of a problem often not subject to direct experimentation </li></ul>
3. 3. Solving a maze <ul><li>Maze - A confusing intricate network of passages </li></ul><ul><li>Brain vs. Recursive Algorithm </li></ul><ul><li>Base part - Whether or not you reach the exit </li></ul><ul><li>Recursive part - Where to go in order to reach the exit </li></ul><ul><li>- Moving to an empty cell - Backtracking </li></ul>
4. 4. boolean solveMaze(var maze, var location) { if (reach the goal) return true; else { // moving to an empty cell if ((down-cell is empty) || (right-cell is empty) || (up-cell is empty) || (left-cell is empty)) { maze[location] = ‘X’; // mark the location   if (down-cell is empty) return solveMaze(maze, down-cell); else if (right-cell is empty) return solveMaze(maze, right-cell); else if (up-cell is empty) return solveMaze(maze, up-cell); else if (left-cell is empty) return solveMaze(maze, left-cell); } // backtracking else if ((down-cell is marked) || (right-cell is marked) || (up-cell is marked) || (left-cell is marked)) { maze[location] = ‘#’; // block the location   if (down-cell is marked) return solveMaze(maze, down-cell); else if (right-cell is marked) return solveMaze(maze, right-cell); else if (up-cell is marked) return solveMaze(maze, up-cell); else if (left-cell is marked) return solveMaze(maze, left-cell); else return false; // path does not exist } } }
5. 5. Solving a maze with the fixed entry and exit <ul><li>‘ Finding an empty cell ’ vs. ‘ Backtracking ’ </li></ul><ul><li>Right, Down direction vs. Left, Up direction </li></ul>.***... ..**.** *....** **.*.** .*.*.** ****... ******.
6. 6. boolean solveMaze(int r, int c) { if (r == MAX-1 && c == MAX-1) return true; // reaches the exit else if (maze[r+1][c]=='.') || (maze[r-1][c]=='.') || (maze[r][c+1]=='.') || (maze[r][c-1]=='.')) { maze[r][c] = '+'; // moves to an empty cell if (maze[r+1][c] == '.') r++; else if (maze[r][c+1] == '.') c++; else if (maze[r-1][c] == '.') r--; else if (maze[r][c-1] == '.') c--; } else { maze[r][c] = '-'; // backtracks if (maze[r+1][c] == '+') r++; else if (maze[r][c+1] == '+') c++; else if (maze[r-1][c] == '+') r--; else if (maze[r][c-1] == '+') c--; else return false; // no path exists } return solveMaze(r, c); } Examples 1.1
7. 7. Solving a maze with the unfixed entry and exit <ul><li>Unfixed Entry - Can be located at any cell before the program begins </li></ul><ul><li>Ordering in backtracking - Left, Up, Right, Down - Code 1.1 - Example 1.2 - Example 1.3 </li></ul>
8. 8. Finding the best path through a maze <ul><li>Priority of 4 directions - right, down, up, left - Example 1.4 </li></ul><ul><li>Permutation of 4 numbers - Code 1.2 </li></ul><ul><li>Convert numbers to directions - (0, 1, 2, 3) to (up, down right, left) - Code 1.3 </li></ul><ul><li>Count the steps - Code 1.4 </li></ul>Example 1.5
9. 9. Driving on a street I (A single car) <ul><li>Map - A representation usually on a flat surface of the whole or a part of an area </li></ul><ul><li>Speed limit , stop signs , traffic signals </li></ul>
10. 10. Speed limits <ul><li>Cruise control </li></ul><ul><li>Physics Problems </li></ul><ul><li>- Acceleration & Deceleration </li></ul><ul><li>- Rotational Energy </li></ul><ul><li>- Frictions </li></ul><ul><li>- Example 2.1 </li></ul>
11. 11. Visiting a place <ul><li>Map of ‘Jinho City’ - Coe, Eby, H Mart, and St. Lukes </li></ul><ul><li>Representations - building, null, up, right, down, and left </li></ul><ul><li>Database for places </li></ul><ul><li>Code 2.1 </li></ul><ul><li>Example 2.2 </li></ul>int iMap[][] = {{0, 0, 4, 1, 0, 0, 2, 0, 0}, {0, 1, 4, 1, 4, 2, 2, 1, 0}, {5, 5, 4, 5, 5, 5, 5, 5, 5}, {3, 3, 4, 3, 3, 3, 2, 3, 3}, {0, 5, 4, 0, 0, 0, 2, 1, 1}, {0, 3, 4, 0, 0, 0, 2, 5, 0}, {1, 1, 4, 0, 0, 0, 2, 3, 0}, {0, 0, 4, 2, 4, 1, 2, 0, 0}, {0, 0, 3, 3, 3, 3, 2, 1, 0}};
12. 12. Stop signs <ul><li>Only one object - No need for stop signs </li></ul><ul><li>Location of stop signs </li></ul><ul><li>Pause for ½ second </li></ul><ul><li>Example 2.3 </li></ul>
13. 13. Traffic signals <ul><li>Properties - Horizontal & Vertical - Take turns about 10 sec. - Sense 2 blocks before </li></ul><ul><li>Database for traffic signals - Code 2.2 </li></ul><ul><li>Synchronization - Code 2.3 </li></ul><ul><li>Example 2.4 </li></ul>
14. 14. Driving on a street II (Multiple cars) <ul><li>A good beginning for an artificial intelligent car </li></ul><ul><li>Less flexibility vs. more safety </li></ul><ul><li>Convenient for humans, beneficial for society </li></ul>
15. 15. Three moving objects <ul><li>Object 1 , Object 2 , and Object 3 </li></ul><ul><li>Database for the objects - Code 3.1 </li></ul><ul><li>Keeps the traffic signals - Code 3.2 </li></ul><ul><li>Example 3.1 </li></ul>
16. 16. Visiting a place against 3 other objects <ul><li>Chance for the intersections - Code 3.3 </li></ul><ul><li>Stop signs - Check if the street is clear - Code 3.4 </li></ul><ul><li>Example 3.2 </li></ul>
17. 17. Day and night situations <ul><li>Turn on the headlights </li></ul><ul><li>Slow down </li></ul><ul><li>Example 3.3 </li></ul>
18. 18. Appendix Blackjack Chess 4 / 4 Puzzle Elephant Spinout
19. 19. Thanks for coming to my presentation http://www.public.coe.edu/organizations/ComputerClub/