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

Friday, May 24th, 2024

    Time Event
    12:51a
    ChatGPT translation
    Stumbled upon the following DirectX 5 example
    http://archive.gamedev.net/archive/reference/articles/article589.html

    It does some obscure shit. In particular, it inits palette to random colors
        // clear all the palette entries to RGB 0,0,0
        memset(color_palette,0,256*sizeof(PALETTEENTRY));
        
        // set all of the flags to the correct value
        for (index=0; index<256; index++)
        {
            // create the GRAY/RED/GREEN/BLUE palette, 64 shades of each
            if ((index / 64)==0)
            {
                color_palette[index].peRed = index*4;
                color_palette[index].peGreen = index*4;
                color_palette[index].peBlue = index*4;
            } // end if
            else
            if ((index / 64)==1)
                color_palette[index].peRed = (index%64)*4;
            else
            if ((index / 64)==2) 
                color_palette[index].peGreen = (index%64)*4;
            else
            if ((index / 64)==3)
                color_palette[index].peBlue = (index%64)*4;
    
            // set the no collapse flag
            color_palette[index].peFlags = PC_NOCOLLAPSE;
    
        } // end for index
    



    So I asked ChatGPT to convert it to SDL2.
    And it decided to be smart....
        for (int i = 0; i < MAX_COLORS; i++)
        {
            Set_Pal_Entry(i, (i % 64) * 4, ((i / 64) % 4) * 64, ((i / 64) % 4) * 64);
        }
    


    That was in fact the single broken part of it.
    Outside of the need to "#define SDL_MAIN_HANDLED" to suppress SDL from doing `#define main SDL_main /*happy debugging retards!*/`

    Anyway, the code is basically Etch A Sketch


    Current Mood: amused
    3:53p
    Entity Relations
    Apparently the right way to implement relations is the by creating a relation table dynamically and adding there all ids satisfying the relation:

    https://ajmmertens.medium.com/building-games-in-ecs-with-entity-relationships-657275ba2c6c

    Basically we do
      ComponentTables["[Relation] [What]"].[EntityId] != NULL


    For example
      ComponentTables["is mortal"].[Socrates] != NULL


    In SQL people usually introduce secondary keys for that.

    But yeah, that requires very efficient and adaptive hash table implementation, since we can have millions of relations, having just a few elements each. I.e. doing unordered_map<int,int> won't cut it.

    Current Music: VNV Nation - When is the Future?

    << Previous Day 2024/05/24
    [Calendar]
    Next Day >>

About LJ.Rossia.org