BUT
what i am trying to do, is find the shortest way though an array from enemy to player (simple Ai)
got it working in java...
tried to convert it to lua, but i get errors all over
would be great if someone is willed to help me
(i publish the source for sure afterwards)
sample of what i try:
Code: Select all
Map= {
{8,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0},
{2,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1},
{0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9}
}
enemy (Ai) = 9 (pos 17/17)
player = 8 (pos 1/1)
enemy has to walk from 17/17 to 1/1 with the shortest way
the java-code solves the problem just fine (2 classes)
code can be viewed/downloaded here(bottom 3 files):
have a look here