SRL Archive - Help and Support

Self-Determining TPA


NKN

2012-06-03 14:48:16

Alright,


I need to get the ferret(Circled in red), to follow the path (In Orange). To make it move, you throw fish onto the block you want it to walk to. If it goes into a hole, it moves somewhere else.
How would one get it to determine the path by itself?

Chris

2012-06-03 15:12:20

I believe Zmon's 3D engine would come in handy here :p
Its a 7x7 square, I would use the 3D engine to find out where the ferret is and where he has to go to, the blue holes are also pretty easy to find. You would need some kind of algorithm to get the path, and I dont know a lot about making that. :(
In those "Dungeoneering, possible?" threads they said the problem would be puzzles like this, I believe they are right.
Not sure if this helps you. :D

Brandon

2012-06-03 15:22:20

Dijkstra A* would work.. Any path finding algorithm would work.. Speed would be a problem probably unless you make it a plugin. Could possibly still be just as fast in Simba I would assume.

You could always get the blocks that have the blue on them and get the destination block. eliminate the blues from a Giant TPA and probably use TPA colums and rows to figure out where to throw.

Just an idea though. I'd have to program it to see if it works lol.

m34tcode

2012-06-04 14:26:43

From: Brandon
Dijkstra A* would work.. Any path finding algorithm would work.. Speed would be a problem probably unless you make it a plugin. Could possibly still be just as fast in Simba I would assume.

You could always get the blocks that have the blue on them and get the destination block. eliminate the blues from a Giant TPA and probably use TPA colums and rows to figure out where to throw.

Just an idea though. I'd have to program it to see if it works lol.


i dont see speed as a problem. all that must be done, is the program analyses the floor, and creates a 2d array, then use a bread search to find the shortest path. you now have a n array of tiles. use a fish on each of these tiles in order

Sir R. M8gic1an

2012-06-04 21:33:45

Guys, the algorithm is actually really simple (if I understood it right, as I never saw this minigame before). All you need to do is find out the lowest y for each x.


for x:= 0 to 6
for y := 0 to 6
if Position(x, y) then
Path[x] := Point(x, y)

Function Position needs to return a boolean depending on whether the spot x, y is a walkable spot.

edit: once you have this, you'll have the key points in your path. You then just need to add y points to static x positions where distance > 1 eg (3, 0) & (4, 2) will need points (3,1) and (3,2) - static x, increasing or decrease y, depending on target.

~RM

Runaway

2012-06-04 21:50:51

Wow I didn't even think about the possibility it would be that simple >.<

Although, if I'm not mistaken, wouldn't this return only the highest/lowest (depending on where you're placing the origin) walkable spot for each x? Using the picture above, the path would be:

 (1, 0), (2, 0), (3, 0), (3, 1), (3, 2), (4, 2), (5, 2), (5, 1), (6, 1), (6, 0) 

But your loop, would return:

 (1, 0), (2, 0), (3, 0), (4, 2), (5, 1), (6, 0) 

Once again, I don't know if I'm understanding this properly, I just want to understand what you're trying to do here cause it's interesting :p

EDIT: Of course, I don't see your edit before I go an post this :duh:

Brandon

2012-06-04 22:51:45

I don't believe it's that easy.. Think about it. You have to compensate for angle:

Result of Just splitting a TPA:

See how each square is a bit off as you come closer to the bottom? That's because due to perspective the size of each square changes as you come closer to the camera..

Only way to do this is to project it and make the entire thing squared then work on it and project it back. At least that's the only way I can think of :S Unless I'm thinking too hard.

How can the X or Y be static if the puzzle can be in any combination of a 8x8 square :S

Runaway

2012-06-04 23:50:35

I think what he means by static x is that when you run the loop he posted, you receive a single value for each x coordinate. But if you receive a (3, 0) and a (4, 2), you know that you also need a (3, 1) and a (3, 2) in order to get to (4, 2) without running into a non-walkable spot. By static he was only talking about keeping the x value static from (3, 0) when that occurs and increasing the y value to that of the next coordinate pair; in this case (4, 2).

As for the perspective, couldn't the 3d engine that zmon is planning to use grab a 2d version of the 7x7 grid and also get the ferrets location based on MMtoMS? The only part left would be to find the end point which looks fairly easy since it's color is fairly unique compared to the rest of the grid.

Chris

2012-06-05 04:24:15

Its also possible to have the ferret spawning at 0, 0 and the pressure pad at 6, 6 or the ferret at 6, 6 and the pressure pad at 0, 0. I would make it walk to the side of the island which makes the ferret at 0, 0. Then check if the pressure pad is east, south-east or south from the ferret and after that I would try something like Sir R Magician posted. So there will be 3 slightly different algorithms to get the path, I will try writing something when Im at my pc (through mobile atm)

xtrapsp

2012-06-05 05:02:47

From: Brandon
I don't believe it's that easy.. Think about it. You have to compensate for angle:

Result of Just splitting a TPA:

See how each square is a bit off as you come closer to the bottom? That's because due to perspective the size of each square changes as you come closer to the camera..

Only way to do this is to project it and make the entire thing squared then work on it and project it back. At least that's the only way I can think of :S Unless I'm thinking too hard.

How can the X or Y be static if the puzzle can be in any combination of a 8x8 square :S


if you project this from the minimap surely it would work would it not?

Jakkle

2012-06-05 10:30:22

I think the best thing to do is to find the tiles that you don't want the ferret to walk to (bad tiles).
After you know the bad tiles you don't want it to go to you simply click the tiles closest to the ferret (that is not a bad spot) in the direction of the end tile ?

Runaway

2012-06-05 12:07:33

From: Chris
Its also possible to have the ferret spawning at 0, 0 and the pressure pad at 6, 6 or the ferret at 6, 6 and the pressure pad at 0, 0. I would make it walk to the side of the island which makes the ferret at 0, 0. Then check if the pressure pad is east, south-east or south from the ferret and after that I would try something like Sir R Magician posted. So there will be 3 slightly different algorithms to get the path, I will try writing something when Im at my pc (through mobile atm)


Or you could just rotate the 2d array so that the ferret is at point(0, 0) or set the ferret's location as (0, 0) and work from there.

From: Jakkle
I think the best thing to do is to find the tiles that you don't want the ferret to walk to (bad tiles).
After you know the bad tiles you don't want it to go to you simply click the tiles closest to the ferret (that is not a bad spot) in the direction of the end tile ?


Hmm, I think it's easier said than done. The loop Magician posted is probably the most simple way to do it because your method would require the same thing essentially. The only difference is that his would be predetermined and yours would be determined while doing it. I'd say predetermined is the more efficient choice.

m34tcode

2012-06-07 03:11:04

all we need to do, is find the location of a tile in the 3d world, on our 2d screen. search that bounding tile box, for the blue
if it contains alot of blue, its a hole

zmon already has the 3d engine it sounds like

n3ss3s

2012-06-07 20:14:25

Wait, do you throw the fish on the blue dots or ?

NKN

2012-06-07 21:03:43

The ones without the blue dots.

m34tcode

2012-06-07 22:38:43

the goal iss to lead the ferrett to the end tile, without leading him over a hole.

John

2012-06-08 22:25:29

You Could easily get The Ferrets Position using MMToMSEx.

putonajonny

2012-06-11 12:59:01

I have a function that takes a board like this:
  B[0] := [1, 0, 0, 1, 1, 0, 1];//0 = normal spot
B[1] := [1, 0, 0, 0, 0, 0, 1];//1 = Blocked Spot
B[2] := [0, 0, 0, 1, 0, 0, 0];//2 = Start
B[3] := [0, 1, 0, 1, 0, 1, 0];//3 = End
B[4] := [1, 0, 1, 0, 0, 0, 1];
B[5] := [0, 0, 0, 0, 1, 0, 0];
B[6] := [2, 0, 0, 0, 1, 1, 3];
And then outputs a path as a TPointArray like this:
[(0, 6), (0, 5), (1, 5), (2, 5), (3, 5), (3, 4), (4, 4), (5, 4), (5, 5), (6, 5), (6, 6)]//I made it reverse the co-ordinates so they are standard x and y, this means the fist spot is actually B[6][0]

If this is what you want let me know :)

Compiled successfully in 31 ms.
47
1 0 0 1 1 0 1
1 0 0 0 0 0 1
0 0 0 1 0 0 0
0 1 0 1 0 1 0
1 0 1 0 0 0 1
0 0 0 0 1 0 0
2 0 0 0 1 1 3

[(0, 6), (0, 5), (1, 5), (2, 5), (3, 5), (3, 4), (4, 4), (5, 4), (5, 5), (6, 5), (6, 6)]

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 8 0 0
0 4 0 6 7 8 0
2 3 4 5 0 9 10
1 2 3 4 0 0 11
Successfully executed.
47 is time running, at that point it has already generated the path

Also I put some randomness in it, so sometimes it comes out as:
[(0, 6), (1, 6), (2, 6), (2, 5), (3, 5), (3, 4), (4, 4), (5, 4), (5, 5), (6, 5), (6, 6)]
[(0, 6), (1, 6), (2, 6), (3, 6), (3, 5), (3, 4), (4, 4), (5, 4), (5, 5), (6, 5), (6, 6)]
Or others…

NKN

2012-06-11 13:03:45

From: putonajonny
I have a function that takes a board like this:
  B[0] := [1, 0, 0, 1, 1, 0, 1];//0 = normal spot
B[1] := [1, 0, 0, 0, 0, 0, 1];//1 = Blocked Spot
B[2] := [0, 0, 0, 1, 0, 0, 0];//2 = Start
B[3] := [0, 1, 0, 1, 0, 1, 0];//3 = End
B[4] := [1, 0, 1, 0, 0, 0, 1];
B[5] := [0, 0, 0, 0, 1, 0, 0];
B[6] := [2, 0, 0, 0, 1, 1, 3];
And then outputs a path as a TPointArray like this:
[(0, 6), (0, 5), (1, 5), (2, 5), (3, 5), (3, 4), (4, 4), (5, 4), (5, 5), (6, 5), (6, 6)]//I made it reverse the co-ordinates so they are standard x and y, this means the fist spot is actually B[6][0]

If this is what you want let me know :)


That's what I need, but it has to get the blocked spot, start, and end spot, by itself.

putonajonny

2012-06-11 13:37:12

From: NKN
That's what I need, but it has to get the blocked spot, start, and end spot, by itself.


See my edit, and yeah, that shouldn't be too difficult, Both the ferret and blue spots have unique colours for detection, just need to detect the edges of the board, then from that work out where the squares are, then go through each square then do a colour count, the hardest bit would be orienting yourself to be able to see the whole board, if you get a good screenshot at a high angle I could try and get you some of the other functions

NKN

2012-06-11 14:45:10

I feel like the board is too big to get one shot, I tried doing it last time. :I