Skip to first unread message

dove...@yahoo.co.uk

unread,
Jun 3, 2016, 11:46:17 AM6/3/16
to MIT App Inventor Forum
Im programming a card game app and need some help. In the app you play against a computer and I wish for the computer (the program) to make the best move each time from the 12 cards in play. Each card has a variable which denotes how far the move will go (from 1 to 8), the variable is say cpucard1move=3, cpucard2move=7 etc ... now for the computer to make the best move in each turn I need to find the highest variable from the list of 12 variable cpucard1move to cpucard12move but the only way I can think of doing this is to get app inventor to go through each variable against each variable which is going to be very long winded ie..

if cpucard1move>cpucard2move and cpucard3move and etc...

Is there a simpler way to get a result from a collection of variables ?

Thanks for any help, ive search the forums but cant find anything.

Taifun

unread,
Jun 3, 2016, 11:55:44 AM6/3/16
to MIT App Inventor Forum
instead of n variables, use a list to store the values
use a for each item in list loop to find the highest value

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

dove...@yahoo.co.uk

unread,
Jun 3, 2016, 12:36:42 PM6/3/16
to MIT App Inventor Forum
The cards i have in my program are created using a list and the variables in the cards are also in a list, i also have the lists to remove cards once played and to replenish the playing deck from the list replacing the card played. I did think whether using lists would work, im still not sure exactly how to find the highest value but i can see how 'for each item in list' would work so ill have a go.
Reply all
Reply to author
Forward
0 new messages