New answers tagged algorithm
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 ...
0
Algorithm behind targeting mechanism used by the player characters in Bionic Commando and Just Cause
The target Mechanism is based on the distance and angle between the viewing direction of the player and the direction to every object.
If the object is out of range it can't be targeted, it can'T also be targeted if the angle is too large.
You just select the object as a target which is a valid target and have the lowest angle.
I guess they just use ...
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 ...
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 ...
0
The easiest method that performs well and gives a lot of flexibility is to use a SQL database, e.g. an in-memory SQLite database.
Using such, you can trivially find all pending matches that meet some criteria, insert a pending match, and remove "stale" matches that are too old (indicating no match was found).
Define a table that has a column for your match ...
0
The simplest way to do this is with a dictionary. That provides fast access to specific keys.
So, from each player you'll generate a dictionary with the parameters he set and fill in the dictionary. When the matchmaking is required to be done, you just check if the keys from one dictionary match any existing ones in the other one. If there is no such key, ...
0
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
...
0
It's very simple example and has nothing to do with my comments (example in js)
You could spice it by giving random advantage to one side or another + other rules.
var red = 50;
var blue = 100;
while ( ( red != 0 ) && ( blue != 0 ) ) {
var result = Math.floor((Math.random()*(red+blue))+1);
if ( red < result ) {
red--;
...
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
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 ...
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 ...
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 ...
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
Many game AI implementations in that situation will choose to cheat, and give themselves full knowledge of the map, where their human opponent doesn't have that. You can then simply apply A* to the full map.
How sensible this looks for computer controlled units will depend on things like how maze like the maps are, and if the player is likely to learn the ...
17
You should use the D* algorithm, which is designed for this exact scenario. Specifically, the D* Lite implementation is the most efficient and simple variant.
9
A* is the logical choice. Your main concern is going to be with generating good navigation nodes. The nodes will tell you everything you need to know about how traversable each node is with respect to each unit.
Having size information associated with your nodes will be very helpful to you. In the above, we see a size 1 unit can use any of the nodes.
...
7
What you are looking for is Rooted Tree Isomorphism, which is a specialised version of the Graph Isomorphism, except for trees and the root node is fixed.
The explanation given in this assignment uses two properties:
Have the same number of levels (distance between root and leaf nodes)
Each level has the same number of nodes
Using these two properties, ...
3
The problem to see if two graphs are logically the same is called Graph Isomorphishm so you might want so start from there.
Note that the general Graph Isomorphism problem is in NP however for this special case there might be a shortcut, I'm not sure since it seems logical that to know the differences you have to check if they are equal.
2
Something like the following algorithm:
getNearest(Vector3f position) {
distance = MAX_VALUE
tmpDistance = MAX_VALUE
nearestObject = null
foreach objectInArray //for each object in your array
//get the distance from that object to the position you're interested in
tmpDistance = getDistance(currentObject, position)
if ...
1
you can build those kind of puzzles in 4 phases:
create a Sudoku puzzle board
choose regions
put some random operations for those regions and their respective results
try solving that puzzle yourself and check if there is any other solution for that specific puzzle. (which is not really necessary)
if by any chance you've generated a puzzle with multiple ...
Top 50 recent answers are included



