nancygold's Journal
 
[Most Recent Entries] [Calendar View] [Friends View]

Monday, April 29th, 2024

    Time Event
    12:12a
    Spell of Mastery Progress
    Still rewriting the engine.
    Earlier I've converted everything to use ECS.
    That opened a venue to fixing the general architecture.
    At the moment I'm decoupling video and audio parts from the entities.
    With ECS both are just the systems sampling entities and producing output.
    Before ECS they were highly coupled with the entity actions.
    For example, animation code had to tell when the attack animation hits.
    That led to horrible bugs and general inflexibility.
    I.e. it was impossible to break any actions.
    And animation code had to be run even for the off screen entities.
    Because otherwise these entities couldn't act.

    Beside uniformity, as an added bonus, the code became faster.
    Because only the entities really needing that get processed.
    Moreover, systems inside the same phase could run on different CPUs.
    As long as they dont write into each other systems.

    Compared to OOP, ECS guides you towards robust architectural choices.

    Of course my success with ECS is due to first re-introducing the complete OOP.
    That way I could have gradually transitioned my messy code to proper ECS.
    Untangling it component by component.

    I haven't implemented method phase yet, so it involves manually calling the systems:
    update_systems Me =
      update_custom_systems Me
      for U each(add_cover){unit_}:  add_cover U
      for U each(add_shadow){unit_}: add_shadow U
      for U each(remove_sat){unit_}: remove_sat U
      for U each(place_sat){unit_}:  place_sat U
      for U each(suffers){unit_}:   upd_suffers U
      for U each(motilize){unit_}:  motilize U
      for U each(active){unit_}:    U.do_activation
      for U each(needs_globals){unit_}: U.add_global_acts
      for U each(anm1){unit_}:      U.update_anim
      for U each(made_step){unit_}: made_step U
      for U each(anm_float){unit_}: U.reset_visl
      for U each(animate){unit_}:   U.do_animate
      for U each(randidle){unit_}:  U.rand_anim_step
      for U each(goal){unit_}:      U.break_idle
      for U each(ordered){unit_}:   U.break_idle
      for U each(members_){unit_}:  update_members U
      for U each(fade_inc){unit_}:  U.update_fade
      for U each(acting){unit_}:    update_action U
      for U each(pursued){unit_}:   update_pursued U
      for U each(actpost){unit_}:   update_actpost U
      for U each(enchng){unit_}:    update_enchng U
      for U each(fall){unit_}:      update_fall U
      for U each(sqid){unit_}:      update_sqid U
      for U each(host){unit_}:      update_hosted U
    


    Ugly but already much cleaner than when all this nonsense was buried and coupled in a spaghetti mess.

    Note that each system there converts the table to the `unit` interface. These are similar to Java or C# interfaces, in that they don't have data, only methods, allowing me to work with an entity like with an OOP object, abstracting away the tables behind it. So I don't really lose any OOP benefits, and due to Symta being bytecode language, hashtable performance loss is negligible.

    Further more, by allocating entity ids inside specific ranges it is possible to have subtypes of entities with non-hash table. For example, if ones decides to implement terrain cells as entities, one can reserve an id range for them, so pathfinder lookup will be fast enough. In fact, I did that for my terrain cells even before ECS, because a few cells needed to have expensive metadata. So using a monolithic struct for all cells was just not an option. Finally I have a solid framework instead of disjoint mess of tables.

    I think some people use ECS outside of video games or graphics. I myself use it for widgets in my voxel editor. And you can easily replace ReactJS with ECS. In general you can use ECS everywhere you have a SQL database or need a Prolog style processing. In fact, some components and systems could remain inside the database, or even across multiple servers. But the system `phases` will be different for each use case.

    For example, you can represent each row in a text file as an entity, and every character inside of it as another entity. Then each row number could be made into a separate component, and same with column number. Now you can implement programs like grep as systems over entities, and even run them in parallel in the same phase on different rows. And different phases can be seen as separate programs connected through pipes. The components can also be seen as messages, and system can consume them by clearing the table after processing everything.
    Console.println = "hello world"
    sets component println, which could be printed asynchronously. The paradigm is kinda profound.


    The weak point of ECS is that everything is inherently async. So if you want to do have everything in sync, it will be really slow, because ECS have to go through all the phases, before performing the next step. That is okay for rendering a web page, but not okay for say running a CPU emulator.

    Current Mood: amused
    12:40p
    There is no beauty in ugliness
    If we cull ugly animals, why can't we cull the ugly bald men?
    Just a few generations of bottlenecking, and every human gets good looks.
    There is absolutely no good reason for degenerate freaks to exist.
    They lower humanity's morals and make everyone depressed.
    The planet is too low on resources to afford carrying ugliness.
    And ugly people suffer living, in addition to poisoning humanity.
    It is inhumane to torture them and produce even more ugliness.

    Current Mood: contemplative
    Current Music: Baldur's Gate 2 OST - The Vulgar Monkey Tavern
    3:55p
    How Ukrainian Army Works
    https://tass.com/defense/1456129

    Ukrainian POWs open up about ruthless anti-retreat squads
    According to one of them, a platoon, which refused to fight, left, and no one ever saw them again

    MOSCOW, May 26. /TASS/. Ukrainian soldiers, who surrendered to Russian forces on May 25, revealed that the Kiev regime had barrier troops (better known as anti-retreat squads) that threatened anyone with summary execution for attempting to retreat or for low morale.

    "Our commander told us, when were on the battlefield: if you start retreating, we will shoot you, also behind you are barrier troops, which will be shooting those running away" Dmitry Tarasyuk from the 95th assault brigade of Ukraine’s Armed Forces said in a video, posted by Russia’s Defense Ministry on Thursday.

    Tarasyuk also revealed that a platoon, which refused to fight, left. "No one ever saw them again," he said.

    All soldiers, who surrendered during the fighting near Krasny Liman on May 25, gave testimony about these so-called barrier troops that punish those who do not want to fight, the Defense Ministry said.


    Current Mood: amused

    << Previous Day 2024/04/29
    [Calendar]
    Next Day >>

About LJ.Rossia.org