All pastes #179208 Raw Edit

Untitled

public java v1 · immutable
#179208 ·published 2006-09-22 01:11 UTC
rendered paste body
package rockPaperScissors;import java.util.ArrayList;import java.util.Random;public class DumbBot implements RPSStrategy{	int op = 0;	boolean isdummy = false;	private Random generator;	ArrayList hismoves;	ArrayList mymoves;	int round = 0;	public DumbBot()	{		reset();	}	public void reset()	{		generator = new Random();		op = generator.nextInt(2);		isdummy = false;		hismoves = new ArrayList();		mymoves = new ArrayList();		round = 0;		mymoves.add(round, new Integer(op));	}	public String getName()	{		return "DumbBot";	}	public int nextThrow()	{		if (isdummy)		{			if (op == 0)			{				op = 1;				mymoves.add(round++, new Integer(op));				return 1;			}			if (op == 1)			{				op = 2;				mymoves.add(round++, new Integer(op));				return 2;			}			if (op == 2)			{				op = 0;				mymoves.add(round++, new Integer(op));				return 0;			}			return -1;		}		else		{			int j =  generator.nextInt(2);			return j;		}	}	public void opponentsLastThrow(int th)	{		hismoves.add(round, new Integer(th));		if (hismoves.equals(mymoves))		{			isdummy = true;		}		else		{			isdummy = false;		}	}}