Path finding in a highly dynamic world - artificial-intelligence

I am working on a simple soccer simulation, I am using potential fields for collision avoidance more specifically following technique,
http://www.ibm.com/developerworks/java/library/j-antigrav/
only obstacles on the field are other players and they are constantly moving. Problem is it works if I assign really big push force to the characters since characters move at speed it takes some time to change direction but this has few drawbacks with such a high gravity I can never position an npc to grab the ball cause there is always some force pushing me around.
I though I could solve this by assigning pulling force to the ball but that actually made it worse. nps would go to the ball, ball starts pulling which makes npc push the ball it goes into a loop until npc crashes to a wall.
How I've implemented this is, I have a vector that would steer me towards my target then I add to that all gravitational forces acting on the npc and steer towards that direction.
Basically I am wondering what kind of improvements I can make? my current problem is not hitting other players precisely getting behind a ball without getting affected by other players.

I'm not sure that employing potential fields is the way to go here. If all players are directly between you and the ball, how do you get to it?
I'd be tempted to plot a straight line, then iteratively adjust the route for the position of other players, adjusting for their trajectories and — if you're really clever — anticipating changes in the same.

You could put some kind of limit as to the area of effect that another player's gravity well will have. Limit it to a small radius around that player so that when you're clear of other players, there are no forces acting on your character. You could also diminish the collision avoidance force when you're near the ball, reasoning that players care less about not hitting each other when it's time to kick the ball.

Related

How are continuous streams of projectiles created in programming? [Say: Gaming]

I'm creating a side-scroller video game for my final project in my grade 12 programming class. Right now I have nice delta-timer my partner made for me, a flying ship, asteroids, and a scrolling background. I've added a few basic things such as collision detection between asteroids and the ship, and ship movement. Now, my next steps are implementing random enemy spawns, and projectiles (laser beams :D) from both ships. Implementing random enemy spawns should fun and relatively easy, however I'm struggling with figuring out how I will create so many bullets that will fit on the screen. I need bullets from the enemy, and the ship (player controlled).
How can I achieve this? I know there are probably many answers to this question, but I would really like to see the types of approaches people have to this problem.
So far I have thought that:
a) I could make the game have a (say) 200 bullets max on the screen
b) I could make a dynamic array (I believe this term means the array gets bigger or smaller), that way I don't limit the amount of possible projectiles
...and then I'm afraid that all these bullets will cause lag from all the collision processing that will happen.
Please shed some light on this, and help guide me along the path to an efficient; well executed; side-scroller game.
Thanks,
Guest dude

Create GO like AI - maybe with minimax algorithm?

So I'm trying to make a game that's similar to the game GO. Essentially I've got a grid of faces, and when you click on a face they turn your respective color (red and blue). You and your opponent take turns clicking on faces to color them your respective color. When any amount of faces are surrounded by faces that are of all the same color, then all the faces that are surrounded are deleted from the board, and the number deleted is added as score to the player whose color surrounded. And if you tap a face twice with the same color (so red face is tapped by red again) then it bursts leaving residue around that face's surrounding faces making it so those residued faces can't have their color change to the other color that's not the residue color.Now my hope is that I could get a slightly working AI, it doesn't have to be amazing or anything, just good enough to make decently intelligent moves and could possibly win. After doing some research it seems that using a MiniMax algorithm would be my best bet, but I have no clue how to create such a thing in unity. I was hoping someone might have some insight on how to accomplish this, or does anyone have a better idea of an algorithm that would be better in determining moves?
Thanks for the help!
This is horribly broad question, however - one of the most succesful approaches to the board games AI (especially GO) is UCT based approach. It is a monte carlo driven heuristic approximation of the minmax algorithm. MinMax requires game's state space to be very small in order to fit in both memory and time constraints. UCT on the other hand can make reasonable moves in any given amount of time (it is fully iterative).

Record cursor movement

