# HG changeset patch # User Markus Bröker # Date 1241964282 -7200 # Node ID 93fe1f21e0d82f6eaf020ab1866ea25c1384fabc # Parent ad18534e08fd21cb13f2b0c3b6110ebd4383c651 Class Variables have default values via default A class variable is initialized via default, it doesn't need explicit initialization diff --git a/org/homelinux/largo/checkers/Checkers.java b/org/homelinux/largo/checkers/Checkers.java --- a/org/homelinux/largo/checkers/Checkers.java +++ b/org/homelinux/largo/checkers/Checkers.java @@ -25,9 +25,9 @@ static final long serialVersionUID = 250408; static final String helpURL = "http://largo.homelinux.org/cgi-bin/gitweb.cgi?p=games/Schach.git;a=summary"; - MouseListener listener = null; - KIBoard board = null; - Point p = null; + MouseListener listener; + KIBoard board; + Point p; JLabel human = new JLabel("Human"); JLabel computer = new JLabel("Computer"); JButton neu = new JButton("Play"); diff --git a/org/homelinux/largo/checkers/KIBoard.java b/org/homelinux/largo/checkers/KIBoard.java --- a/org/homelinux/largo/checkers/KIBoard.java +++ b/org/homelinux/largo/checkers/KIBoard.java @@ -187,7 +187,7 @@ System.err.println("Computing once more..."); value = max_alpha_beta(1, Integer.MIN_VALUE, Integer.MAX_VALUE); if (bestMove == null) { - System.out.println("Finito"); + System.out.println("Finito " + value); return false; } } diff --git a/org/homelinux/largo/games/board/Board.java b/org/homelinux/largo/games/board/Board.java --- a/org/homelinux/largo/games/board/Board.java +++ b/org/homelinux/largo/games/board/Board.java @@ -36,7 +36,7 @@ boolean black; boolean blacksTurn; - MouseListener listener = null; + MouseListener listener; /** * The init method initializes an empty board with a history. @@ -276,8 +276,8 @@ * Moves one half-move backward. */ public void backwards() { - History h1 = null; - History h2 = null; + History h1; + History h2; if ( moveNr < 2) return; @@ -297,8 +297,8 @@ * Moves one half-move forward. */ public void forward() { - History h1 = null; - History h2 = null; + History h1; + History h2; if ( moveNr > stack.size()-2 ) return; @@ -325,8 +325,8 @@ * pop: undo the push operation. */ public void undo() { - History h1 = null; - History h2 = null; + History h1; + History h2; int size = stack.size(); if ( size < 2 ) diff --git a/org/homelinux/largo/games/board/checkersboard/CheckersBoard.java b/org/homelinux/largo/games/board/checkersboard/CheckersBoard.java --- a/org/homelinux/largo/games/board/checkersboard/CheckersBoard.java +++ b/org/homelinux/largo/games/board/checkersboard/CheckersBoard.java @@ -71,7 +71,6 @@ public boolean validMove (int t, int o) { int steps; int rows; - int dx; if ( t == o ) return false; @@ -204,7 +203,6 @@ * all changes are relative to pieces and will not be painted. */ public boolean simulateMove(int t, int o) { - int steps = Math.abs(t-o); int rows = Math.abs(t/8 - o/8); int pos; diff --git a/org/homelinux/largo/schach/KIBoard.java b/org/homelinux/largo/schach/KIBoard.java --- a/org/homelinux/largo/schach/KIBoard.java +++ b/org/homelinux/largo/schach/KIBoard.java @@ -81,7 +81,7 @@ * The Turn will flip automatically if "simulate(...)" finds a valid move. */ Move simulate(int t, int o) { - Move move = null; + Move move; int value; if ( validTurn(o) ) { @@ -111,7 +111,7 @@ int max_alpha_beta (int depth, int alpha, int beta) { int moveValue; int o, t; - Move move = null; + Move move; if ( desired_depth == -1 ) desired_depth = depth; @@ -150,7 +150,7 @@ int min_alpha_beta(int depth, int alpha, int beta) { int moveValue; int o, t; - Move move = null; + Move move; for (o = 0; o < 64; o++) { t=0; @@ -184,16 +184,16 @@ */ public boolean doBestMove(int search_depth) { int value; - desired_depth = -1; bestMove = null; + value = max_alpha_beta(search_depth, Integer.MIN_VALUE, Integer.MAX_VALUE); if ( bestMove == null ) { System.err.println("Computing once more..."); - value = max_alpha_beta(1, Integer.MIN_VALUE, Integer.MAX_VALUE); + value = max_alpha_beta(--search_depth, Integer.MIN_VALUE, Integer.MAX_VALUE); if (bestMove == null) { - System.out.println("Check Mate"); + System.out.println("Check Mate " + value); return false; } } diff --git a/org/homelinux/largo/schach/Schach.java b/org/homelinux/largo/schach/Schach.java --- a/org/homelinux/largo/schach/Schach.java +++ b/org/homelinux/largo/schach/Schach.java @@ -25,9 +25,9 @@ static final long serialVersionUID = 140208; static final String helpURL = "http://largo.homelinux.org/cgi-bin/gitweb.cgi?p=games/Schach.git;a=summary"; - MouseListener listener = null; - KIBoard board = null; - Point p = null; + MouseListener listener; + KIBoard board; + Point p; JLabel human = new JLabel("Human"); JLabel computer = new JLabel("Computer"); JButton neu = new JButton("Play"); diff --git a/org/homelinux/largo/utils/ImgComponent.java b/org/homelinux/largo/utils/ImgComponent.java --- a/org/homelinux/largo/utils/ImgComponent.java +++ b/org/homelinux/largo/utils/ImgComponent.java @@ -9,7 +9,7 @@ public class ImgComponent extends Canvas { static final long serialVersionUID = 140208; - private Image img = null; + private Image img; public ImgComponent (String sFile) { ClassLoader cl = getClass ().getClassLoader ();