Tous les collages #185275 Brut Modifier

Something

public text v1 · immuable
#185275 ·publié 2006-09-28 20:21 UTC
corps du collage affiché
package rockPaperScissors;
import java.util.Random;

public class JackBauerBot implements RPSStrategy {
	float round = 0;
	int rocks = 0;
	int paps = 0;
	int ss = 0;
	int op = 9;
	int copy = 0;
	int scopy = 0;
	int thor;
	String move = "";
	int mine = 9;
	int r = 0;
	int me[] = new int[11000];
	int them[] = new int[11000];
	int winna = 9;
	int winme = 0;
	int winthem = 0;
	private Random generator;
	

	public JackBauerBot() 
	{
		reset();
	}
	
	public void reset() 
	{
		rocks = 0;
		paps = 0;
		ss = 0;
		round = 0;
		copy = 0;
		generator = new Random();
	}
		

	public String getName() 
	{
		return "JackBauerBot";
		
	}

	public int nextThrow() 
	{
		round++;
		
		int winna = Referee.whoWins(mine, op);
		if (winna == 1)
			winme++;
		if (winna == 2)
			winthem++;
		
		
		
		if (round > 5 && op == me[(int)round-2])
			copy++;
		//System.out.println(me[(int)round-1] + "" + op);
		if (round < 5 || op == -1)
			mine = generator.nextInt(3);  //randomize for the first 15 turns or when i hit an invalid
		if (round > 5)
			if ((rocks/round) > .91 || (paps/round) > .91 || (ss/round) > .91)
				mine = (op + 1) % 3;
			else if ((copy / round) > .91)
				mine = (mine + 1) % 3;
			else
				mine = (mine +  2) % 3;
		if (winthem - winme > 200)
			mine = generator.nextInt(3);
		
			
		
		me[(int)round] = mine;
		return mine;
	}

	public void opponentsLastThrow(int th)
	{	
			if (th == -1)
				move = "invalid";
			if (th == 0)
			{
				rocks++;
				op = th;
			}
			if (th == 1)
			{
				paps++;
				op = th;
			}
			else
			{
				op = th;
				ss++;
			}
		if (round > 5)
		{
			them[(int)round] = th;
		}
			
	}

}