Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    List Implementation

    Work In Progress
    3
    7
    319
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I
      IANRASE last edited by

      Right now I'm making a first person dungeon crawler with randomly generated levels, and while working on the map generation code I really needed some list-like structures.
      Because referencing is whack right now - especially for structures - I had to make an array backed list that wasn't based on a statically declared structure.

      Anyway, it ended up being super useful so I put the code into its own file and added a few more functions to make it do all the list-y things and wrote some documentation above all the functions for usage requirements and use-case explanations.

      The lists can hold any value type, are doubly linked, and have are guaranteed to cause only moderate headaches. The code is a little gross looking because I kept changing it to add more functionality instead of planning it out, but at least it works (or at least, it passed my non exhaustive test cases. Though I did change a few small things after copying it to it's own file).

      I have it shared right now as Lists, my friend code is SW-8470-2088-7226 (LobsterLeg)
      A few notes I left out in the comments:

      • After making your list, don't directly change the first, last, size, or a fields
      • Use .size to get the number of items in the list
      • .first and .last are the indices to the first and last items, not the items themselves
      • similarly, .iter is to provide iterator-like functionality and is the index of the current item in the list the iterator is pointing at. You can copy and set the value to facilitate multiple iterators, but keep in mind that aside from the iterator functions, the iterator is changed if the item it is pointing at gets removed from the list.

      In case that doesn't work or you want to type it out yourself, I took screenshots:






      pianofire 1 Reply Last reply Reply Quote 2
      • pianofire
        pianofire Fuze Team @IANRASE last edited by

        @IANRASE That looks really interesting. I have sent a friend request

        1 Reply Last reply Reply Quote 1
        • I
          IANRASE last edited by IANRASE

          Just accepted it.
          What I really would have liked is the ability to do something like:

          struct ListItem
              var value
              var next
          endstruct
          

          The main reason I couldn't was because in FUZE you can't have indeterminate types as fields (but you can for anonymous structures), you can't have arrays of variable size (even though arrays are automatically resized when not part of a structure), you can't have structure references (aside from when they are passed as arguments), and you can't access structure fields programmatically.
          If any one of those were implemented, I could make a non array-dependent list and using them wouldn't incur as much unnecessary overhead.

          Also, is there a way to do spoilers/text folding here? Those links make the post rather long but I don't see an option for such with the post formatting icons and none of the common BB syntax's I've tried have worked.

          1 Reply Last reply Reply Quote 0
          • Martin
            Martin Fuze Team last edited by

            @IANRASE said in List Implementation:

            is there a way to do spoilers/text folding here? Those links make the post rather long but I don't see an option for such with the post formatting icons and none of the common BB syntax's I've tried have worked.

            Not that I know of, but instead of posting a wall of code screenshots, just create a post telling everyone what you have created and put your friend code in the post so anyone that's interested can make a friend request and grab it.

            pianofire 1 Reply Last reply Reply Quote 1
            • pianofire
              pianofire Fuze Team @Martin last edited by

              @Martin They have shared the code as well. It is very impressive work!

              1 Reply Last reply Reply Quote 1
              • I
                IANRASE last edited by

                Just wanted to share that I fixed an error caused by some left-over code in the shrinkList function.

                I'm also rewriting the insertion function to fix a bug that causes insertion at position 0 to not work properly in some cases. Currently I'm away from my Switch, but that will be done and shared once I get to it.

                I'm also thinking of renaming some of the variables within the functions to prevent unexpected behavior due to variables with the same name being used in global space. I didn't consider this at first because I almost always handle things within a main function and try to name my globals something like TEXTLOG or __tl, but realized it was a big issue after several index out of bounds errors within a previously working text parsing loop because I declared i as a for loop variable in global space and i was also used in the parsing for loop. This might be a bug because both loops set i to zero at the start of their loops (and the OOB error was from the function scoped loop, not the global one), however resetting it would have threw off the global loop anyway.

                1 Reply Last reply Reply Quote 1
                • I
                  IANRASE last edited by

                  I fixed all the issues and reshared the program, and because my other programs using the list functions were getting too big to scroll around, I added a condensed version of the functions - one function per line. Removing all that white space by hand was a trip, wondering every few lines if I screwed something up.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post