Tag Info

New answers tagged

0

To make it easier for you to switch between world coordinates and grid coordinates, you should make two functions, projectToWorld and projectToGrid. pseudo code: /** * returns the topleft position of a given grid coordinate. */ function projectToWorld(gridX, gridY) { return new Vector2(TILE_WIDTH * gridY, TILE_HEIGHT * gridY); } /** * ...


2

For the A-star algorithm you must provide a data structure that, for vey legal current position of the agent, provides the set of possible moves from that location along with the cost of making that location change. The most common means of providing such a data structure, especially for a rectangular grid, is a 2D array of lists. However for more complex ...


0

Well if you don't want to use A* for some reason, try "Dijkstra’s algorithm" or "Greedy best first search".


7

A* would work fine for this task, but since your map is small, Breadth First Search would work too, and it's even simpler than A*. These are “graph search” algorithms, which require you to tell them what the allowed moves are. They are not limited to grids. In your case you would tell it that the allowed moves from (x,y) are to (x+1,y-1), (x+1,y), and ...


0

a* will work fine. In the selection of neighbor cells consider forward, forward_up, forward_down


1

A* will certainly work for this. Linked below is an excellent tutorial on how to implement it. 1) Add the starting square (or node) to the open list. 2) Repeat the following: a) Look for the lowest F cost square on the open list. We refer to this as the current square. b) Switch it to the closed list. c) For each of the 8 squares adjacent to this ...


0

Lets say player is at origin, and you have (any convex shape should work) your inner-most hexagon defined as array vec2 shape[6]. The simplest algorithm would be: int windingsNo; //=some value const int vertexCount = 6; vec2 shape[vertexCount]; float scale = 1.f; for(int w = 0; w < windingsNo; w++) { for(int v = 0; v < vertexCount; v++) { ...


1

I'm not sure I completely understand what you are asking, as it's hard to tell what you mean by your "game style", but I will say that a path-finding algorithm is not necessarily overkill, especially if you would like your NPC's to find specific routes around obstacles. From my own experience with AI navigation, there are a couple of very popular types of ...


0

Take a look at a few of these and see if they match what you're looking for. I let attenuation = 10 for the purpose of demonstrating, but you should play around with all the numbers involved. WolframAlpha is very good at visualizing this sort of thing. Keep in mind, negative exponents probably are not what you're looking for. Inverse squares, or negative ...


0

Simply use a function like itertools like there on Python . I am not aware of the name of the same function in Java try ".http://code.google.com/p/neoitertools/" Find out all the permutations of the object called "cards"


0

R-trees and AABB-trees are two names for the same thing, so it doesn't make any sense to say one has an advantage over another.


3

Sorry everything would look nicer if latex formatting would be possible. Let's consider three gears: G1, G2 and G3. Now each gear has a given radius r1, r2 and r3. The problem is to find the angular velocity for each gear (denoted av1, av2 and av3). From a physics course we know that the tangent velocity v is proportional to the radius: v1 = av1 * r1. ...



Top 50 recent answers are included