Counting a sequence - assistance needed
Hello all,
Is there anyway to shorten this situation.
Five numbers are presented,each from a different attribute, for example,
1,1,1,4,6
Is there an equation that will count how many "first number" appear in a row.
From the above example, the first number is 1 and the count would be 3.
However if the numbers were,
3,3,4,3,3
The first number would be 3 and the count would be 2, because there is only one three after the initial 3.
Currently to do this I had rules, if second number is equal to first number,
- change count to 2
- Add new rule nested if third number is equal to first number then change count to 3
- And so on and so on.
This works all fine and dandy until I add in a "Wild Number". Which can be any number it needs to be.
Example:
1,W,1,1,7 = 4 count
W,W,5,6,W = 3 count.
This is where my issue remains. Should I be giving it a numerical value, such as 100. I tried having a rule that a wild will change its value to the first number of the sequence. But ran into issues when a Wild was first. Because then the second. Umber would be comparing it self to a wild, rather than a normal number.
This making sense? Any directions I should be taking, more information needed?
Thanks
Comments
I would probably take the loop behavior and do it that way. Set the condition of the loop so that it continues to loop until the value doesn't equal the first number in your rows. Each iteration, change an attribute(the one in your loop condition) to +1 and plug it into a table cell Value to check the next row. You'll also want to add +1 to an attribute that holds the total count.
Hopefully that makes sense.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
@Braydon_SFX I have been working with that for a few hours now. It's all every easy until you start with a wild. Or have 3 Wilds in a row in the first 3 positions.
I am trying having two loops, one to determine what the starting number is when there are wilds, and one when there isn't any wilds.
This is currently only semi working, it sometimes gives me a count plus one more than it should, or it works fine.
Could you clarify the wilds a bit. You say it can be any number it needs to be, but your examples seem inconsistent. Why is the second example a 3 count, when the wilds could combine with the 5 or the 6 (presumably the 5 as it's first) to make a four count?
You say each number is an attribute - are you needing to perform any kind of maths on them, or are you using strings to accommodate the wilds?
Additionally, are the numbers strictly 1-9?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
@Armelline Hi, be happy to clarify,
The count stands for the number of the same numbers in a row starting from left to right.
With the example you mentioned,
W,W,5,6,W. Can be re stated as:
5,5,5,6,W = 3 fives in a row.
The 6 stops there from being anymore and therefore the last Wild becomes useless.
Do I need to post some diagrams, or is it starting to make some sense. I might be able to make a video explaining if it still doesn't make sense.
As for the 1-9 question. That's a complicated issue. The answer is yes and no. Wilds only work on the numbers 1-9, however the numbers can range from 1-12. (This is on the bases that a wild is classified as the number 10 when reared to tables).
Hi @CodeCell I've sorted a way that doesn't need a loop, (or a table); see if this will work for you:
-- your way of putting your 5 numbers into 5 integer attributes, I've called them PosA, PosB, etc.
Not sure how you've done your wildcard number but here's my version (attribute integer Rand):
etc., up to PosE
Display Text: scene.Count
Integer attribute called Count with value of 1
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
@gyroscope , makes sense, I will give it a go after I finish watching the last episode of Game of Thrones.
I actually not understanding the first bit though the rest I do. Why am I changing the attribute W to random(1-9)?
A wild is to act as an extra number. Is that's what happening there? Or is it changing the Wild to a random number despite what the next number is in the sequence?
I misunderstood what you're doing with the wild number, I see - I thought you meant you have 5 numbers, then one of those numbers could be replace with a "wild" number that's random too...
OK, you'll need Rand for the position, but then your wild number is just what it is, without any random? Then just ignore the line Change Attribute W to random(1,9)
Hope the rest works out for you; can't see why it shouldn't...
As for Game of Thrones, I tweeted not long ago something along the lines of: The Popular Culture Police are going to arrest me soon - the charge? Not watching even one second of Games Of Thrones.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
@gyroscope well, not really sure I want to be using your answer now . I was introduced to it about a month ago by some mates at Uni. I never heard of it before. I was "converted".
As for the answer, I think I am back in the same situation. I can easily get a count for any sequence providing the first number isn't a Wild. Either by loops or rules like you provided.
However when I get this:
W,W,2,3,4
The Wilds don't know what value they are and there for can not do a count. I can use a rule that, if wilds are represented by the value 10,
If first number is equal to 10, add a count, but now I run the problem that the 2 won't know it's now the main number. Then there is issues when this occurs:
W, 2, W, 2, W
But it seems I am one step closer.
Have not looked at what @gyroscope said yet, so this may be a moot question, but can you clarify this. I've got a system working checking 5 attributes with wildcards no problem, but that's working on the assumption that a wildcard can be equivalent to any number.
If you want to have numbers from 1-12 + wildcards and the wildcards only acting as equivalent to numbers 1-9, it complicates matters a little. Can a 10 be present as well as wildcard? Or are the options essentially 1-9, wildcard, 11-12?
On a side note I found this week's Game of Thrones very underwhelming.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
@Armlline
Sorry for such a confusion. So here we go.
For me to use tables each "variable" had to have a number to represent it. They are as followed.
1 = 1,
2 = 2,
3 = 3,
4 = 4,
5 = 5,
6 = 6,
7 = 7,
8 = 8,
9 = 9,
10 = Wild (any number from 1-9),
11 = Blank number (can not be counted, can not be part of any sequence order),
12 = Blank Number 2 (can not be counted, can not be part of any sequence order)
Therefore the below is what would be the output
10,2,2,12,2 = Wild, 2,2,Blank, 2. = 3 counts of the number 2.
Does this help?
Do you do any maths with them? And would you rather use 10 as a number if you could, or is the number 10 of no use to you?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
@Armilline I am sure if theres another way, number etc that's fine. The 10 is to represent it, so when a number is picked randomly, i can choose a number from 1-12, and there is a chance a wild (10) will be picked to be displayed. Since i am using integers, everything is represented by a number.
Not sure i quite understand the question, but as far as i know now in the stage of development i am with the game, i don't do any maths with the wilds expect to get a count value of another value, or a count value of itself if there happens to be 5 Wilds in a row.
Okay, so just confirm:
e.g.
11,W,1,9,4 = 1
W,W,W,11,4 = 1
1,W,W,W,12 = 4
12,12,12,W,12 = 3
My question about the 10 was really because I wondering why 12 or 0 wouldn't be the wild card, it seemed strange that a number in the middle of the list would be chosen. But it doesn't really make any difference at the end of the day.
And I asked about the maths to know if string functions would be available for use, or if they strictly needed to be integers.
Will see about editing my test project to take into account the 11 and 12.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
@Armelline Yes, thats it.
A Wild can be represented by a 0 if it makes it easier. Which it probably would.
I been playing around and keep hitting a dead end using loops. or even just the one loop. I get plus 1 too many counts, or minus one counts. About to give it a go when the wild is a zero and see if I can come up with anything.
Glad its working for you
I have what I think is a working version avoiding loops (I don't like the GS loops very much as they stand). It can probably be trimmed down and optimised a decent bit though.
Will post shortly once I've added some comments.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
I'm PMing you a link to download the example project from. It takes into account the 11 and 12 not using wildcards, and keeps 10 as a wildcard.
No loops. I suspect it could be done marginally more efficiently using loops, but as I said before I don't trust them.
I commented it fairly thoroughly so you should have a very good idea of what it's doing and why.
I'm not posting it here as I don't know about your game or if you want this functionality shared. You're welcome to post it if you want.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
@Armelline Thanks, Received it, works a treat. So kind of you to also add in all those notes and spend the time trying to understand my issue. Glad to see it was possible to create.
And a shout out to @gyroscope for your ideas.