Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

191 Neutral

About dendrite

  • Rank
  1. 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. 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. 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. 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. 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. 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. 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. 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. 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?
  10. Hi, I've been attempting to make my game more data-driven. My initial approach was to define blueprints - which are configurations of specific components - that can read data from JSON files using the serialization library Cereal. A BlueprintLoader class knows about every type of blueprint. During initialization, it loads blueprints from their respective directories into a map, 1 per blueprint. class BlueprintLoader {  using WeaponBlueprintMap = std::map<std::string, WeaponBlueprint>; // keyed by the file name  using ItemBlueprintMap = std::map<std::string, ItemBlueprint>; ...  WeaponBlueprintMap weapons;  ItemBlueprintMap items; ... more blueprint maps...   void init() {   loadItems();   loadWeapons(); ... more load calls, one for each type of blueprint... } }; An example blueprint: class WeaponBlueprint { ...    std::vector<std::string> allowedEntityTypes; // entities that can use this weapon    std::uint32_t accuracy, cooldown, damage, preparationTime; ... };   An example JSON file that the weapon class can load from:     "weapon": {         "type": "laser cannons",         "allowedEntityTypes": [             "scout"         ],         "accuracy": 95,         "cooldown": 10,         "damage": 2,         "preparationTime": 0,     }   And when loading a level from a level file:   void Level::load() {   loadItems();   loadWeapons(); ...one function call per blueprint type... }   This is becoming tedious to maintain as every new blueprint type requires its class definition, code to load the blueprint and code to instantiate instances of each blueprint in the world. 1. How can I support entirely new blueprint types to be defined through data? Blueprints are just specific grouping of components that already existing in c++ code. 2. How could inter-blueprint references be managed? For example, if an enemy blueprint e.g "level 1 boss.json" has items or weapons which are themselves blueprint types. a) All the item and weapon blueprints need to be loaded first so that this enemy can be fully constructed. An initial idea would be to create a graph data structure, then do a topological sort to find the correct loading order; not sure how I would do this in practice though. b) To construct this enemy example, the items and weapons referenced by this enemy need to have their pointers in the InInventory and UsedBy component set correctly, how could this be done?
  11. 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. 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. dendrite

    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. dendrite

    entity system implementation

    @swiftcoder: yeah, i'm pretty sure it does.
  15. dendrite

    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.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!