Commit bcf39c7e authored by Ari Trachtenberg's avatar Ari Trachtenberg
Browse files

score updates

parent 8069d021
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
Greedy Brain	15	10	48
Greedy Brain	15	10	24
gyuh	15	10	6103
kjhgj	15	10	6070
	15	10	5869
	15	10	2755
Foo	15	10	1938
Simple Brain	15	10	1781
hoooodnbjeijohgjg	15	10	1761
	15	10	1215
Greedy Brain	15	10	1078
Greedy Brain	15	10	91
+19 −11
Original line number Diff line number Diff line
@@ -8,17 +8,25 @@ import java.util.Random;
 */

public enum CircleColor {
	NONE (new Color(0,0,0)), Red (new Color(255,0,0)), Green (new Color(0,255,0)), Blue(new Color(0,0,255));
	NONE(new Color(0, 0, 0)),
	Red(new Color(255, 0, 0)),
    Green(new Color(0, 255, 0)),
    Blue(new Color(0, 0, 255)),
    Pink(new Color(255,0,255));

	// fields
	private final Color myColor;
	private static final Random randGen = new Random();        // allocate Random number generator

	// Constructor
	CircleColor(Color myColor) { this.myColor = myColor; }
	CircleColor(Color myColor) {
		this.myColor = myColor;
	}

	// Accessors
	Color getColor() { return myColor; }
	Color getColor() {
		return myColor;
	}

	/*
	 * Generate a random color from the first num possible colors (excluding NONE)
+0 −5
Original line number Diff line number Diff line
@@ -233,10 +233,5 @@ class SelfAwareCircle extends Component implements MouseListener, SelfAwareListe

			// draw the circle
			g.fillOval(0, 0, size.width, size.height);
//			if (!debug.equals("")) {
//				g.setColor(new Color(0, 0, 0));
//				g.drawString(""+debug,0,size.height/2);
//			}

		}
}
+17 −26
Original line number Diff line number Diff line
@@ -57,7 +57,6 @@ class sg extends GUI implements ActionListener,ItemListener {
	private JMenuItem quitGame;
	private JRadioButtonMenuItem noPlayerMenuItem,simplePlayerMenuItem, lazyPlayerMenuItem, // various automatic player options
		smarterPlayerMenuItem;
	private static boolean IamApplet = true;   // true iff the application is run as an applet, false otherwise

	// ... Brain elements
	Brain theBrain;                   // the Brain (automated player) for the game
@@ -147,15 +146,19 @@ class sg extends GUI implements ActionListener,ItemListener {
	 * @return the score achieved from clicking on a region of length <b>level</b>
	 */
	final public int score(int level, CircleColor theColor) {
	    int tmp;

        if (level==1)
            return -10;
        else
            tmp = (int) (level * Math.log(level));
        switch (theColor) {
			case Blue:
				return level+1;
            case Red:
				return 2*level*level;
			case Green:
				return level*level;
                return -tmp;
            case Green: case Blue:
                return tmp;
            default:
                return 0; // I don't know this color
                return 0;
        }
	}

@@ -402,7 +405,6 @@ class sg extends GUI implements ActionListener,ItemListener {
		// if we've gotten here, it means that the game has ended
		int score = new Integer(totalPoints.getText());

		if (!IamApplet) {
		highScore hs = new highScore(highScoreFile);
		hs.loadScores();

@@ -427,16 +429,8 @@ class sg extends GUI implements ActionListener,ItemListener {


		JOptionPane.showMessageDialog(null, "Current high scores:\n"+hs.display());
		}
		else { // I am in an applet, disable high scores (they won't work as currently implemented because of security reasons)
			JOptionPane.showMessageDialog(null, "Game Over (High Scores are disabled for Applets).\n  You had "+score+" points.\n"+
					"Your weighted score for this sized board was "+ highScore.hsComp.weightedScore( new highScore.HSdata("",width,height,score))+".");
		}

		return false;
		/*		// for debug - show states
		for (int ii=0; ii<width; ii++)
			for (int jj=0; jj<height; jj++)
				circles[ii][jj].debug=""+circles[ii][jj].getState();*/

	}

@@ -516,15 +510,12 @@ class sg extends GUI implements ActionListener,ItemListener {
	}

	/**
	 * Designed to allow the applet to run as a standalone application
	 * See <a href="http://www.informit.com/content/images/078970935X/sourcecode/ch13.zip">here</a>}
	 * Runs the application
	 */
	public static void main(String args[]) {
		JFrame myApp = new sg();
		//JFrame myAppFrame = new JFrame("Ari's samegame");
		myApp.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
		myApp.setSize(defaultWindowWidth, defaultWindowHeight);

		myApp.setVisible(true);
	}
}
 No newline at end of file