#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Dynamic Level Select as coordinates/links to determine level content using tables

Posts: 559Member

Hi Folks,

I have levels that dependent on various inputs from a particular table to determine content. Instead of crafting each individual level, the level instead read the table to determine those details.
Additionally, I have dynamic menus because there are a lot of levels + plus worlds whose data is saved in a different table.
Essentially what I am asking, how do I use the inputs from the dynamic menu and link them to the data table. I suppose its a series of conditions much like a search function you know: attribute X + Attribute Y + Attribute Z = Level GHF. Considering that the inputs are not uniform. For instance. In the menus I chose one option resulting in 24 different options, I choose any and depending on the option I chose I would then have from 5 to 50 other options to choose from. I chose and the same before I eventually get into the level. The implications and applications of this could instead to in game decision making resulting in multiple paths being followed and outcomes. But I'm using it for menus. HELP! Just that link point.

• Posts: 11,815Member, Sous Chef, PRO, Senior Sous-Chef
edited April 2016

To do this efficiently, you'll need to have some sort of pattern or mathematical function in mind. Without that, you have way too many options to just manually set up rules to check every possible combination. Twenty four options with 50 additional options means you have 1200 possible results (24 * 50 = 1200). Even if many of those results are the same (e.g. Level GHF), that's still too many.

I don't think we can tell you the pattern or function but if you have some kind of organization in mind, we can help you with the math behind it.

Put another way, your question is kind of like this: "If I have 24 different colored t-shirts and I want to pick one and then wear one of 50 different pants, how will I know which outfit I have on?" But if you have numbered each shirt and set of pants and you know, for example, that even numbered shirts paired with odd numbered pants are "golf" outfits, then you can code a rule that looks for that combination mathematically.

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

• Posts: 559Member

@tatiang I had been think working indexing and attributes. So everything is indexed. And lets run a scenario: Choice 1 has 2 options and selecting changes Zebra Attribute to corresponding value (x=2), Choice 2 responding to choice 1 has 24 options, I choose (y=15) and donkey attribute changes to that corresponding value, Choice 3 responding to preceding choices has 16 options (z=9). The data table has corresponding indexed value matching each and every possible outcome (GHF = 2.15.9)

An alternative scenario would be like

Choice 1 with 2 options and selecting changes Zebra Attribute to corresponding value (x=1), Choice 2 responding to choice 1 has 43 options, I choose (y=27) and donkey attribute changes to that corresponding value, Choice 3 responding to preceding choices has 108 options (z=106). The data table has corresponding indexed value matching each and every possible outcome (GHF = 1.27.108).

Whilst I can index the data table (1-->last possible result). I am struggling to create a formula that responds to varying choice sizes to create a result the datable can then match.

I have 3 attributes which change due to the preceding one. x-->y -->z (Arranged in one table) = GHF (arranged in another table)

1 (2) 1 (43) 1 (3) 1
1 (2) 1 (43) 1 (3) 2
1 (2) 1 (43) 1 (3) 3
1 (2) 1 (43) 2 (16) 1
1 (2) 1 (43) 2 (16) 2

etc as the First table with the attributes.

Does that make it any clearer? Or is this even more cumbersome and roundabout?

• Posts: 11,815Member, Sous Chef, PRO, Senior Sous-Chef

That helps me understand it better. It's going to be easier to do since you have unique results. Each combination of three attribute values corresponds to a unique GHF value.

I don't get the last series of values...

1 (2) 1 (43) 1 (3) 1
1 (2) 1 (43) 1 (3) 2
1 (2) 1 (43) 1 (3) 3
1 (2) 1 (43) 2 (16) 1
1 (2) 1 (43) 2 (16) 2

... but I think I can suggest something... give me a minute

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

• Posts: 11,815Member, Sous Chef, PRO, Senior Sous-Chef
edited April 2016

My idea would be to arrange the table according to this:

Section.Row.Column

So when you have the example GHF = 1.27.108, it would be section 1 of the table, row 27, and column 108. In that cell would be the GHF/level value.

What is a 'section'? Well, you can divide the table up into equal sets of rows that are as large as the largest number of options for the second value in your 1.27.108 example. Let's say you have one set of values that have 25 options for the second value, another with 33 options for the second value, and another with 41 options. You'd make each section of the table 41 rows long. It's fine for some sections to have blank rows at the end.

Here's an example: if the player picks 2.38.95, you would look in tableCellValue(tableName,(2-1) * 41+38,95). That "2-1" in the expression is important... you'll have to subtract one from the first value because you're starting at the bottom/end of the previous section and moving down however many rows. In this case, you start at the bottom of section 1 and move down 38 rows to row number 79 (41+38). If you were trying to find 8.16.33, you would use tableCellValue(tableName,(8-1) * 41+16,33).

I've probably confused you horribly!

Edit: this assumes only three sets of values. If you end up having more (e.g. 3.16.99.28), this won't work!

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

• Posts: 559Member

The last series of values the final choice ie. first option (2), chose and now have 43 choices, chose 1 and not have 3 choices and you chose 2. The last number is the last choice you make.

