Randomly choose a value, but exclude values already taken?

Hi guys,
In my game I have a character selection for 1-2 players. There are 8 characters to choose from and players pick at the start of each game. the characters are just a graphical skin there's no difference otherwise.
I have 2 integer game attributes that record the player picked, player1Character & player2Character.
These are set when the player selects who they want to be, and then the actor in the game generates the corresponding graphics based on this value. That all works fine.
I also have some AI characters (2-3 depending if it's a 1 or 2 player game). I want these to randomly select another character to skin themselves with, but not one the player has already selected. Currently they have a personal integer attribute and an 'change attribute' that tells that to pick a random number from 1-8, and then the same behaviours to skin the actor accordingly. But how can I make it so that it picks randomly from 1-8 but excludes the number the player has picked?
so for example:
Player1 selects the cat, which is a value of 2.
Player2 selects the frog, which is a value of 5.
AI 3 then has a random selection of 1,3,4,6,7,8. So it can't pick 2 or 5 as they are gone.
AI 4 then gets the same choice with minus the one AI 3 also picked.
Thanks in advance!
-Olly
In my game I have a character selection for 1-2 players. There are 8 characters to choose from and players pick at the start of each game. the characters are just a graphical skin there's no difference otherwise.
I have 2 integer game attributes that record the player picked, player1Character & player2Character.
These are set when the player selects who they want to be, and then the actor in the game generates the corresponding graphics based on this value. That all works fine.
I also have some AI characters (2-3 depending if it's a 1 or 2 player game). I want these to randomly select another character to skin themselves with, but not one the player has already selected. Currently they have a personal integer attribute and an 'change attribute' that tells that to pick a random number from 1-8, and then the same behaviours to skin the actor accordingly. But how can I make it so that it picks randomly from 1-8 but excludes the number the player has picked?
so for example:
Player1 selects the cat, which is a value of 2.
Player2 selects the frog, which is a value of 5.
AI 3 then has a random selection of 1,3,4,6,7,8. So it can't pick 2 or 5 as they are gone.
AI 4 then gets the same choice with minus the one AI 3 also picked.
Thanks in advance!
-Olly
Comments
we can use tables
also, you can use a text-type attribute to store previous selections
Player1 selects the cat; changeAttribute: game.textSelection To: game.textSelection.." ".."2"
then for AI chars on the random selection
Rule: when game.textSelection contains the selection (2 or expression for attribute storing Player1 selection) … do another random
you could use Index type attributes to store whole positive numbers …
@};- MH