Minimalist Scoring Program

This is just some code I hacked up to keep track of a board and the current scores.

It runs through terminal in blue j (java IDE), but it would probably run through just cmd.

I just wanted to develop a way to quickly keep track of the score. This is all text based so at the input prompt you would enter something like

x,1,1

meaning put x on position 1,1 of the grid. it goes [row],[column].

I’m thinking about making it web-based (idea from sundial) with some human watchers updating to a central server as the game progresses. This means people in the pits would have some idea of how the games are progressing.
This may not happen because season has started, but who knows.

Unforutunately there are no spoilers yet implemented and anything can just be simply removed. This is just an elaborate game of tic tac toe with scoring.

Please use the code as would suit you best.


import java.util.*;

public class RackandRoll
{
    
    public static int board]] = { {0,0,0,0,0,0,0,0},
                                    {0,0,0,0,0,0,0,0},
                                    {0,0,0,0,0,0,0,0},
                                   };
    public static final int ROWS = 3,COLUMNS = 8;
    public static final int X = 1, O = 2,EMPTY = 0;
    public static int XScore,OScore;
   
    
    
    public static void printBoard()
    {
        for(int c=0;c<30;c++)
            System.out.println();
        
        System.out.print("  |");
        for(int i=0;i<COLUMNS;i++)
            System.out.print(" " + (i+1) + " |");
            
        System.out.println();
        
        for(int i=0;i<ROWS;i++)
        {
            System.out.print(i+1+ " |");
            
            for(int k=0;k<COLUMNS;k++)
            {
                switch (board*[k]){
                    
                    case X:
                        System.out.print(" " + 'X' + " ");
                        break;
                    case O:
                        System.out.print(" " + 'O' + " ");
                        break;
                    case EMPTY:
                        System.out.print("   ");
                        break;
               }
               
               System.out.print("|");
            }
            
            System.out.println();
          
        }
        
        getXScore();
        getOScore();
        
        System.out.println();
        System.out.println("X score is: " + XScore );
        System.out.println("O score is: " + OScore );
        

   }
   
   public static int getInput()
   {
       Scanner sc = new Scanner(System.in);
       int value=0;
       
       System.out.println("[X or O or e],[row],[column]");
       System.out.print("Input>>");
       StringTokenizer st = new StringTokenizer(sc.next(),", ");
        

        
       switch (st.nextToken().charAt(0))
       {
           case 'x':
                value = X;
                break;
           case 'o' :
                value = O;
                break;
           case 'q':
                value = -1;
                break;
           default:
                value = EMPTY;
        }
        
      
        if(value == -1)
            return value;
            
        int row = Integer.valueOf(st.nextToken())-1;
        int column = Integer.valueOf(st.nextToken())-1;
        
        if(row > 2 || row < 0 || column > 7 || column < 0)
            return 0;
        
        board[row][column] = value;
        return 0;
        
    }
    
    public static void getXScore()
    {
        int score=0,cnt=0;
        int i,k;
        
        for(i=0;i<3;i++) //score for horz. rows
        {
            for(k=0;k<8;k++)
            {
                if(board*[k] == X)
                {
                    cnt++;
                }
                
                if( k==7 || board*[k+1] != X)
                {
                    if(cnt > 0)
                    score += Math.pow(2,cnt);
                    
                    cnt=0;
                }
            }
            
            
        }
       
        cnt = 0;
        
         for(k=0;k<8;k++) //score for horz. rows
        {
            for(i=0;i<3;i++)
            {
                if(board*[k] == X)
                {
                    cnt++;
                }
                
                if( i==2 || board*[k] != X)
                {
                    if(cnt > 0)
                    score += Math.pow(2,cnt);
                    
                    cnt=0;
                }
            }
            
            
        }
        
        XScore = score;
        
    }
    
        public static void getOScore()
    {
        int score=0,cnt=0;
        int i,k;
        
        for(i=0;i<3;i++) //score for horz. rows
        {
            for(k=0;k<8;k++)
            {
                if(board*[k] == O)
                {
                    cnt++;
                }
                
                if( k==7 || board*[k+1] != O)
                {
                    if(cnt > 0)
                    score += Math.pow(2,cnt);
                    
                    cnt=0;
                }
            }
            
            
        }
       
        cnt = 0;
        
         for(k=0;k<8;k++) //score for horz. rows
        {
            for(i=0;i<3;i++)
            {
                if(board*[k] == O)
                {
                    cnt++;
                }
                
                if( i==2 || board*[k] != O)
                {
                    if(cnt > 0)
                    score += Math.pow(2,cnt);
                    
                    cnt=0;
                }
            }
            
            
        }
        
        OScore = score;
        
    }
            
        
       

   public static void main(String args])
   {
      int i=0;

      do
      {
          printBoard();
          i = getInput();
      }while(i != -1);
          
    }

}