Creating AI using Table Collision
Yo!
I have been working on this the last couple days, haven't been able to make a fully working version, and ran out of ideas.
The basic idea:
Using the table collision detection system proposed by Utopian (you guys are great), I want to create an AI actor that will detect if it can no longer proceed on its path. If it collides, it randomly chooses to rotate left or right, and continues checking its position. If its open, it moves. If its blocked, it checks the next position.
I was able to make it sort of work, except that it would sometimes confuse its location and actually occupy a spot that it shouldn't be able to occupy. (In testing, i ignored the random aspect). Essentially, I had my actor check its next occupiable space, and if it was false, it would rotate 90 degrees, and check again. It would travel around my map pretty well, except occasionally the checking would get choked up, and it'd start doing square shaped movements through walls.
Any insights would be greatly appreciated!
I have been working on this the last couple days, haven't been able to make a fully working version, and ran out of ideas.
The basic idea:
Using the table collision detection system proposed by Utopian (you guys are great), I want to create an AI actor that will detect if it can no longer proceed on its path. If it collides, it randomly chooses to rotate left or right, and continues checking its position. If its open, it moves. If its blocked, it checks the next position.
I was able to make it sort of work, except that it would sometimes confuse its location and actually occupy a spot that it shouldn't be able to occupy. (In testing, i ignored the random aspect). Essentially, I had my actor check its next occupiable space, and if it was false, it would rotate 90 degrees, and check again. It would travel around my map pretty well, except occasionally the checking would get choked up, and it'd start doing square shaped movements through walls.
Any insights would be greatly appreciated!
Comments
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
PlayerX and PlayerY are actually the row and column numbers not the pixel positions of the block. I set a bunch of booleans for possible movement (game.West+0, game.North+0, etc.) but there is probably a cleaner way to do that.
So for example, if the block is at a certain location (row, column) and the table looks like this:
1 0 1
1 0 1
0 0 1
Then the block (which is always the center 0 location) can go up/north or left/west.
I didn't use rotation.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
By the way, I really appreciate this help.
Edit: I'm just now seeing the image block. Did you just add that?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I'm trying to set mine up as an AI. At the very least, the first tip about checking all directions was immensely helpful.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I'm curious, where do you get 8 directions? I would think 3D (incorporating the z axis) would only have 6? For mine, there is no cross directional (no SE, NW). THough I'm still having a hell of a time coming up with the logic.
In bomberman, or pacman, or whatever, the enemy follows the maze and turns when it has to. My problem is when more than one direction is open... If two directions are open, I don't want the baddie to get stuck in a loop. However, as I'm typing this, I realize Pacman may actually be a searchable topic, with possible templates out there.
1 2 3
4 B 5
6 7 8
With the numbers being possible directions and the B being the block, I can move one of eight directions, NW N NE W E SW S or SE. (In my game, you're limited to N, W, E, or S, so four directions). If I replace the numbers with boolean values (1 or 0), it looks something like this:
1 0 1
1 B 0
1 1 1
In that case, I can move N or E.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Things to still do:
1) Smooth movement: because the table and the directional sense utilize a grid pattern, smooth movements don't seem to work. I've tried move, acc, interp using both self.position and next.position (the whole number associated with grid). For now, its grid movement.
2) Now that I have made it so the enemy can never be stopped, I'm going to try to enter logic that'll allow it to change directions at intersections, even if it isn't stopped.
@tatiang You've been a big help, as the multi directional sensing is a huge part of this. Want me to package this up and send you a copy?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I'll be sending a dropbox link to your pm here in a minute. Again, thanks for the help!
Though my game is moving the whole grid instead of the actor. I just dumb the actor in the middle of the maze and setup 4 limits in 4 direction that are contrained to the next possible grid in the four direction so i can only move if limit is false in that particular direction.