@tatiang said:
That helps me understand it better. It's going to be easier to do since you have unique results. Each combination of three attribute values corresponds to a unique GHF value.

I don't get the last series of values...

1 (2) 1 (43) 1 (3) 1
1 (2) 1 (43) 1 (3) 2
1 (2) 1 (43) 1 (3) 3
1 (2) 1 (43) 2 (16) 1
1 (2) 1 (43) 2 (16) 2

... but I think I can suggest something... give me a minute

• Posts: 559Member

Yeah! That's saying it lightly!

@tatiang said:
I've probably confused you horribly!

Edit: this assumes only three sets of values. If you end up having more (e.g. 3.16.99.28), this won't work!

• Posts: 559Member

@tatiang its only 3 values. I almost added a fourth and decided best not to. Wayyy too many results to deal with.

• Posts: 559Member

@tatiang I've finally understood you! Curious though, because I was thinking of my problem which I likened to a search function and think of this: a library has x amount of sections (geography, history etc) which have a sub category to topic (geophysics, global warming etc) and then author (McClance,S. , Jones, I. etc) leading to one specific result. or Even a bible - Testament, Book, Chapter, Bible.
Here I am using at as referral tool for decision process leading to unique attributes.
Perhaps I am building the model wrong and there is a better way?

• Posts: 11,815Member, Sous Chef, PRO, Senior Sous-Chef

With my method, you're not searching for anything. A search implies that you need to find something that matches a certain value. We're using the values more as trail signs to get to the value we want. Go this far down, this far over, ...

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

• Posts: 559Member

And if we search? I ask because right now we are limited to 3 variables. If we added more then this solution wouldn't work.
hmmm

@tatiang said:
With my method, you're not searching for anything. A search implies that you need to find something that matches a certain value. We're using the values more as trail signs to get to the value we want. Go this far down, this far over, ...

• Posts: 11,815Member, Sous Chef, PRO, Senior Sous-Chef

Searching would require a different algorithm. If you have have additional variables, you'd have to look into data structures that organize that many dimensions. I'm not sure what those would be.

If it were me, I'd start to think about whether you can represent the data in a text string as an integer value. For example, "001039116099" would represent 1.39.116.99. But then we're basically back to having to code every possible result as a separate rule, so that's not efficient.

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

• Posts: 9,913Member

Make sure you do prototypes before you do a full blown build. This type of data searches are know to be laggy. I reccomend doing a prototype build and test in ad hoc and watch the frame rates. I found it is best to break up the code blocks that do the algorithm in multiple actors, this does speed up the process.

• Posts: 559Member

As in have the rules etc. split between several actors rather than a single one? example?

@Lost_Oasis_Games said:
Make sure you do prototypes before you do a full blown build. This type of data searches are know to be laggy. I reccomend doing a prototype build and test in ad hoc and watch the frame rates. I found it is best to break up the code blocks that do the algorithm in multiple actors, this does speed up the process.

• Posts: 559Member

How about keeping them as 1.39.116.99 and searching for that? by combining x.y.z.v?

@tatiang said:
Searching would require a different algorithm. If you have have additional variables, you'd have to look into data structures that organize that many dimensions. I'm not sure what those would be.

If it were me, I'd start to think about whether you can represent the data in a text string as an integer value. For example, "001039116099" would represent 1.39.116.99. But then we're basically back to having to code every possible result as a separate rule, so that's not efficient.

• Posts: 11,815Member, Sous Chef, PRO, Senior Sous-Chef
edited April 2016

@fmakawa said:
How about keeping them as 1.39.116.99 and searching for that? by combining x.y.z.v?

I'm still not understanding why you want to search. Are you going to have a table with all possible values (e.g. 1.1.1.1, 1.1.1.2, 1.1.1.3, etc.) in one column? Are you building the data source (table) externally in Excel and then importing it in? Even then, that's a crazy number of combinations (e.g. 100 * 100 * 100 * 100 = 100,000,000 combinations).

I think you might need to simplify your game so that there aren't so many possible combinations.

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

• Posts: 559Member

@tatiang That had been my thinking. Have all of them in listed in one column. Its the only way I think I can do it if I was using more than 3 variables. I'm actually using your earlier idea about sections for my current one and I'm testing the concept for a much bigger project for later. (All my projects right now are basically a test phase for concepts I am bring together later for a much bigger project. RPG.)

• Posts: 11,815Member, Sous Chef, PRO, Senior Sous-Chef

Do you have 100 million different GHF levels?

If not, how are you determining what happens when the player chooses something like 1.16.39.105 versus something like 1.25.66.98?

Again, I'm guessing you have to automate this process somehow... to incorporate a pattern that allows you to group x.x.x.x results so that certain types of results, that is certain groupings of x.x.x.x values all point to the same GHF level value.

New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

• Posts: 559Member

@tatiang Nah! Not that many! The prototype is just a shade over 50 000 unique GHF values. Remember some choices might only give you two options, others 15 and other 72 but mostly on the lower end hence why they dont get to be so many. Its the variability of the number of choices that made it difficult. Had it been the millions I would definitely used a pattern of some sort.