# dendrite

Member

29

191 Neutral

• Rank
Member
1. ## Pathfinding on a 2d grid for tower defence

Wow, I really like the first solution for its elegance. I had something like your second solution, in mind, but thats harder to understand and implement right. Many thanks.
2. ## Pathfinding on a 2d grid for tower defence

I'm working on a small tower defence project. The board is a 2d grid. I used BFS to compute paths between the enemy's spawn location and its destination, so I have a list of coordinates that looks something like this: (9, 0), (8, 0), ..., (0, 0), (0, 1), (0, 2), (0, 3), (1, 3) Enemy coordinates are floating point, since I need to simulate movement across a square taking some time. The way I'm currently doing it is to compute the direction between the current square the enemy is on, and the next square on the path, then having the enemy move in that direction. For e.g, (9, 0), (8.9, 0), (8.8, 0), ... However, this doesn't work well when the enemy is turning a corner. In this case, after moving west from (9, 0) to (0.9, 0), it moves north to (0.9, 3.1), then east to (1, 3.1). I need each enemy to spend the same amount of time in each square, not make turns like this. It looks like if I can make them stay in the centre of the square, that would solve my problem. How can I do so?
3. ## AI for an active time based combat system

In the lecture, you used the example of having 6 considerations with values (1, 0.9, 0.9, 0.9, 0.9, 0.9). Original score without compensation = 0.59 Why's the value for score in the following formula 0.9? I originally thought it was the original unmodified score; my understanding is you multiply original scores to get 0.59, and plug that as value for score. ModificationFactor = 1 - (1/ number of considerations) MakeUp value = (1 - score) * ModificationFactor FinalConsiderationScore = score + (MakeUpValue * score)
4. ## AI for an active time based combat system

Wow, this sounds like an elegant, and surprisingly simple solution to my problem conceptually - thank you. How do you deal with large numbers of considerations reducing the score? That's the last piece of the puzzle for me. Is the spreadsheet available from some other link? The one in that video isn't working.
5. ## AI for an active time based combat system

Where can I find more information about the infinite axis utility system? I've watched "Building a Better Centaur AI" which references a prior lecture. I've also watched "Improving AI Decision Modeling Through Utility Theory" and "Embracing the Dark Art of Mathematical Modeling in AI", none of which mention it. Does the book talk about the "compensation factor" mentioned in the 2013 lecture?
6. ## AI for an active time based combat system

Ah, this sounds more like alpha-beta search where the utility is the happiness of the agent at some possible future state, instead of the utility computed on the changes that an action would cause to the game state, if that makes any sense.
7. ## AI for an active time based combat system

Hi, I've progressed further on the combat implementation. Currently, I have skills set up as lists of affects that can occur to each type of target. For example, "fireball" : { "preparationTime" : 10, "cooldownTime" : 5, "enemy" : { "damage" : 5, "effects" : "stun", "healthRestored" : 0 } On a healing skill, it would be "heal" : { ... "self" : { "damage" : 0, "effects" : [], "healthRestored" : 10 I'm looking to use a utility-based AI to evaluate which skills should be used. The problem is that skills can do anything, e.g damage, grant/remove effects, etc, so I've been trying to find a good utility function. An idea I tried is a linear combination, all values normalized in the range [0, 1]: utility (simplified) = danger * expectedHealing + (1 - danger) * expectedDamage This doesn't give good results. I want the utility of using healing skills to be more like a quadratic curve, and that for damaging skills to be linear. How can I combine differing curves together so that the result is still normalized? Some skills can do various things, like do damage and cause effects, so the utility from effects needs to be combined too. Is there a better way of evaluating utility in this setup?
8. ## Separating content from instance-specific data

