hey guys

i have a question i got for homework

the program is a basicly an Othelo/Reversi game

ive been writing some functions that changes the board according to legal playes

and now im being asked to create a function(BENEFIT) that counts the amount of enemy discs changeed based on the last play.

public static int benefit(int[][] board, int player, int row, int column){

int ans = 0;// YOU CAN CHANGE IT !!

return ans;

}//end of benefit

problem is its easied to count the maount of changes in the "play" function using COUNT++;

but i have no idea how am i suppose to use Benefit Function in order to count those changes. moreover it should sum the total amount of changes not only change per row/col/diagonal , instead it needs to return the changes of row+col+diagonal of a single play.

can anyone help me out?

heres some of the play function if it helps (the way ive written it anyways):

public static int[][] play(int[][] board, int player, int row, int column){

if (isLegal(board,player,row,column)){

if (isLegalrowright(board,player,row,column)){

//switching row right according to rules

int j=column;

while (j<=board[row].length-1&&board[row][j]!=player){

board[row][j]=player;

j=j+1;

}//while

}

if (isLegalrowleft(board,player,row,column)){

//switching row left according to rules

int j=column;

while (board[row][j]!=player&&j>=0){

board[row][j]=player;

j=j-1;

}//while

}

exc...

u can see adding co++ after board[row][j]=player will be the easiest solution but its not what i asked .. sadly.

thanks for help and sorry for length.