(char[] state, char turn)
| 75 | * are '0'. |
| 76 | */ |
| 77 | public static int toInt(char[] state, char turn) { |
| 78 | int out = 0; |
| 79 | int len = state.length; |
| 80 | for ( int i = 1; i <= len; i++ ){ |
| 81 | if ( state[len-i] == turn) { |
| 82 | out += Math.pow( 2, i-1 ); |
| 83 | } |
| 84 | } |
| 85 | return out; |
| 86 | } |
| 87 | |
| 88 | /* Compare an integer game state against known winning states for tic tac |
| 89 | * toe. For example, X can win with three Xs on the bottom row: |
no outgoing calls