Android Development & Technology
  • Connect 4 Online - Update

    Posted on July 10th, 2009 chris 1 comment
    This is a brief summary about today's update of Connect 4 Online, a multiplayer-enabled four-in-a-row game for Android phones. One major improvement is in the points / ranking system, especially in the case when the opponent leaves the game. For simplicity we are using a simplified ELO-rating system from chess to determine how many points the players win and loose. Round-Time is set to 30 seconds now! If your opponent doesn't move within 30 seconds, you can exit the game -- for the opponent it counts as lost and you will neither win nor loose points. Other updates include:
    • Checking of a network connection before connecting (avoids force close in that case, but requires one more permission)
    • Mapping Server: To make it easy to update the Python server, the clients first connect to a mapping server and receive an IP + Port for the real server instance
    • Numerous small fixes and smaller updates :-)
    I hope you guys enjoy it and let us know about your opinion! We promise to keep improving it then :-D Here is the code to calculate the new ELO rating for both players:
    // This function returns an array of two doubles
    // [0] is the new rating for player A, [1] for player B
    private double[] calcElo(int status, double RA, double RB) {
    	// status: 0 = draw, 1 = player A won, 2 = player B won
    	double QA = Math.pow(10, RA/400);
    	double QB = Math.pow(10, RB/400);
    
    	double k = 20;
    	
    	double EA = QA / (QA + QB);	    	
    	double EB = QB / (QA + QB);	    	
    	
    	double SA = 0.5; // draw
    	double SB = 0.5; // draw
    	if (status == 1) { 
    		SA = 1;
    		SB = 0;
    	} else if (status == 2) {
    		SA = 0;
    		SB = 1;
    	}
    
    	double[] res = new double[2];
    	res[0] = RA + (k * (SA - EA));
    	res[1] = RB + (k * (SB - EB));
    	return res;
    }

    Fatal error: Call to undefined function wpx_whatsNext() in /var/www/4feets.com/htdocs/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()'d code on line 45