This is more of a conceptual/implementation question, rather than a specific language problem.
Does anybody have any insight into cursor movement recording?
It's very easy to get a cursor's current position, but how would you go about recording the path followed by the cursor?
(To the degree of detail where it could be plotted graphically without ambiguity as to the path taken)
I imagine you could record the cursor's current position repeatedly after a small duration, logging it all to make a list of chronologically visited coordinates,
but I'm not sure how frequent (or feasible) the recording should take place; every 10 ms?
I've not even encountered a method of sleeping for such short durations to the nescessary precision!
I'm concerned also about the performance of the sleeping and recording during intense CPU usage; when the user is using the mouse to interact with intensive software.
I'm not even entirely sure where the cursor is really moving.
If I sweep my cursor across the screen, has the computer (somewhere internally) acknowledged that I crossed all those pixels,
or has my mouse really told it "I was there, now I'm over here, now I'm there".
I do also seek a method of differentiating between fast and slow movement, but for now, I can just observe the plot spacing on a graph of the visited coordinates.
Does anybody have any insight into this?
Any potential pitfalls; are my concerns legitimate?
Am I going the wrong way about this?
(As is observable, I really need some guidance in the matter)
Thanks!
It's far easier to log the mouse movements within the same application - just log something on every WM_MOUSEMOVE message. You will get a message periodically updating the mouse pointer location. You will not get a WM_MOUSEMOVE message for every pixel the mouse crosses, but it will jump depending on how fast you move the mouse and how busy the system is.
Logging mouse movements in some other application is going to be slightly more involved. If you have written both the logger and the application being logged, then you can handle WM_MOUSEMOVE in the application being logged, and send a corresponding message to your logger application. Your choice of IPC; a simple SendMessage() might be sufficient.
Logging mouse movements across the whole system is a totally different problem. You may have to hook in at somewhere closer to the driver level.
I just thought of another approach - the CBT (Computer-Based Training) hooks are designed to provide exactly this sort of information across applications. I've never used these though, so you'll have to do more investigation.

How can I manipulate a RagDoll made with farseer physics in Silverlight?

I made a ragdoll similar to the one in this demo. This rag doll will be used for a turn based rpg game where the physics will be used for animations such as character taking damage, dying, falling down, etc.
What I am pondering at the moment is as how should go about this, should I stick the rag doll by the head to the background (leaving the body dangling) and basically throw around its body parts around as to simulate punching etc (as shown in Fig 1), or stiffen the joints and statically rotate and move the body parts for the actions taken(as shown in Fig 2), and when it comes to the character dying(or a similar action) just loosen the joints and let the rag doll fall down. Or is there a better way to go about doing this?
I am new to farseer physics and don't even know if what I mentioned is even possible or overwhelmingly hard to do.
Illustration http://img3.imageshack.us/img3/8681/charactermovementrg5.jpg
Please note that the red line in the figures represents the character's arm
Not sure that ragdolls are the way to go here, if you want animations. But if you do want to use them, I'd lock the feet to the floor and have some rotation springs in the joints so that when no forces are applied, the body stands upright. Then if it gets a hit, it'll kind of bend over, but should rebound to it's stand-up state afterwards (you may have to help it along the way back, e.g. apply some forces/torques until it's back where you want it).
For animations, such as the character punching, you could perhaps apply a spring joint (I think that's the name). Connect it to the fist and the destination, and the arm should automatically move there. You could do the same with a kick, just release the lock on that foot. However, I think it might be hard to get it to look right. On the other hand, it would look unique to other games, even though it might look kinda funny.
If you're skilled, you might wanna create an animation editor and save an animation as a sequence of forces and torques that need to be applied to limbs in order to get them to where and when they should be.
I think a better approach is to have an animated sprite played, rather than going through joint manipulation .
Maybe you can use some RotateTransform implementations to articulate arms and legs.
For sure animated sprites are the best, and painless, way of doing this.

Best approach to animate physics in Silverlight?

I am new to Silverlight and want to animate a ball that is shot out of a cannon then moves through the air under the laws of physics (so roughly, on an elliptical path).
My inclination is to use a callback timer and move the little ball every 50ms by changing its Canvas.LeftProperty and Canvas.TopProperty values. Is this the right approach or should I be using a DoubleAnimation? My resistance to using animations here is that I would have to create many different animation in succession.
Which path would a Silverlight guru take?
Have a look at a question I asked some time ago here the accepted answer gives a comparison of five different ways to do animation for games in silverlight linking to this blog. The article concludes that the method you choose will depend on a number of factors.
To answer you question I personally would use the dispatcher timer which is fired each time the screen re-draws and set the properties then to move the X and Y.
I also found Game Physics 101 a really good resource.
Might be a little overkill bit are you aware of the physics helper libraray
I don't think you would have to create several animations in succession. The ball only changes direction once.
The Y value goes down (making the ball look like it's going up) and then goes up (making the ball look like it's going down). The deceleration as it's going down should be constant (something representing 9.8 m/s/s) and the acceleration as the Y value goes up (cannonball goes down) is constant, until it hits the point representing the ground.
The X value should be constant, or else decelerate slightly should air resistance be taken into account.
Therefore, you would work out the following:
Where does it start (the cannon,
obviously)
Where does the ball hit it's vertical peak
Where does the ball hit the ground
So now you can animate the Y value as a start value, and end value and one waypoint.
And you can animate the X value with just a start and an end.
Of course, it's going to involve non-trivial mathematics to determine the exact numbers to enter into the AccelerationRatio, DecelerationRatio, SpeedRatio, Duration, From and To parameters. But you would have to work that out no matter what method you're using.

Resources