Jump to content

  • Log In with Google      Sign In   
  • Create Account

AnEverydayGuy

Member Since 24 Apr 2008
Offline Last Active Jul 14 2014 09:09 AM

Posts I've Made

In Topic: Prompting and Passing problem

11 July 2014 - 09:36 AM

Again, without straight up giving you the answer and trying to nudge you along the right path:

 

What is happening is you are assigning the entire list to 'script' and 'user_name' when what you want is only one element from that list (per variable). While I disagree with Lysy with the list unpacking suggestion in this situation (simply because not every element in the list is required), that is my own personal bias and it is a valid solution. I would suggest reading up on list unpacking (good to know at any rate) and lists in general.

 

More specifically, to retrieve an element from a list you must 'index' into it. Don't worry, it's very easy to do.


In Topic: Prompting and Passing problem

09 July 2014 - 03:48 PM

Without straight up giving you the answer and trying to nudge you along the right path:

 

argv is the list of arguments you give to python, in this case argv = ["m.py", "script", "user_name"]. If you were to print argv, this is what you'll see. You assign your 'script' and 'user_name' variables to argv, this means:

argv = ["m.py", "script", "user_name"]

script = ["m.py", "script", "user_name"]

user_name = ["m.py", "script", "user_name"]

 

So, when you are printing either 'script' or 'user_name', you are printing the string representation of that list.


In Topic: Calculating the polygon outline from the set of overlapping polygons

18 June 2014 - 03:17 PM

I've changed my plan of attack to more inline with Theta* pathfinding (not sure if that's an actual thing or just the name the guy came up with, http://aigamedev.com/open/tutorials/theta-star-any-angle-paths/). However, I still need to determine if two points have a 'line of sight' with each other (the entire vector is in a nav mesh, though not nessessary in the same nav mesh).

 

 Any ideas?


In Topic: Entity Component System questions/tips

11 June 2014 - 09:48 AM

I'm not actually worried about efficiency, it's simply a problem I came across and what curious as to what other's have done to remedy the situtation.

 

The reason I am implementing my own solution and not using a framework such as Artemis, is that I am learning about ES/ECS. I have a much better understanding of something when I implement it so that when I use it I know what is going on in the background; or so I can make a more informed decision between frameworks; or any number of situations that I could find myself in where that understanding could be helpful.

 

So, while I may not be worried about efficiency, this is still a 'design' decision that can have serious repercussions down the line (if this were a real framework that I were to use). As such, I'm curious to what other's that done to provide a broader understanding; after all, someone could have thought of a solution that I never would have thought of.


In Topic: Entity Component System questions/tips

10 June 2014 - 11:57 AM

More questions, yay.

 

I'm looking for a way to efficently implement 'nodes'. 'Nodes' being nodes in Ash, or Aspects in Artemis; that is to say, they are a collection of components an entiy must have for a system to affect said entity. EG: The movement system affects entities with position and velocity, so entities with those components have a 'movement' node which the movement system then effects.

 

 

 

Background:

So, my ES implementation is setup like so:

  • I have a World object that has an entity manager and a system manager.
  • The system manager keeps track of the various systems (that's about all I have right now, as I'm just starting to work on systems now).
  • My entity manager manages entities and their components. It has a hash that takes in a component name and returns a component manager. It also has another hash that takes in a component name and return's a component ID. A component manager manages its (one type of) component. Basically, it keeps it's component storage (an array) as densely packed as possible (to save memory) and translates a component ID to the actual component data structure. The end result is that entity #5 may have position #0 (which the position component manager may translate to be x=100, y=50) and velocity #8 (which the velocity manager may translate to be x=-3, y=10).

 

 

 

The problem:

I originally designed the component manager as I did to keep the array densly packed to save memory and to speed up system execution. However, system execution is now complicated because the components that belong to an entity can be spread throughout the various component arrays (as seen above). This means, as it stands, the movement system can't take velocity at index 1 and apply it to the position component at index 1 because they can belong to different entities.

 

However, I really like the space savings offered by my current implementation of my component manager. If I have 3,000 entities and each entity only has 3 components, then, on average, each array is 1,000 big rather than the more naive each array is 3,000 big (as an example, I'm just throwing out numbers).

 

 

 

My solution:

The solution I've come up with is to implement 'nodes', data structures that contain components and have a one-to-one relationship with systems. EG: The movement system requires movement nodes, that contain the position and velocity components; the render system requires render nodes, that contain position and sprite components; etc.

 

Every time an entity is created or changed (components added/removed) a 'updateNodes' function is called that will update the nodes belonging to that entity. This means if an entity has a position, it does not have a movement node (requires position and velocity); however, when the entity has a velocity component added, a movement node is created which is then used in the movement system. Likewise for velocity being removed, the movement node is removed/destroyed and is no longer affected by the movement system.

 

Components in a node are pointers. This way if a component is altered (such as by the movement system), the component data is altered and is correct for all the other nodes that use that component (such as the render node, which is used by the render system and has the updated position value).

 

The problem I have with this potential approach is that it destroys caching. No longer can systems run along an array and update components and have prefetching work (for lack of a better term), because of the indirection I am now jumping around in memory and have lost a key aspect of Entity Component Systems.

 

To get around that, I could have nodes have a copy of the data; but now I run into the problem of 'what if a system changes a node's component, it's no longer the same for the other nodes that use the same component'.

 

 

 

So, as always, I'm curious as to what other people have done.


PARTNERS