Excal's Recent Forum Activity

  • I've fixed the pathfinder object jumps.

    Now the third AI program seems to always skip a square even though none of the others do (and they all use the same movement function).

    <img src="http://i.imgur.com/3Lfz5cM.png" border="0" />

    If anyone can take a look, that would be great.

    I'm getting very close to turning this into a playable prototype!

  • I've never experienced this before.

    I am using two pathfinding objects in my application - one which pathfinds from the computer object to the closest player object, 'tagging' squares along the way. The second one starts at the furthest tagged square and moves to the computer object, creating a 'movement list' along the way. The computer object them moves according to this movement list.

    I'm seeing weird things happen - the pathfinder object seems to ignore several solids and sometimes even jump.

    The .capx has a lot of events, but very few of the events deal with pathfinding (and most of the crucial stuff like cell size is assigned in the editor anyway). You should be able to see what I mean by running the .capx once or twice (be sure the Gameplay layout is selected before you run it!).

    BoardGame.capx

  • The beta releases have this thing called a debugger. It has sped up my development progress significantly, and I don't see any reason not to download it.

  • Here's another update. The AI is slowly coming along, but it's not complete. However, this is significant progress, at least to me anyway.

    <img src="http://i.imgur.com/QKmEdB6.png" border="0" />

    The 'default behavior' is mostly implemented, but it only works for a single AI program. During the computer's turn, the AI will pathfind to the nearest player target, then pathfind again to find a series of moves, then move accordingly. At the end of the movement, attack highlighting occurs, which is what you see in the picture.

    The .capx is mostly commented, but a lot of it is very complex and potentially confusing. I apologize to anyone who might be using it for reference at the moment - I will clean up the events and try to optimize some of the tasks once I am completely finished with the AI behavior.

  • vee41, so now I'm using two different pathfinding objects. One pathfinds to the target, the other starts from the highlighted square closest to the target and pathfinds back to the active object, adding each space's UID to a string as it passes along its way.

    The issue now is that the UID being passed to the string is passed multiple times for each square (since the pathfinding object overlaps each square more than once each second).

    Any idea how to do this? The relevant code can be found here:

    <img src="http://i.imgur.com/BEbo5WN.png" border="0">

    I tried to account for it by doing left(str, 3) not equal space.UID, but that doesn't actually seem to work.

    By the way, if you fire up the .capx and add the local static variable 'dirs' to inspect/watch, it's pretty cool to see it update in realtime during the computer's turn. You'll also see what I mean by the same UID being stored in the string repeatedly ;)

    BoardGame.capx

    UPDATE: Nevermind, I think I got it!

  • My program currently uses 2 different systems:

    The first is pathfinding, which 'tags' squares the pathfinding object moves through. The idea is to then select the farthest tagged object and backtrack to the original program.

    The second is simply selecting the highlighted square that is closest to the target (in the case of a pathfinding path not found) and backtrack to the original program.

    The backtracking is important to determine how the program should move.

    Unless, of course, you are suggesting that I also use pathfinding as a method of backtracking, which could work as well. I was just thinking the highlight function itself could somehow assign directions.

  • vee41

    <img src="http://i.imgur.com/xK2P3fJ.png" border="0" />

    Apparently what I'm doing to determine direction isn't working. The backtracing is working, but since directions are being recorded wrong, it creates a sort of infinite loop.

    So now my question is, is there any way to use your highlighting function to determine the direction the object should move? I'm using the key:

    1 = left

    2 = right

    3 = up

    4 = down

    This is what I tried, but it doesn't always store the direction properly:

    <img src="http://i.imgur.com/NhvAB8N.png" border="0" />

    Any idea on how to record direction?

  • Wait, I think I understand what you mean now. In the log it shows the function only being called once when the other recursive functions are called multiple times.

    So it should be called more than once, and it's not. Is that what you mean?

    UPDATE: It's working now! The direction list is now updated so the computer program should know the exact sequence of squares to move!

    <img src="http://i.imgur.com/QJGDceT.png" border="0" />

    UPDATE 2: It turns out I'm going to have to use some sort of pathfinding for this. The problem is that using the nearest highlighted square might cause the computer to run toward an edge or area where no squares exist, and that's not what I want.

    Darn...

    UPDATE 3: I guess it's not so bad. There's some weird inconsistencies like when pathfinding fails to find a path even though there are paths available (the cell size I'm using is smaller than the widths of the actual paths). In the case of pathfinding not working, I just resort to the previous 'use nearest square' method. Now to get my AI programs moving...

    <img src="http://i.imgur.com/mkrQSes.png" border="0" />

  • The comparison?

    The BoardSpaces condition?

  • The functions that trigger a console warning are the player highlighting function, computer highlighting function, and building a direction list.

    One thing about all three functions - they are recursive and call themselves until 'stop conditions' are met. However, they appear to be working perfectly, even if Chrome gives me a warning.

    As to the actual issue of the local static text 'dirs' always equaling "", I think I'm going to just make it global and see if the scope change solves the issue.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Here is a quick debug 101 for problems like this, or how I would approach finding out what is wrong.

    First, add log messages. This way you can easily see what is happening during runtime (the debugger has tool that can do similar stuff, but I am a bit old school). These log messages are displayed in browsers log and tell you what exactly is going on in your variables.

    <img src="https://dl.dropboxusercontent.com/u/19921470/debug2.PNG" border="0" />

    I assume you mean debugger breakpoints? I have no idea how to set those, as I assumed they would be under the System object but couldn't find any breakpoint events :(

    Here is the output:

    <img src="https://dl.dropboxusercontent.com/u/19921470/debug.PNG" border="0" />

    This suggests your problem is related to the second comparison in the event.

    Another thing: It seems you use separate functions (copy pasted?) for AI and player movement. It's generally bad practice to copy paste same code to two places, and you should look for a way to use same functions for AI and player programs if they do the same thing.

    Yes, I use separate functions for AI and player movement. The main reasoning is that the player movement function checks for different things than the computer movement one. The computer movement function also has more parameters due to the AI needing more instructions for movement and targeting, etc.

    UPDATE: No idea why there is an error with the function call. Both functions appear to be working perfectly for highlighting movement.

    And also; commenting your events is very, very useful when you come back to your project after two week vacation or show it off to people in the forums :P. I generally write short comment above every function about what it should do, what do the input variables mean and describe any return variables. At least for me this is a must, that way I don't have to spend anytime wondering what these events do :)

    Almost everything in the project is commented. Some of the newer stuff that I'm trying to debug isn't, but I usually add comments once things are fixed up.

  • I've done some more testing with the debugger. The problem isn't the backtracking - that part should be working. However, for some odd reason my string isn't being updated properly.

    <img src="http://i.imgur.com/b5paFcp.png" border="0">

    My dirs variable is a local static text.

    The PathToDestination function is only called once due to a 'trigger once' clause. Any idea why my string is always empty?

    BoardGame.capx

Excal's avatar

Excal

Member since 9 Mar, 2013

Twitter
Excal has 1 followers

Connect with Excal

Trophy Case

  • 11-Year Club
  • Coach One of your tutorials has over 1,000 readers
  • Email Verified

Progress

13/44
How to earn trophies