Class Variables have default values via default
authorMarkus Bröker <mbroeker@largo.homelinux.org>
Sun, 10 May 2009 16:04:42 +0200
changeset 7 93fe1f21e0d8
parent 6 ad18534e08fd
child 8 34a247829246
Class Variables have default values via default A class variable is initialized via default, it doesn't need explicit initialization
org/homelinux/largo/checkers/Checkers.java
org/homelinux/largo/checkers/KIBoard.java
org/homelinux/largo/games/board/Board.java
org/homelinux/largo/games/board/checkersboard/CheckersBoard.java
org/homelinux/largo/schach/KIBoard.java
org/homelinux/largo/schach/Schach.java
org/homelinux/largo/utils/ImgComponent.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("<html><font size='5' color='#FFFFFF'>Human</font></html>");
 	JLabel computer = new JLabel("<html><font size='5' color='#FFFFFF'>Computer</font></html>");
 	JButton     neu = new JButton("Play");
--- 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;
 			}
 		}
--- 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 )
--- 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;
 
--- 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;
 			}
 		}
--- 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("<html><font size='5' color='#FFFFFF'>Human</font></html>");
 	JLabel computer = new JLabel("<html><font size='5' color='#FFFFFF'>Computer</font></html>");
 	JButton     neu = new JButton("Play");
--- 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 ();