Tree data structures in GameSalad

rotorrotor Member Posts: 25
edited September 2012 in Working with GS (Mac)
I'm looking at a bit of a technical challenge for a project here. Basically, the concept for the system is a pre designed structure with a limited set of branches, each node should have its own address and a reference to library index to fetch a string, additionally a node would branch to one or more branches or leafs.

I'm curious to know if anyone here has designed this type of tree data-structure in GameSalad before, and what did your system look like?

I can imagine this with paths set up wrapped in a lot up in a lot or Rules conditions. How did you access your leaf nodes? Would bitmasking be a good idea? How do you keep your system readable?

Comments

  • rotorrotor Member Posts: 25
    Thanks, uptimistik :) Np!

    Anyone else here that may have tried to set up more advanced data structures in GameSalad could share their thoughts? It would be a big help! Thanks! :D
  • ultimaultima Member, PRO Posts: 1,207
    edited September 2012
    it really depends on what your data is. i mean it certainly is possible to set-up the tree structure in tables or multiple tables. but you must define accessible.. you don't need to set-up a lot of rules but use smart formula and formatting of your data. if you are talking about what I think you are talking about

    A
    A1 A2
    A1a A2a

    where A1a and A2a A1 A2a belong to the same root. but A2 and A2a is the same branch.
    sort of things, you can also manipulate the formatting of data inside each table to achieve these sort of things. but it's kinda hard to explain how without knowing exactly what you are trying to achieve.
  • hotMagichotMagic Member, PRO Posts: 266
    ultima shares my sentiment, in that you need to know exactly what you're doing.
    My high level solution would be to make a table, and each row is one of your entries. You could have a column for parent, and multiple for children.
    Set up a rule that says if index, i is not empty, do this, if (index, i+1) is not empty, do this, etc etc. So you're basically traversing the tree and checking for children.

    I guess, in programming language, you're basically creating a class that has entries for its value, its parent, and its children.

    It won't be fast though. I'm bookmarking this because I'm interested in what you decide to do.
  • ultimaultima Member, PRO Posts: 1,207
    edited September 2012
    question hotMagic, how do you check for "not empty(or not null)" if the table contains multiple types of attributes? is it something like 1 / 0 type of thing (if it contains anything it'll return a 1)? I think it came up when I was playing around with table by accident but didn't quite remember what i did.
  • hotMagichotMagic Member, PRO Posts: 266
    I don't have my GS with here. But I suppose you need to just reference the row number in the parent fields, right? Or for readability you could name each row, if you were doing a tree of people entries, for example.

    The easiest way (especially for multiple types), is to put an empty character in every row that doesn't have a value, like 00 or *, and check for that. Or the second idea would be to have every entry have an index for how many parents, and make that another column.
    And every time you add or remove parents, you do index ++ or index --

    For Zig Zag Zombie, we have a percent complete variable that shows up on the world select screen as a meter. It scans the whole table and stops when it finds values that are below the minimum completion percentage. Which I guess is similar to the dummy character solution.
  • 3itg3itg Member, PRO Posts: 382
    What @hotMagic posted is the method I use to do something similar.
    I wanted a boolean, with no initial value. So if the question hadn't been asked, there was no answer.
    I used a table of integers, I used -1 for my initial value, 0 and 1 for my true/false.
    so now if it hits a 1, its complete.
    a 0 is attempted but not complete.
    and a -1 is never been attempted.

    Doing it like this allowed me to save on the amount of rules and actor size as well.
    When I had a special condition like an IAP or a secret in the level, I was able to just add a rule.
    Example: if the level is unlocked by IAP, you could use 2 to represent that.
    So if in your rules, you require 50% complete to move on to the next level, doing this would allow you not modify the original conditions, and program a work around so that even though a level has never been attempted, has 0% completion it can still be unlocked easily without modifying other important, tested and working rules.
Sign In or Register to comment.