Attribute combinations help!
shortwave
Member Posts: 29
Hi everyone, I have a problem which I can't seem to figure out. It will probably be really easy for you guys!
Anyway, here is what I have:
10 attributes - all integer but only ever 1 or 0
An actor which displays a different image depending on what all those attributes are... For example 1 0 0 1 0 0 0 1 1 0 would display one image, while 1 1 1 1 1 1 1 1 1 1 would display another.
At the moment I have a rule for each combination of attributes that I need, which basically says:
If attribute 1 = 1
If attribute 2 = 0
If attribute 3 = 1
If attribute.....
Like that for all 10 attributes, and that is repeated for every combination I need an image for.
There must be an easier way of doing this... Maybe a table could help somehow? Or maybe is there a way of creating a new attribute out of all the others like this - 1010101010, then I could just say if newattribute=101010101010 then display image?
Also I've had a problem doing it my way as sometimes it doesn't seem to update, usually if I take away a 1 to make a new combination.
I'd also like to know if theres any way I could save a list of combinations like this and load them up easily, like from a table?
Thanks everyone!
Anyway, here is what I have:
10 attributes - all integer but only ever 1 or 0
An actor which displays a different image depending on what all those attributes are... For example 1 0 0 1 0 0 0 1 1 0 would display one image, while 1 1 1 1 1 1 1 1 1 1 would display another.
At the moment I have a rule for each combination of attributes that I need, which basically says:
If attribute 1 = 1
If attribute 2 = 0
If attribute 3 = 1
If attribute.....
Like that for all 10 attributes, and that is repeated for every combination I need an image for.
There must be an easier way of doing this... Maybe a table could help somehow? Or maybe is there a way of creating a new attribute out of all the others like this - 1010101010, then I could just say if newattribute=101010101010 then display image?
Also I've had a problem doing it my way as sometimes it doesn't seem to update, usually if I take away a 1 to make a new combination.
I'd also like to know if theres any way I could save a list of combinations like this and load them up easily, like from a table?
Thanks everyone!
Comments
Hi @shortwave Yes, using tables would probably be the way to go. But even then, that'll be a lot of work.... I'll explain how in another post after a question, so I'm sure what you're after: you have 10 attributes which could be 0 or 1; you do realize that the total amount of combinations (i.e between 0000000000 and 1111111111 and including those two) is 1010? >>>> http://www.mathsisfun.com/binary-combinations.html
In other words you need to show over a thousand different images? Is that what you want to do?
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
OK, the following is rough, as a guide but should get you up and running:
•Make a table with a hundred rows and two columns, the first column showing the 100 possible combinations (to make things slightly easier to see what's going on, make these Text attributes), and the second column, also as text, showing the names of the images.
With your update problem, you need a counter attribute (up to 10) for each "round".
I don't know how you want to start off the process, let's say with a go button.
Rule: When Count =0
Change attribute start to true
• I also don't know enough details of your game as to how the 0 or 1 integers are generated, so I'll assume it's in 10 different actors.
In each of the 10 actors' Rules: ---- assuming this
When Count< 10 and Start is true
Change attribute Random to (0,1)
Change attribute Collector --a text attribute--- to Collector..Random
When TableCount <100 and TableSearch is false and Count = 10
Change Attribute TableSearch to true
Change Attribute TableCount to TableCount+1
When Collector =tableCellValue(YourTable,TableCount,1)
Change Attribute scene.Background.ActortoChangepic.Image to tableCellValue(YourTable,TableCount,2)
Change Attribute Count to 0
Change attribute Start to false
Otherwise
Change Attribute TableSearch to true
Change Attribute scene.Background.ActortoChangepic.Image to blankimage
--------
Rule: When TableSearch is true
Change Attribute TableSearch to false
-----this is off the top of my head, so untested, and there might be a few minor hiccups with the logic, but that's roughly what you need. Best of luck.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
I think you're mixing up the number 10 (1010 in binary) with the largest 10 bit number (1024).
[/math pedantry]
Cheers!
PS I have a dose of some sort of flu and that's my excuse and I'm sticking too it! (I really have, actually; been feeling really grotty the last three days.... all say "aah, poor thing...." ;-) Been sleeping for most of the days, (as well as at night); feeling hot but cold at the same time.... getting fed up with it now, so got up earlier and pretending I'm OK...
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Just to check, my app is basically ten on and off buttons, which control the attributes, and a display which shows the picture, the display changes as soon as a combination matches one that's saved. Will this work ok the way you suggested, I was only wondering because there is no 'round' or anything like that, just a set of ten separate attributes that are changing independently and a display that changes when a certain combination happens...
Thanks for helping!
Hi, by the sound of it, the above will do what you want... (barring the possible logic hiccups);
As for the "rounds", there is those, as such, i.e every 10 buttons pressed, you get an image or a blank image...., then presumably start again with another "round"...?
Just thought, you'll have to add self attribute boolean to each of the actors, to stop them being pressed more than once, so something like
When Count= 0
Change attribute button1 to false
When button1 is false
When touch is pressed
Change attribute button1 to true
----then all the stuff above
-------same with all the other buttons, changing the number accordingly. You're welcome; hope it all works out for you. :-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Using a loop, concatenate the rows together to form a master image list:
Change Attribute game.ImageNameList [text] to game.ImageNameList..tableCellValue(tableName,self.loopCounter,1).."#"
Either change or constrain the image name you want to display:
Constrain Attribute game.ImageName [text] to game.attribute1..game.attribute2..gameattribute3 [etc.]
Then check to see if game.ImageNameList contains game.ImageName and if so, Change Attribute self.Image to game.ImageName.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Ahh, poor thing. :-& :-& :-& :-& Sounds nasty, I hate the hot+cold thing.
This is something for you to read it bed:
http://www.tuaw.com/2010/10/15/report-iphone-ipad-glass-crawling-with-bacteria-and-viruses/
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
It's really simple but it works, with just 2 rules...
First concatenated all 10 attributes into one long text attribute,
Then constrain self.image to that attribute...
All I needed to do was rename all the images 1001010101 etc and it works perfectly yay!
Only problem at the moment is it displays white actor when no image name matches, can't think about how to get round that yet. Unless maybe I put a list of possibilities at the start of the rule... If attribute=0101010101001 bla bla *100 then otherwise blank image at the end?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@shortwave Full marks for the other method of course but for the record, part of my rules for you first includes concatenating all 10 attributes into one long text attribute:
----the following in each of the 10 buttons----
When Count< 10 and Start is true
Change attribute Random to (0,1)
Change attribute Collector --a text attribute--- to Collector..Random
this concatenates up to 10 from 10 presses, so Collector (text attribute) has the complete list of 10 0 or 1's.
>>> Nice shortcut to avoid a second column though, by naming the images as the concatenated variations.... neat! (Kicking myself I didn't think of that, instead of making it unnecessarily complicated...)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Hi, so you mean to avoid the table completely, in an added Rule, set to Any:
When Collector =111000000 ------ Collector being the concatenated text attribute
Collector =111001100
Collector =101000000 --etc up to 100 of them, a lot of work, but would have still needed to be put into a table...
Change Attribute self.Image to scene.Collector
Otherwise
Change Attribute self.Image to blankimage
That'd work fine providing your images where all named as the 100 same numbers as names.
Pleased it's working out for you now.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps