Hot answers tagged algorithm
6
when should i use BFS instead of Dijkstra's Method
BFS applies to unweighted graphs only. Dijksta's is just an extension of BFS to weighted graphs - Dijksta's on an unweighted graph will examine exactly the same nodes as BFS.
So, they can essentially be viewed as the same algorithm.
Or is A* an answer to all the prayers and there is no reason not ...
4
In light of your question's context, http://nodewar.com/, there are a couple specific considerations for your solution:
You have a (low) maximum angular velocity, and enough maximum torque to reach it in very short time.
Your drone and target each have velocity and external acceleration unrelated to thrust (gravitation abounds).
Your desired target changes ...
3
A similar question, with some good answers, including the apparent name of this whole subject, "motion planning":
http://stackoverflow.com/questions/2560817/2d-trajectory-planning-of-a-spaceship-with-physics
As a programmer, I like the practicality of user470365's suggestion. However, I'll take a stab at a more rigorous approach. My suggestion here computes ...
3
Bresenham's algorithm is specifically built to draw circles with fixed-point mathematics; that is, to rasterize circles. For what you're doing you're almost certainly better off with a much more abstract representation of your circular motion — that is, you want to keep track of your character's angular velocity and to simply move it with constant ...
3
Inefficient is fine if it's not using much cpu relative to other parts of your game. :) Start with the simple implementation and then go back and improve it later, only if needed.
Your pseudocode uses a queue but you don't really need the entire queue; you only need the max.
If you have lots of workers and lots of buildings, with your algorithm you may end ...
2
You might also want to take a look in other algorithms described in maximum weighted matching in bi-partite graphs.
In your case, all the people looking for the job should be placed in same group, and all the jobs should be placed in the other. Obviously there is no edge between vertices in the same group, and for person-job edge, it's weight would be equal ...
2
The simplest solution is to simply use the ratio of the two forces as the probability of success/defeat. If you want a method that does not happen instantly, simply implement this method one unit at a time, with a variable speed and output threshold.
For example, 57 vs 89 troops would mean that, for the first step, one side has a chance of 57/146 (39%) to ...
2
I think it helps to compare it side-by-side with regular Perlin noise. As explained in the Gustavson paper, Perlin noise works by assigning pseudo-random values (gradient vectors) to each corner of a square grid and then doing some interpolation for points in the interior of a grid cell. So the first step in evaluating Perlin noise is to figure out which ...
2
As suggested by the top link in my Google search (http://elo.divergentinformatics.com), you could calculate the individual changes in a players Elo rating (your R values), and then sum them up to provide the total change to apply to each player's rating.
i.e. If you have 4 players (A,B,C,D), calculate the change to A's rating (R-sub-a-sub-new) from their ...
1
When you think about soldiers sitting in trenches firing at each other with a constant fire rate, you could model it by giving each soldier an x% chance to hit and eliminate one enemy soldier per shot, and repeat until one army is defeated.
double kill_chance = 0.05; // 5% chance to kill an enemy per round
int troops_A = 57; // starting strength of army A
...
1
Do you evade in the sense of "to flee" or "to (non-)cooperatively walk around each other"?
The answer to both questions is quite easy:
1) To let A flee away from B... let move A in the direct opposite direction of B relative to A. Which means: The direction vector should be Position(B) - Position(A). You'll then need to calculate the angle from this Vector ...
1
This is not a universal solution but often if there is a word that is an anagram rather than a scramble this makes finding the original word harder. Once your brain is locked onto the original word it's hard to get that word out of your head.
i.e. decree -> recede might be harder than ecdeer -> recede.
One further point (though I'm not sure how to ...
1
I tackled this problem recently using some of these answers as a starting point. The most helpful thing to keep in mind is that boids are a sort of simple n-body simulation: each boid is a particle that exerts a force on its neighbors.
I found the Linde paper difficult to read; I suggest instead looking at S.J. Plimpton's "Fast Parallel Algorithms for ...
Only top voted, non community-wiki answers of a minimum length are eligible


