Search Unity

reasonable approach to a sims-like game architecture using ECS ?

Discussion in 'Data Oriented Technology Stack' started by PalmGroveSoftware, Nov 23, 2018.

  1. PalmGroveSoftware

    PalmGroveSoftware

    Joined:
    Mar 24, 2014
    Posts:
    12
    Hello Unity3D community !
    From Morocco and a total beginner to all things ECS, it's been only a week so far of reading docs, scouring the web for tutorials, catching up with what is going deprecated and overall loving all the stellar work put into it from the whole team !
    The project I am trying to realise for years now was always started, delayed, rebooted, but never managed to make much progress on it, mostly because gigs to keep things going and skill a bit ( using unity since 2012 or so..), and also because combinatory explosion and OOP design ill suited for this kind of simulation with many states/subsets/objects dependencies and coupling..
    for years i've been hitting walls, and it's been only a week and I can already feel the anchor going away with the strong decoupling old C fashioned style and planning on going full steam ahead with the new pradaigm now.
    This is also the first time I use any kind of forum thread, so that's progress in itself I guess until I go full parallelism haha
    I am still not sure at all also if I start with pure ECS for the simulation side/learning phase or if an hybrid approach might be more appropriate for my current skill level, as I could use some familiar territory..but nothing set in stone yet for animation, presentation ( why is kinematica so far away ? :p ) and visible progress onscreen, but text could still do just fine.

    My main interrogation is if there is any pointers, general directions to take as to how one can go about defining all the states/actions/verbs of the sim (waking up, sitting down, drinking..) .. in OOP design patterns i've been trying to use in past prototypes, reifying things with the command pattern to aleviate the couplings issues a bit seemed to be the way to go, also used to have scriptable objects in past attempts with data of effects on sim stats, anim clips, nice animation curves for the utility mapping to sim needs all organized together with the classic unity tooling goodness..

    now i'm wondering, since even enums need an hybrid approach for example, is the tagging technique somethin appropriate in such case and make each action/verb be a pure tag component ? or make a system per 'action/state of sim'.. sorry if i am all over the place, mostly ramblings out loud in front of everybody :) but i hope even with approximative terminology and bag of ideas the main interrogation comes across.

    Loved Tic Toc Games talk pointing to nice techniques, can't wait to gulp more docs, tutorials and content, sorry if such a question is not that relevant to technical aspect of things and more on design/conceptualisation side, but having fun thinking about the problem in the new paradigm, still less of a headache compared to OOP.

    Thanks for any pointers !
     
    Last edited: Nov 23, 2018
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    9,039
    Hi, welcome to ECS and Jobs.

    Enums works for me perfectly fine in Pure ECS.

    upload_2018-11-23_19-7-19.png

    But you can map stuff in OOP or Hybrid, and execute / iterate in ECS.

    You can have initially abilities stored in enum, or even dictionary.
    Then for example mapping abilities into NativeArray and access with indexes.
    Then you can track easier, what is going on.

    You will know, that hunger is always index 3.

    In the image above, I got variables, which are initially represented by string. Then mapped and initialization to the NativeArrays.

    I was even thinking about making sims clone at some point, but I would like put some innovate characters control, for which, I didn't want spending time learning toward this direction. At least not now.

    But I hope you get the idea to rest above?
     
    PalmGroveSoftware likes this.
  3. PalmGroveSoftware

    PalmGroveSoftware

    Joined:
    Mar 24, 2014
    Posts:
    12
    Hey !
    Thanks a lot for taking the time, much appreciated indications, I guess I am still reasoning encapsulation big time...
    Speaking of strings, I was wondering how to have a component being the action and a string as display name value.. Might be the way I am leaning towards, the more i think about it, the more it makes sense to have each action being an entity created when action is evaluated/performed by AI and/or player input.. since i probably will queue them anyways.. pure enum mapping might not be enough ?
    Thanks again !
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    9,039
    In my current prototype, I mapped every name (string / enum) into equivalent integer representation. But that is mainly I am working on modding tool. So any operations works on indexes, which are equivalent of property names.
    Then for UI if you need to reference, you just get appropriate index from an array.

    Queuing tasks is just adding relevant task index to an array.
    Nothing fancy.
     
    PalmGroveSoftware likes this.
  5. PalmGroveSoftware

    PalmGroveSoftware

    Joined:
    Mar 24, 2014
    Posts:
    12
    nice !
    Thx !
     
unityunity