Ah, sorry. Should have stated more explicitly what my question was. Is what i'm trying to achieve done often? All read-only access to the entity's info can just return information from the template. For instanced data, it seems like a lot of code would be required. For e.g, class Entity { TemplatePtr shared; // variables that can be changed on per instance basis PositionPtr pos = nullptr; VelocityPtr vel = nullptr; // if non-const access is required and if we don't have a copy of the component for this instance, make a copy and return it (i.e, copy on a potential write) Position getPos() { return pos = nullptr? pos = new Position(shared.getPosition()) : pos; } // and similarly for velocity // const version that returns the instance specific copy if it exists, or the shared one otherwise Position getPos() const { return pos = nullptr? shared.getPosition() : pos; } }; Is there some way involving c++ templates i could use so that i could just have 2 functions templated on the component type, a const and non-const version? I don't want to have to write 2 functions per component type.
9. ## Separating content from instance-specific data

In games, i wanted to allow the use of templates (which define the components an entity has, but instances of these templates may have different properties; e.g 2 fighters may have  position and velocity components but 2 fighters would have different values for both. They'd probably share some common traits like hull integrety, damage, etc). My first thought to instantiating these templates was cloning all the variables, but there's an alternative i'm considering. The data for entities can be divided into the following: 1. data that was defined from templates, and 2. instance specific data I'd like to only save instance-specific data as I can think of several benefits to doing so: 1. More robust save files that allow you to make changes, while allowing instanced data to persist. For example, if you change the base stats of an item and have item customizations as instanced data then updating the base stats in a future update will also preserve the customizations made. 2. Less memory usage as all instantiations of a template can share data from its template but have instance specific data So for our example, these 2 fighters would share damage and hull integrety data, while maintaining their instance-specific position and velocity component data. Anyone has ideas on how i could implement something like this?

11. ## AI for an active time based combat system

Thanks for the suggestions and the link to the presentation; will check them out once I get a few hours of spare time. I've not heard of utility-based AI before this topic, so will need to learn about what those do as well.
12. ## AI for an active time based combat system

Hi, I'm currently programming the AI for enemies. The game uses an active-time based combat system; so combatants usually don't get an equal number of turns (like final fantasy). Each action that can be taken in combat has a preparation time, and a cooldown which determines when that entity gets to go again after it acts. The following types of skills can be used in combat: offensive direct damage skills, skills that cause targets to be affected by positive or negative effects, and healig skills. I'd like the AI to be able to do the following: 1. Attack intelligently; it should assess the threat posed by various player units and/or choose a target such that its attack does the most damage. However, I also need to be able to assign value to certain player targets so that more important targets can override the usual decision. There are also some skills that require prerequisite skills to be used first; so it needs to know how to use these skills, and somehow decide between lower damage attacks that requires no preparation or these more riskier attacks. 2. Use effects intelligently. 3. heal intelligently. Some allies may be more important than others, so it needs to assess the value of its allies. 4. Do all this while also factoring the length of time that various actions take.   How would I go about doing this? I've been reading up on tools used in AI like state machines, and behaviour trees, but i'm not sure how to apply them to this specific situation.
13. ## entity system implementation

@phil_t: the objects were part of the component itself. As Servant of the Lord pointed out, copying the raw memory being used (essentially a memcpy) to store the components wouldn't work because the constructors of the components objects wouldn't be called, as well as having other downsides. Not being able to iterate over components was the primary problem for me. Eventually, I managed to figure out how variadic templates and boost.type_index could be used to do what I described.
14. ## entity system implementation

@swiftcoder: yeah, i'm pretty sure it does.
15. ## entity system implementation

@Servant: the ECS i'm using doesn't require components to inherit from a base class. My systems currently don't cache components, and asks for what it needs from the ECS. so for e.g every tick, for (auto& e : entities.has_components<Position, Velocity>())  // do stuff   I'm not too concerned with the speed of the save function, but i'm concerned with maintaining it. This is the if statement I want to avoid writing manually, if at all possible:   if (entity.has_component<C1>()) // mark c1 as being present else if (entity.hasComponent<C2>()) ... else if (entity.hasComponent<Cn>()) // mark Cn as being present   The API of entityx doesn't allow me to assign arbitrary ids to components. It only allows creating an entity, then assigning components to it. Hence why I need to determine for each component type, whether it is present and if so, save it and adding it back when loading.