Hello just working on a little game, with the setup
1 2 3
4 5 6
7 8 9
Each of the numbers are actually colored squares in the programs with string literals in the for of numbers on them as listed. Now what what i am trying to do is find a formula which i could use in an if/ else statement which would validate moves correctly. Not looking for the obvious solution already do a long if/else statement. Looking more for a math formula. Best i can figure is that we could break them into 3 columns, each number has a difference of 3 vertically in the first/second/third columns, and difference of 1 horizontally. Can anyone think of a formula that i could use, which would only allow moves in horizontal or vertical, crossing moves are illegal. For instancs square 5 can only move too 2,4,6,8.
Any help would be great, already done a long if/else statement. Notlooking for that type of answer. If/else will still be used in the validation of moves just not 20 or so lines of it.
thanks again
1 2 3
4 5 6
7 8 9
Each of the numbers are actually colored squares in the programs with string literals in the for of numbers on them as listed. Now what what i am trying to do is find a formula which i could use in an if/ else statement which would validate moves correctly. Not looking for the obvious solution already do a long if/else statement. Looking more for a math formula. Best i can figure is that we could break them into 3 columns, each number has a difference of 3 vertically in the first/second/third columns, and difference of 1 horizontally. Can anyone think of a formula that i could use, which would only allow moves in horizontal or vertical, crossing moves are illegal. For instancs square 5 can only move too 2,4,6,8.
Any help would be great, already done a long if/else statement. Notlooking for that type of answer. If/else will still be used in the validation of moves just not 20 or so lines of it.
thanks again