So all my algorithm will need are

2 integers

- currentx
- currenty

1 2d matrix of bools

- index[x][y]

Border is False

5x3 rectangle impassable in center

bool index[11][11] = { {false,false,false,false,false,false,false,false,false,false,false }, // row 0 {false,true,true,true,true,true,true,true,true,true,false }, // row 1 {false,true,true,true,true,true,true,true,true,true,false }, // row 2 {false,true,true,true,true,true,true,true,true,true,false }, // row 3 {false,true,true,false,false,false,false,false,true,true,false }, // row 4 {false,true,true,false,false,false,false,false,true,true,false }, // row 5 {false,true,true,false,false,false,false,false,true,true,false }, // row 6 {false,true,true,true,true,true,true,true,true,true,false }, // row 7 {false,true,true,true,true,true,true,true,true,true,false }, // row 8 {false,true,true,true,true,true,true,true,true,true,false }, // row 9 {false,false,false,false,false,false,false,false,false,false,false }, // row 0 };

Here is a graph of what it will look like

X = boolean false;

O = boolean true;

XXXXXXXXXXX //row 0 XOOOOOOOOOX //row 1 XOOOOOOOOOX //row 2 XOOOOOOOOOX //row 3 XOOXXXXXOOX //row 4 XOOXXXXXOOX //row 5 XOOXXXXXOOX //row 6 XOOOOOOOOOX //row 7 XOOOOOOOOOX //row 8 XOOOOOOOOOX //row 9 XXXXXXXXXXX //row 10[/font]

So now all we need is the initial position.

int curx = 1;

int cury = 1;

So 3 inital values are as follows

- curx
- cury
- index

I will write my algorithm in C++ notation.

//assuming you are going up. //translates well into all 4 directions. if(index[cury-1][curx]==true) { cury-=1; } else { //collision sound }

So when I implement this I think I will implement it as a function. I may create a class for map so it will be easy to create a rectangular grid.

**Edited by black_darkness, 16 December 2012 - 12:19 AM.**