/* Jothello 3.1 modified 6 * * for Java browser * * Nov/10/1996 * * CopyRight (C) Tadasuke Yamaguchi * * All Rights Reserved. * * Jothello is an interactive program written in Java for playing * othello game. It runs on some Java browsers. And this is free * software. So, permission is granted to make copies of this program. * * Please send me report of bugs you may meet on Jothello by email. * E-mail sph40086@bkc.ritsumei.ac.jp or echizen@mbox2.inet-osaka.or.jp * Of cource, your sugestions are welcome, too. * * Jothello's Home URL * http://www.ritsumei.ac.jp/bkc/~sph40086/java/Jothello/index-j.html * * Java is a registered trademark of Sun Microsystems, Inc. . * */ import java.awt.*; import java.applet.Applet; import java.applet.AppletContext; import java.net.URL; import java.net.MalformedURLException; import java.lang.String; public class Jothello extends Applet { BOARD Board; COMP Comp; Panel control; Choice Level; MESSAGE Message; int board[][] = new int[8][8]; int color = 1; final int black = 1; final int white = -1; final int blank = 0; int black_num = 2; int white_num = 2; int level = 0; int level_up = 9; int level_swap = 0; int undo_color[] = new int[60]; int undo_column[] = new int[60]; int undo_row[] = new int[60]; int tricks = 0; GridBagLayout gridbag; GridBagConstraints bagConstr; boolean registering = false; boolean registeringe = false; public void init() { String last_spart = getParameter("last_spart"); if( last_spart != null) { level_up = Integer.parseInt(last_spart); } String regist = getParameter("regist"); if( regist != null) { registering = true; } String registe = getParameter("registe"); if( registe != null) { registeringe = true; } System.out.println(""); System.out.println(""); System.out.println(""); System.out.println(""); System.out.println(""); System.out.println(""); System.out.println(""); System.out.println(""); System.out.println(" Jothello 3.1 modified 6"); System.out.println(""); System.out.println(" for Java browser"); System.out.println(""); System.out.println(" Nov/10/1996"); System.out.println(""); System.out.println(" CopyRight (C) Tadasuke Yamaguchi "); System.out.println(""); System.out.println(" All Rights Reserved."); System.out.println(""); System.out.println(" Jothello is an interactive program written in Java for playing"); System.out.println(" othello game. It runs on some Java browsers. And this is free"); System.out.println(" software. So, permission is granted to make copies of this program."); System.out.println(""); System.out.println(" Please send me report of bugs you may meet on Jothello by email."); System.out.println(" E-mail to sph40086@bkc.ritsumei.ac.jp or echizen@mbox2.inet-osaka.or.jp"); System.out.println(" Of cource, your sugestions are welcome, too."); System.out.println(""); System.out.println(" Jothello's Home URL "); System.out.println(" http://www.ritsumei.ac.jp/bkc/~sph40086/java/Jothello/index-j.html"); System.out.println(""); System.out.println(" Java is a registered trademark of Sun Microsystems, Inc. ."); System.out.println(""); System.out.println(""); System.out.println(""); System.out.println(""); System.out.println(""); System.out.println(""); System.out.println(""); Get_new(); Layout_init(); Data_init(); Draw_init(); } public void Get_new() { control = new Panel(); Comp = new COMP(this); Board = new BOARD(this); Level = new Choice(); Message = new MESSAGE(this); COMP_DATA data = new COMP_DATA(); } public void Layout_init() { gridbag = new GridBagLayout(); bagConstr = new GridBagConstraints(); setLayout(gridbag); bagConstr.gridx = 0; bagConstr.gridy = 0; bagConstr.ipadx = Board.width; bagConstr.ipady = Board.height; gridbag.setConstraints(Board,bagConstr); add(Board); bagConstr.gridy = 1; bagConstr.ipadx = Board.width; bagConstr.ipady = Board.line_terval+1; gridbag.setConstraints(Message,bagConstr); add(Message); bagConstr.gridy = 2; bagConstr.ipadx = 0; bagConstr.ipady = 0; gridbag.setConstraints(control,bagConstr); add(control); control.add(new Button("Undo")); control.add(new Button("Pass")); control.add(new Button("Reset")); Level.addItem("very easy"); Level.addItem("easy"); Level.addItem("normal"); Level.addItem("difficult"); Level.setBackground(Color.lightGray); control.add(Level); } public void Data_init() { for(int column = 0 ; column < 8 ; column++ ) { for(int row = 0 ; row < 8 ; row++ ) { board[column][row] = blank; } } board[3][3] = board[4][4] = white; board[3][4] = board[4][3] = black; } public void Draw_init() { Message.init(); Message.WriteCount(); Message.WriteTurn(); Message.repaint(); Board.init(); Board.draw_board(); Board.draw_all_pieces(); } public boolean action(Event evt,Object arg) { if(Board.turnning) { return false; } if (evt.target instanceof Button) { if("Undo".equals(arg)) { Undo(); } if("Pass".equals(arg)) { Pass(); } if("Reset".equals(arg)) { Reset(); } } else if(evt.target instanceof Choice) { String choice = (String)arg; if(choice.equals("very easy")) { level = 0; level_swap = level; } else if(choice.equals("easy")) { level = 1; level_swap = level; } else if(choice.equals("normal")) { level = 2; level_swap = level; } else if(choice.equals("difficult")) { level = 3; level_swap = level; } if( black_num+white_num > 64 - level_up) { level = 64 - (black_num+white_num); } else if( black_num+white_num + 3 >= 64 - level_up) { level = level_swap + 3; } } return true; } public boolean Undo() { if( tricks == 0 ) { return false; } BREAK_POINT: for( int num = tricks - 1; num >= 0 ; num-- ) { if( undo_color[num] == color ) { tricks = num; break BREAK_POINT; } } Data_init(); for( int num = 0 ; num < tricks ; num++ ) { turn_up(board,undo_column[num],undo_row[num],undo_color[num]); } Board.draw_board(); Board.draw_all_pieces(); Board.repaint(); Message.WriteCount(); Message.WriteTurn(); Message.repaint(); if( black_num+white_num <= 64 - level_up) { level = level_swap; } if( black_num+white_num +3 > 64 - level_up) { level = level_swap + 3 ; } return true; } public void Pass() { if( (black_num+white_num) != 4 ) { for( int column = 0 ; column < 8 ; column++ ) { for( int row = 0 ; row < 8 ; row++ ) { if(Comp.possible(board,column,row,-1*Comp.comp_color)) { return; } } } color = Comp.comp_color; } else { Comp.comp_color = color; } Message.WriteCount(); Message.WriteTurn(); Message.repaint(); Board.turnning = false; Board.loop = 1; Comp.thinking = true; Board.MoveThis.resume(); Board.repaint(); } public void Reset() { level = level_swap; Data_init(); tricks = 0; color = black; Comp.comp_color = white; Board.draw_board(); Board.draw_all_pieces(); Board.repaint(); Message.WriteCount(); Message.WriteTurn(); Message.repaint(); } public final boolean turn_up( Object obje , int column , int row ,int color ) { int column_d,row_d; boolean OX = false; int board[][] = (int[][])obje; if(board[column][row] != 0) { return OX; } for( int c = -1 ; c < 2 ; c++ ) { END: for( int r = -1 ; r < 2 ; r++ ) { column_d = column+c; row_d = row+r; if ( column_d < 0 || column_d > 7 || row_d < 0 || row_d > 7 ) { continue END; } else if( board[column_d][row_d] != -1*color) { continue END; } do { column_d += c; row_d += r; if ( column_d < 0 || column_d > 7 || row_d < 0 || row_d > 7 ) { continue END; } } while(board[column_d][row_d] == -1*color); if( board[column_d][row_d] == color ) { do { OX = true; column_d -= c; row_d -= r; board[column_d][row_d] = color; }while( column_d != column || row_d != row ); } } } return OX; } public void Register(String s) { if(!registering && !registeringe) { return; } try { URL url = new URL(s); getAppletContext().showDocument(url); } catch ( MalformedURLException e ) {} } } class BOARD extends Panel implements Runnable { Jothello jothe; Graphics graphic; Image image; Thread MoveThis; final int sleeping = 200; boolean turnning = false; int loop = 0; final int width = 241; final int height = 241; final int line_terval = 30; final int diameter = 25; int draw_color; int count = 0; int turn_up_pieces[][] = new int[19][2]; Color shade; BOARD(Jothello jothello) { jothe = jothello; } public void init() { image = createImage(width,height); graphic = image.getGraphics(); shade = new Color(0,60,0); MoveThis = new Thread(this); MoveThis.start(); //MoveThis.suspend(); } public void draw_board() { graphic.setColor(Color.lightGray); graphic.fillRect(0,0,width,height); graphic.setColor(new Color(20,150,20)); graphic.fillRect(0,0,8*line_terval,8*line_terval); graphic.setColor(Color.black); for(int line = 0 ; line < 9 ; line++ ) { graphic.drawLine(line*line_terval,0,line*line_terval,8*line_terval); graphic.drawLine(0,line*line_terval,8*line_terval,line*line_terval); } } public void draw_all_pieces() { for(int column = 0 ; column < 8 ; column++ ) { for(int row = 0 ; row < 8 ; row++ ) { if(jothe.blank != jothe.board[column][row]) { draw_a_piece(column,row,jothe.board[column][row]); } } } } public void draw_a_piece( int column , int row , int color ) { int x = line_terval*row+(line_terval-diameter)/2; int y = line_terval*column+(line_terval-diameter)/2; graphic.setColor(shade); graphic.fillOval(x-1,y-1,diameter+3,diameter+3); if(color == jothe.black) { graphic.setColor(new Color(20,20,20)); graphic.fillOval(x-1,y-1,diameter+2,diameter+2); graphic.setColor(Color.darkGray); graphic.fillOval(x+1,y+1,diameter-4,diameter-4); graphic.setColor(new Color(48,48,48)); graphic.fillOval(x+3,y+3,diameter-5,diameter-5); } else { graphic.setColor(new Color(55,55,55)); graphic.fillOval(x-1,y-1,diameter+2,diameter+2); graphic.setColor(new Color(80,80,80)); graphic.fillOval(x-1,y-1,diameter+1,diameter+1); graphic.setColor(new Color(128,128,128)); graphic.fillOval(x,y,diameter-1,diameter-1); graphic.setColor(new Color(160,160,160)); graphic.fillOval(x+1,y+1,diameter-2,diameter-2); graphic.setColor(Color.white); graphic.fillOval(x,y,diameter-2,diameter-2); graphic.setColor(new Color(220,220,220)); graphic.fillOval(x+2,y+2,diameter-4,diameter-4); } } public void draw_pieces() { int column = turn_up_pieces[count][0]; int row = turn_up_pieces[count][1]; turn_up_pieces[count][0] = 0; turn_up_pieces[count][1] = 0; count--; draw_a_piece(column,row,draw_color); } public synchronized void update(Graphics g) { if(turnning) { draw_pieces(); if(count <= 0) { count = 0; turnning = false; } if(!turnning) { jothe.color *= -1; jothe.Message.WriteTurn(); jothe.Message.repaint(); jothe.Comp.thinking = !jothe.Comp.thinking; if(!jothe.Comp.thinking) { //MoveThis.suspend(); } } } g.drawImage(image,0,0,null); if(jothe.Comp.thinking && !turnning && loop >= 3) { loop = 0; //MoveThis.suspend(); if(jothe.Comp.ThinkOut()) { MoveThis.resume(); get_turn_up_pieces(jothe.board,jothe.Comp.column,jothe.Comp.row,jothe.Comp.comp_color); jothe.turn_up(jothe.board,jothe.Comp.column,jothe.Comp.row,jothe.Comp.comp_color); draw_color = jothe.Comp.comp_color; jothe.undo_color[jothe.tricks] = jothe.Comp.comp_color; jothe.undo_column[jothe.tricks] = jothe.Comp.column; jothe.undo_row[jothe.tricks] = jothe.Comp.row; jothe.tricks++; turnning = true; jothe.Message.WriteCount(); jothe.Message.repaint(); } else { jothe.color = -1*jothe.color; jothe.Message.WriteTurn(); jothe.Message.repaint(); jothe.Comp.thinking = false; } } if(jothe.Comp.comp_color == jothe.color && !turnning) { jothe.Comp.thinking = true; loop++; } } public void paint(Graphics g) { graphic.drawImage(image,0,0,null); g.drawImage(image,0,0,null); } public boolean mouseDown(Event evt,int x,int y) { if(turnning) { return false; } int row = getPosition(x); int column = getPosition(y); if( row < 0 || row > 7 || column < 0 || column > 7 ) { return false; } if(get_turn_up_pieces(jothe.board,column,row,jothe.color)) { jothe.turn_up(jothe.board,column,row,jothe.color); draw_color = jothe.color; jothe.undo_color[jothe.tricks] = jothe.color; jothe.undo_column[jothe.tricks] = column; jothe.undo_row[jothe.tricks] = row; jothe.tricks++; jothe.Message.WriteCount(); jothe.Message.repaint(); turnning = true; MoveThis.resume(); } return true; } public void run() { while (true) { try { repaint(); MoveThis.sleep(sleeping); }catch(InterruptedException e){} } } public int getPosition(int num) { return num/line_terval; } public boolean get_turn_up_pieces( Object obje ,int column , int row , int color) { int column_d,row_d; boolean OX = false; int board[][] = (int[][])obje; if(board[column][row] != jothe.blank) { return OX; } for( int c = -1 ; c < 2 ; c++ ) { END: for( int r = -1 ; r < 2 ; r++ ) { column_d = column+c; row_d = row+r; if ( column_d < 0 || column_d > 7 || row_d < 0 || row_d > 7 ) { continue END; } else if( board[column_d][row_d] != -1*color) { continue END; } do { column_d += c; row_d += r; if ( column_d < 0 || column_d > 7 || row_d < 0 || row_d > 7 ) { continue END; } } while(board[column_d][row_d] == -1*color); if( board[column_d][row_d] == color ) { do { OX = true; column_d -= c; row_d -= r; if( !( column == column_d && row == row_d ) ) { count++; turn_up_pieces[count][0] = column_d; turn_up_pieces[count][1] = row_d; } }while( column_d != column || row_d != row ); } } } if(OX == true) { count++; turn_up_pieces[count][0] = column; turn_up_pieces[count][1] = row; } return OX; } } class COMP_DATA { int possible; int number; int corner; } class COMP { Jothello jothe; boolean thinking = false; int column,row; int comp_color; int corner[][] = new int[8][8]; int poor[][] = new int[8][8]; int end[][] = new int[8][8]; boolean can[][] = new boolean[8][8]; COMP_DATA data; COMP(Jothello jothello) { jothe = jothello; comp_color = jothe.white; } public boolean ThinkOut() { int count = 0; int board_now[][] = new int[8][8]; Comp_Data_init(); copy(board_now,'<',jothe.board); if( jothe.black_num+jothe.white_num > 64 - jothe.level_up) { jothe.level = 64 - (jothe.black_num+jothe.white_num); } else if( jothe.black_num+jothe.white_num +3 > 64 - jothe.level_up) { jothe.level = jothe.level_swap + 3; } for(int column = 0 ; column < 8 ; column++ ) { for(int row = 0 ; row < 8 ; row++ ) { if(jothe.turn_up(board_now,column,row,jothe.Comp.comp_color)) { count++; this.column = column; this.row = row; can[column][row] = true; data = preSee( board_now , 0 , -1*comp_color); end[column][row] = data.number; poor[column][row] = data.possible; corner[column][row] = data.corner; copy(board_now,'<',jothe.board); } } } if(count == 0) { return false; /* Yes, this means "pass" */ } decide(); return true; } public COMP_DATA end_line( Object obj , int color ) { int board[][] = (int[][])obj; COMP_DATA data = new COMP_DATA(); data.number = piece_counter(board); data.possible = possible_counter(board,color); data.corner = corner_counter(board,color); return data; } public int corner_counter( Object obj , int color ) { int board[][] = (int[][])obj; int count = 0; for(int column = 0 ; column < 8 ; column += 7 ) { for(int row = 0 ; row < 8 ; row += 7 ) { if(jothe.board[column][row] == jothe.blank && board[column][row] == comp_color) { count++; } if(color == comp_color && possible(board,column,row,comp_color)) { count++; } if(jothe.board[column][row] == jothe.blank && board[column][row] == -1*comp_color) { count--; } if(color != comp_color && possible(board,column,row,-1*comp_color)) { count--; } } } return count; } public int possible_counter( Object obj , int color ) { int board[][] = (int[][])obj; int count = 0; if(color == comp_color) { for(int column = 0 ; column < 8 ; column++ ) { for(int row = 0 ; row < 8 ; row++ ) { if(possible(board,column,row,color)) { count++; } } } } else { for(int column = 0 ; column < 8 ; column++ ) { for(int row = 0 ; row < 8 ; row++ ) { if(!possible(board,column,row,color)) { count++; } } } } return count; } public int piece_counter(Object obj) { int board[][] = (int[][])obj; int count = 0; for(int column = 0 ; column < 8 ; column++ ) { for(int row = 0 ; row < 8 ; row++ ) { if( board[column][row] == comp_color ) { count++; } } } return count; } public void Comp_Data_init() { for(int column = 0 ; column < 8 ; column++ ) { for(int row = 0 ; row < 8 ; row++ ) { end[column][row] = 0; can[column][row] = false; poor[column][row] = 0; corner[column][row] = 0; } } } public final COMP_DATA preSee( Object obje , int num , int color ) { int board_pre[][] = (int[][])obje; int board_now[][] = new int[8][8]; int count = 0; int end_num1,end_num2,end_num3; int end_num_d = 0; COMP_DATA data = new COMP_DATA(); if(color == comp_color) { end_num1 = 0; end_num2 = 0; end_num3 = -10; } else { end_num1 = 100; end_num2 = 100; end_num3 = 10; } copy(board_now,'<',board_pre); if(num < jothe.level) { for(int column = 0 ; column < 8 ; column++ ) { for(int row = 0 ; row < 8 ; row++ ) { if(jothe.turn_up(board_now,column,row,color)) { count++; data = preSee( board_now , num + 1 , -1*color ); /* recursive call */ if(( color == comp_color && data.number > end_num1 ) || ( color != comp_color && data.number < end_num1 )) { end_num1 = data.number; } if(( color == comp_color && data.possible > end_num2 ) || ( color != comp_color && data.possible < end_num2 )) { end_num2 = data.possible; } if(( color == comp_color && data.corner > end_num3 ) || ( color != comp_color && data.corner < end_num3 )) { end_num3 = data.corner; } copy(board_now,'<',board_pre); } } } if(count == 0) { /* This means the pass. */ data = preSee( board_now , num + 1 , -1*color ); /* recursive call */ if (( color == comp_color && data.number > end_num1 ) || ( color != comp_color && data.number < end_num1 )) { end_num1 = data.number; } if (( color == comp_color && data.possible > end_num2 ) || ( color != comp_color && data.possible < end_num2 )) { end_num2 = data.possible; } if(( color == comp_color && data.corner > end_num3 ) || ( color != comp_color && data.corner < end_num3 )) { end_num3 = data.corner; } } data.number = end_num1; data.possible = end_num2; data.corner = end_num3; } else { return end_line(board_pre,color); } return data; } public void decide() { int count1 = -64; int count2 = 0; int count3 = -10; for(int column = 1 ; column < 7 ; column += 5 ) { for(int row = 1 ; row < 7 ; row += 5 ) { if(no_corner(jothe.board,column,row)) { corner[column][row] = -10; } } } for(int column = 1 ; column < 7 ; column += 5 ) { for(int row = 0 ; row < 8 ; row += 7 ) { int co1 = 7; int co2 = 5; if(column == 1) { co1 = 0; co2 = 2; } if(can[column][row]) { if( jothe.board[co2][row] == jothe.blank && jothe.board[co1][row] == jothe.blank) { corner[column][row] = -10; } } if(can[row][column]) { if( jothe.board[row][co2] == jothe.blank && jothe.board[row][co1] == jothe.blank) { corner[row][column] = -10; } } } } for(int column = 0 ; column < 8 ; column++ ) { for(int row = 0 ; row < 8 ; row++ ) { if(can[column][row]) { if(corner[column][row] >= count3 ) { count3 = corner[column][row]; this.column = column; this.row = row; if(poor[column][row] >= count1) { count1 = poor[column][row]; this.column = column; this.row = row; if(end[column][row] >= count2) { count2 = end[column][row]; this.column = column; this.row = row; } } } } } } still(this.column,this.row); if(jothe.level == jothe.level_up) { count2 = 0; for(int column = 0 ; column < 8 ; column++ ) { for(int row = 0 ; row < 8 ; row++ ) { if(can[column][row]) { if(end[column][row] >= count2) { count2 = end[column][row]; this.column = column; this.row = row; } } } } } } public void still(int column,int row) { int board_d[][] = new int[8][8]; boolean stl = false; copy(board_d,'<',jothe.board); jothe.turn_up(board_d,column,row,comp_color); for(int column1 = 0 ; column1 < 8 ; column1 += 7 ) { for(int row1 = 0 ; row1 < 8 ; row1 += 7) { if(possible(board_d,column1,row1,-1*comp_color)) { stl = true; } } } int count = 0; copy(board_d,'<',jothe.board); if(stl) { for(int column1 = 1 ; column1 < 7 ; column1 += 5) { for(int row1 = 1 ; row1 < 7 ; row1 += 5) { if(jothe.turn_up(board_d,column1,row1,comp_color)) { for(int column2 = 0 ; column2 < 8 ; column2 += 7 ) { for(int row2 = 0 ; row2 < 8 ; row2 += 7) { if(!possible(board_d,column2,row2,-1*comp_color)) { count++; } } } if(count == 4) { this.column = column1; this.row = row1; } count = 0; copy(board_d,'<',jothe.board); } } } } } public boolean no_corner(Object obje,int column,int row) { int board[][] = (int[][])obje; int co = 0,ro = 0; if(column == 6) { co = 7; } if(row == 6) { ro = 7; } if(board[co][ro] == jothe.blank) { return true; } return false; } public final void copy(Object obje1,char chr,Object obje2) { int board1[][] = (int[][])obje1; int board2[][] = (int[][])obje2; if(chr == '<') { for(int column = 0 ; column < 8 ; column++ ) { System.arraycopy( board2[column] , 0, board1[column] , 0, 8 ); } } else { for(int column = 0 ; column < 8 ; column++ ) { System.arraycopy( board1[column] , 0, board2[column] , 0, 8 ); } } } public boolean possible( Object obje , int column , int row ,int color ) { int column_d,row_d; int board[][] = (int[][])obje; if(board[column][row] != 0) { return false; } for( int c = -1 ; c < 2 ; c++ ) { END: for( int r = -1 ; r < 2 ; r++ ) { column_d = column+c; row_d = row+r; if ( column_d < 0 || column_d > 7 || row_d < 0 || row_d > 7 ) { continue END; } else if( board[column_d][row_d] != -1*color) { continue END; } do { column_d += c; row_d += r; if ( column_d < 0 || column_d > 7 || row_d < 0 || row_d > 7 ) { continue END; } } while(board[column_d][row_d] == -1*color); if( board[column_d][row_d] == color ) { return true; } } } return false; } } class MESSAGE extends Panel { Jothello jothe; Image image; Graphics graphic; MESSAGE(Jothello jothello) { jothe = jothello; } public void init() { image = createImage(jothe.Board.width,jothe.Board.line_terval); graphic = image.getGraphics(); graphic.setColor(Color.lightGray); graphic.fillRect(0,0,jothe.Board.width,jothe.Board.line_terval); graphic.setFont(new Font("TimesRoman",Font.BOLD,15)); reliefString("move:",3,jothe.Board.line_terval-5); reliefString("count:",123,jothe.Board.line_terval-5); } public void WriteCount() { String black,white; count(); black = String.valueOf(jothe.black_num); white = String.valueOf(jothe.white_num); if(jothe.black_num < 10) { black = " "+black; } if(jothe.white_num < 10) { white = " "+white; } graphic.setColor(Color.lightGray); graphic.fillRect(168,0,75,jothe.Board.line_terval); graphic.setFont(new Font("TimesRoman",Font.BOLD,25)); writeString(black+" :",169,jothe.Board.line_terval-5,false); writeString(white,210,jothe.Board.line_terval-5,true); } public void WriteTurn() { int num = 0; graphic.setColor(Color.lightGray); graphic.fillRect(44,0,70,31); if(jothe.color == jothe.black) { writeString("Black",45,jothe.Board.line_terval-5,false); } else { writeString("White",45,jothe.Board.line_terval-5,true); } count(); int board[][] = new int[8][8]; jothe.Comp.copy(board,'<',jothe.board); for(int column = 0 ; column < 8 ; column++ ) { for(int row = 0 ; row < 8 ; row++ ) { if(jothe.turn_up(board,column,row,jothe.color)) { num++; jothe.Comp.copy(board,'<',jothe.board); } } } if(num==0){ for(int column = 0 ; column < 8 ; column++ ) { for(int row = 0 ; row < 8 ; row++ ) { if(jothe.turn_up(board,column,row,-1*jothe.color)) { num++; jothe.Comp.copy(board,'<',jothe.board); } } } if(num==0) { graphic.setColor(Color.lightGray); graphic.fillRect(44,0,70,31); count(); String s = ""; if(jothe.registeringe) { s = "http://www.ritsumei.ac.jp/bkc/~sph40086/cgi-bin/jothello-e.cgi?"; } else if(jothe.registering) { s = "http://www.ritsumei.ac.jp/bkc/~sph40086/cgi-bin/jothello.cgi?"; } s += "w="; if( jothe.Comp.comp_color == jothe.black ) { if( jothe.black_num > jothe.white_num ) { s += "c&c=w&"; } else if(jothe.black_num < jothe.white_num ){ s += "u&c=w&"; } else{ s += "d&c=w&"; } s += "cn="; s += String.valueOf(jothe.black_num); s += "&un="; s += String.valueOf(jothe.white_num); } else { if( jothe.black_num > jothe.white_num ) { s += "u&c=b&"; } else if(jothe.black_num < jothe.white_num ) { s += "c&c=b&"; } else{ s += "d&c=b&"; } s += "cn="; s += String.valueOf(jothe.white_num); s += "&un="; s += String.valueOf(jothe.black_num); } s += "&l="; s += String.valueOf(jothe.level_swap); jothe.Register(s); writeString("End",60,jothe.Board.line_terval-5,false); } } } public void count() { jothe.black_num = 0; jothe.white_num = 0; for(int column = 0 ; column < 8 ; column++ ) { for(int row = 0 ; row < 8 ; row++ ) { if(jothe.board[column][row] == jothe.black) { jothe.black_num++; } else if(jothe.board[column][row] == jothe.white) { jothe.white_num++; } } } } public void writeString(String s,int x,int y,boolean hollow) { graphic.setColor(Color.black); graphic.drawString(s,x-1,y); graphic.drawString(s,x+1,y); graphic.drawString(s,x,y-1); graphic.drawString(s,x,y+1); if(hollow) { graphic.setColor(Color.white); graphic.drawString(s,x,y); } } public void reliefString(String s,int x,int y) { graphic.setColor(Color.white); graphic.drawString(s,x-1,y-1); graphic.setColor(Color.darkGray); graphic.drawString(s,x+1,y+1); graphic.setColor(Color.lightGray); graphic.drawString(s,x,y); } public void paint(Graphics g) { g.drawImage(image,0,0,null); } public synchronized void update(Graphics g) { g.drawImage(image,0,0,null); } }