shortest path

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Locked
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

shortest path

Post by LuMo »

sorry to ask this here cause its not really luaplayer-specific...
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}
}
thats my map,
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
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Re: shortest path

Post by Shine »

LuMo wrote:sorry to ask this here cause its not really luaplayer-specific...
You are right, please ask this on http://www.lua.org/lua-l.html or irc://irc.freenode.net/lua , would be too much traffic at this forum, if every general Lua question is discussed.
Locked