Oct-01-2016, 01:26 PM
I often use a dictionary for game boards. Tuples are hashable, so they can be used as keys in a dictionary. So you use a tuple of the coordinates of the peg holes as the keys of the dictionary, and the state of each peg hole is the value.
And Larz60+ is right that boolean may not be the best way to store the state. If your peg holes can have more than two states (empty, unusable, peg), than you want something that can handle more than two states. You can use 'X' and 'O', and then it's easy to print the board on the screen. However, it might be that the way you are processing the peg holes would make integer values easier to use in the processing. So you want to think about where in your program you want to interpret the values, and where in your program you want to make use of them as they are.
And Larz60+ is right that boolean may not be the best way to store the state. If your peg holes can have more than two states (empty, unusable, peg), than you want something that can handle more than two states. You can use 'X' and 'O', and then it's easy to print the board on the screen. However, it might be that the way you are processing the peg holes would make integer values easier to use in the processing. So you want to think about where in your program you want to interpret the values, and where in your program you want to make use of them as they are.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures