[Plugin]Board, Layout2Board [Behavior] Grid Move

Post your completed addons to share with the community

Post » Tue Sep 23, 2014 10:33 am

Hi again @rexrainbow,

I've been trying to implement the board_edge plugin, and so far, for a certain configuration, it works.

However, when using squareTx's '8 direction' the edge only respects one direction. I've attached an image which demonstrates the behaviour: the player is behind a long wall, and if the target tile is behind the wall, it will try to move diagonally (because there is no edge between the diagonal tiles). If I use '4 direction' it works fine.

I've tried switching squareTx.Direction based on slg_movement's PreTile and Tile conditions, but I can't get it to work and I'm not sure if this is correct approach.

I'm still trying to play around with the switching, but you have any tricks/ideas to get around this, it would be much appreciated.

Thanks again!

best,
lernie.
You do not have the required permissions to view the files attached to this post.
B
11
S
2
Posts: 18
Reputation: 557

Post » Tue Sep 23, 2014 3:43 pm

@faulknermano

You are right, it had miss something in my board system in squareTx layout.
In squareTx's '8 direction' mode, the grid will become an octangle, although it looks like a tetragon. So that it will have 8 edges, you need put a "wall" for diagonal side, currently.

I will try to solve it. Let me think....



[Edit]
You might try to turn the direction mode to 4 direction before requesting a path in slg_movement plugin.
B
97
S
22
G
178
Posts: 4,121
Reputation: 104,049

Post » Wed Sep 24, 2014 7:46 am

Hi @rexrainbow,

Thanks for the suggestion. I've used 4 direction successfully, but I am currently trying to find a way to combine it: using 4 direction when it hits an edge, and 8 direction when no edge is involved.

I'm trying to find a logic solution, but it would be nice to get your thoughts on it because you're obviously more familiar with the moving path algorithm.

What I will attempt is this:
-request a moving path from slg_movement
-move chess accordingly
-for every GridMove On tile, determine if current tile has an edge
-if current tile has edge, switch to 4 direction
-then get rid of moving path
-request another moving path from current position to original destination

(That's just the rough idea)
(I will, of course, update if I get anything working)

Thanks again!
B
11
S
2
Posts: 18
Reputation: 557

Post » Wed Sep 24, 2014 8:23 am

@faulknermano

"using 4 direction when it hits an edge, and 8 direction when no edge is involved."

- "Condition:Has edges around chess" and set parameter direction to (-1) to check if there is any edge around TileUID.

- "Expression:NeigborUID2DIR" (new in board plugin, you need update board plugin) to get the direction from PreTileUID to TileUID.
In 4 directions, the value is 0~3, in 8 directions, the value is 0~7.

It might be -

+ NOT Edge :Has edges around chess : TileUID , dir to (-1) // no edge around TileUID
- set cost to 1

+ ELSE
+ Board.NeigborUID2DIR( PreTileUID , TileUID ) >= 4 // diagonal
- set cost to BLOCKING

+ ELSE
+ Edge :Has edge between chess ( PreTileUID , TileUID )
- set cost to BLOCKING

+ ELSE
- set cost to 1
B
97
S
22
G
178
Posts: 4,121
Reputation: 104,049

Post » Wed Sep 24, 2014 8:22 pm

Hi @rexrainbow, I've updated the latest on GitHub, but the NeighborUID2DIR expression doesn't seem to be registered in the editor (need to update edittime.js, too?). Thanks!
B
11
S
2
Posts: 18
Reputation: 557

Post » Thu Sep 25, 2014 3:27 am

@faulknermano

Yes, you need download these files. Or using this tool to update my plugins.
B
97
S
22
G
178
Posts: 4,121
Reputation: 104,049

Post » Thu Sep 25, 2014 5:02 am

Thanks @rexrainbow! Your download tool updated it, and now I can see the NeighborUID2DIR expression.

However, just so you know your GitHub repository doesn't seem to be updated; I compared the new edittime.js with the one in my GitHub directory (which I'm always synching), and NeighborUID2DIR only appears in the tool-updated one, not in GitHub.

Thanks again.
B
11
S
2
Posts: 18
Reputation: 557

Post » Thu Sep 25, 2014 5:11 am

@faulknermano

I might forget submit the code, sorry.
B
97
S
22
G
178
Posts: 4,121
Reputation: 104,049

Post » Sat Sep 27, 2014 4:32 am

@rexrainbow, thanks for your help. I finally got it working! The first few times I tried to make it work, the function became messy. But during the debugging I started to understand how slg_movement's moving path function worked, and I came up with something more straightforward, and something that I could read and maintain later.

Like you suggested, Board.NeighborUID2DIR was used to get 'check direction', used a 2-dim array to get the 'reverse direction', corner1 (left of direction), and corner2 (right of direction).

Then I made 2 checks: first check is destination Tile; if an edge exists the 'reverse direction', or any of the reverse direction 'corners', it means tile is inaccessible: movement is blocked (cost = -1).

Second check is PreTile: if edge exists in the 'check direction' of PreTile, or any of the check direction corners, then movement is blocked.

Else, default variable cost value of 1 is used.

Again, thanks for this suite of plugins you've made. Although at the beginning it was hard to use because I didn't quite understand how it worked 'under the hood', now that I have more experience with it, it is getting easier to tweak and get specific results, making it a powerful tool.
You do not have the required permissions to view the files attached to this post.
B
11
S
2
Posts: 18
Reputation: 557

Post » Sat Sep 27, 2014 5:23 am

@faulknermano

Congratulations!
Your request is too specific to implement in a simple way. It really need dig the board system more deeply, to get more information from board/edge.
For tracing, you could dump PreTileUID and TileUID to console, under "on cost" event. Anyway, I am glad that you had came up this problem.

"on cost" could be customized to do diffusing, see the demo in this post.

Have fun!
B
97
S
22
G
178
Posts: 4,121
Reputation: 104,049

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 2 guests