Tag Info

New answers tagged

0

There isn't necessarily a reason to have all these action classes you are defining but instead have a component that represents specific state about a certain use case. So your movement component has a series of booleans that indicate forward, backward, left, right, etc. Now each game tick, you have system that inspects all movement components and sees ...


0

Okay, through some trial and error, I've come up with a system that works. The ai chooses a target node, then uses this method: public Point Next() { Point r = new Point(0,0); float weight = float.MaxValue; Point o = new Point(loc.X + 1, loc.Y); float heuristic = Heuristic(targetNode.Position, o); float distance = ...


0

Often times your ai is the result of several components working together, not just one master ai piece of code. The solution you are after can be achieved in this manner. As already mentioned you can give your creatures states so that they know what their current task is, roaming, rushing, standing ground, retreating, etc. Next you can add pathfinding. This ...


0

You should be able to accomplish this with "creature" states. Roaming Attacking Retreating Defending On each "turn" you evaluate what the state of each creature should be and handle their movement accordingly. For example, if the current state is "Roaming" and the engine evaluates that an enemy is now in front, the state is changed to "Attacking" and a ...


3

There is an approximation for the traveling salesman that will fit your needs very good. It is Cristofides algorithm. Here is how it works: From your current position calculate a minimum spanning tree to the food items. Stop the calculation when the tree will contain 30 food. Calculate a hamiltonian path from the tree by appending non-visited elements when ...


1

"Each food item gives 10 food. How can I find the shortest path that will allow me to collect 30 food", so you need to collect 3 food items. This is small enough that you shouldn't need to give up optimality. Compute shortest paths and distances from the starting location to each food location, between each pair of food locations, and from each food ...


6

The solution is easy implemented but very very computionally heavy - I would not be suprised if this was NP-complete problem, similar to the travelling salesman. The solution has two steps: compute distance between all points (food locations and your location), you can do that with Floyd-Warshall algorithm in n^3 complexity from then, you need to find the ...


1

I'd do this with some kind of behavior tree solution - you path to the goal, and take note of all the obstacles that has been blocking your A*. If you fail, you check if there are objects that can help overcome those obstacles, in that case, path to that object. Repeat. This means that the agent needs to try to path to the goal and fail before getting the ...


0

The approach I have taken in the past was to separate the behavior and the AI aspects into two systems much as you described. On the behavior side, you have a series of predefined aspects that can be chained together into a behavior tree like patrol, attack, threat detection, etc. The behavior tree describes how these behaviors interact, which has ...


2

This is my experience from implementing a MTG AI. If the AI is not considered from the start, adding it later can be challenging. Your engine needs a way to copy the game state. It also needs a way to to quickly undo a move, so search tree can be generated efficiently. Every AI thread should operate on its own copy of the game. When computer makes a move ...


3

Your pathfinding should return a list of way points to reach your objective for each unit. Since you are making a turn based game, I am assuming that the unit movement is like a chess piece. It is either on "this" tile or "that tile, and not in between. If this is the case you might end up with the scenario where a units movements runs out in the middle of ...


3

I see basically two ways you could solve this, but in both cases you'll need to utilize my SharpCraft project, which is a C# powerered way of injecting functionality into Warcraft III made by me, with research from a bunch of other people. Do note that the readme is outdated, but I'll do my best to help you out with the current release. Use JASS This way ...



Top 50 recent answers are included