advertisement
javaboutique
Search Tips
Articles  |   Tutorials  |   Reviews  |   Tools  |   by Category  |   by Date  |   by Name  |   Submit  |   Source  |   Forums  |  
javaboutique
Browse DevX


Partners & Affiliates











advertisement


ADescolada


Java Source:

import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.WindowListener;
import java.awt.event.WindowEvent;
import java.util.Vector;
import java.awt.event.KeyListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
//import java.util.Hashtable;

public class ADescolada extends java.applet.Applet implements ActionListener, KeyListener, Runnable, MouseListener, WindowListener	{
	static int width;
	static int height;
	static int appletWidth, appletHeight, cellWidth, cellHeight;
	//static Vector red, blue;
	static boolean running;
	Button goButton, createButton, iterateButton, destroyButton;
	static int cw, ch;
	Panel buttonPanel;
	Thread kicker;
	//static int[] orgArray;
	Image buffImg;
	Graphics buffGfx;
	//static Hashtable orgs;
	//static Vector keys;
	static Vector orgs;
	static int[] keys;
	//in keys: food=-2;
	static Vector foods;
	static int iterationNumber;
	static Label iterLabel;
	static int iterationDelay;
	//static int siz, newSiz;
	Choice strengt, msa, mdi, se, colo, lifespa;
	Choice strength, ms, md, sex, color, lifespan;
	Frame createFrame;
	Button whichButton;
	int which;
	public void windowClosing(WindowEvent e)	{
			createFrame.setVisible(false);
	}
	public void windowOpened(WindowEvent e)	{}
	public void windowClosed(WindowEvent e)	{}
	public void windowDeactivated(WindowEvent e)	{}
	public void windowActivated(WindowEvent e)	{}
	public void windowDeiconified(WindowEvent e)	{}
	public void windowIconified(WindowEvent e)	{}
	public void init()	{
		try	{
			iterationDelay=(new Integer(getParameter("delay"))).intValue();
		}
		catch(Exception e)	{
			iterationDelay=1000;
		}
		try	{
			width=(new Integer(getParameter("cols"))).intValue();
		}
		catch(Exception e)	{
			width=10;
		}
		try	{
			height=(new Integer(getParameter("rows"))).intValue();
		}
		catch(Exception e)	{
			height=10;
		}
		//siz=0;
		//newSiz=0;
		iterationNumber=0;
		foods=new Vector();
		appletWidth=getSize().width;
		appletHeight=getSize().height-30;
		cellWidth=appletWidth/width;
		cellHeight=appletHeight/height;
		cw=cellWidth;
		ch=cellHeight;
		setLayout(new BorderLayout());
		this.addMouseListener(this);
		goButton=new Button("Run");
		goButton.addActionListener(this);
		iterateButton=new Button("Iterate");
		iterateButton.addActionListener(new itListen(this));
		buttonPanel=new Panel();
		buttonPanel.add(iterateButton);
		buttonPanel.add(goButton);
		createButton=new Button("Attributes");
		createButton.addActionListener(new createListener(this));
		whichButton=new Button("Organism");
		whichButton.addActionListener(new WhichListener(this));
		strengt=new Choice();
		strengt.addItem("Strength");
		strengt.addItem("1=weakest, 4=strongest");
		msa=new Choice();
		msa.addItem("Move Same");
		msa.addItem("1=move away from same color");
		msa.addItem("2=no preference");
		msa.addItem("3=move towards same color");
		mdi=new Choice();
		mdi.addItem("Move Different");
		mdi.addItem("1=move away from other color");
		mdi.addItem("2=no preference");
		mdi.addItem("3=move towards other color");
		se=new Choice();
		se.addItem("Gender");
		colo=new Choice();
		colo.addItem("Color/tribe of new organism");
		lifespa=new Choice();
		lifespa.addItem("Natural Lifespan");
		lifespa.addItem("1=shortest");
		lifespa.addItem("2=medium");
		lifespa.addItem("3=longest");
		this.strength=new Choice();
		this.strength.addItem("1");
		this.strength.addItem("2");
		this.strength.addItem("3");
		this.strength.addItem("4");
		this.strength.select(1);
		this.ms=new Choice();
		this.ms.addItem("1");
		this.ms.addItem("2");
		this.ms.addItem("3");
		this.ms.select(1);
		this.md=new Choice();
		this.md.addItem("1");
		this.md.addItem("2");
		this.md.addItem("3");
		this.md.select(1);
		this.color=new Choice();
		this.color.addItem("Red");
		this.color.addItem("Blue");
		this.sex=new Choice();
		this.sex.addItem("Female");
		this.sex.addItem("Male");
		this.lifespan=new Choice();
		this.lifespan.addItem("1");
		this.lifespan.addItem("2");
		this.lifespan.addItem("3");
		this.lifespan.select(1);
		which=0;
		this.createFrame=new Frame("Attributes");
		createFrame.setLayout(new GridLayout(0,2));
		createFrame.add(strengt);
		createFrame.add(this.strength);
		createFrame.add(msa);
		createFrame.add(this.ms);
		createFrame.add(mdi);
		createFrame.add(this.md);
		createFrame.add(lifespa);
		createFrame.add(this.lifespan);
		createFrame.add(colo);
		createFrame.add(this.color);
		createFrame.add(se);
		createFrame.add(this.sex);
		createFrame.setSize(400,300);
		createFrame.addWindowListener(this);
		this.addKeyListener(this);
		buttonPanel.add(createButton);
		buttonPanel.add(whichButton);
		iterLabel=new Label("Iteration #0             ");
		buttonPanel.add(iterLabel);
		add("South", buttonPanel);
		//red=new Vector();
		//blue=new Vector();
		//orgs=new Hashtable();
		//keys=new Vector();
		orgs=new Vector();
		keys=new int[width*height];
		for (int i=0;i<width*height;i++)	{
			keys[i]=-1;
		}
		running=false;
		kicker=new Thread(this);
		//orgArray=new int[width*height];
		buffImg=createImage(appletWidth, appletHeight);
		buffGfx=buffImg.getGraphics();
		/*for (int i=0;i<8;i++)	{
			System.out.print((int)(Math.random()*2));
		}*/
	}
	public void keyPressed(KeyEvent e)	{
		if ((!running) && (orgs.size()>0))	{
			iterate();
			repaint();
			if (orgs.size()==0)
				iterationNumber=0;
		}
		else if (orgs.size()==0)	{
			iterationNumber=0;
		}
		else	{
			kicker.stop();
			running=false;
			goButton.setLabel("Run");
			kicker=new Thread(this);
		}
	}
	public void keyReleased(KeyEvent e)	{}
	public void keyTyped(KeyEvent e)	{}
	public void paint(Graphics g)	{
		buffGfx.setColor(Color.white);
		buffGfx.fillRect(0, 0, appletWidth, appletHeight);
		buffGfx.setColor(Color.green);
		for (int i=0;i<foods.size();i++)	{
			int j=((Integer)(foods.elementAt(i))).intValue();
			buffGfx.fillOval(cellWidth/3+cellWidth*(j%ADescolada.width),cellHeight/3+cellHeight*((int)j/ADescolada.width),cellWidth/3, cellHeight/3);
		}
		buffGfx.setColor(Color.black);
		for (int i=1;i<width;i++)	{
			buffGfx.drawLine(cellWidth*i, 0, cellWidth*i, cellHeight*height);
		}
		for (int i=1; i<=height;i++)	{
			buffGfx.drawLine(0, cellHeight*i, cellWidth*width, cellHeight*i);
		}
		//draw organisms
		/*for (int i=0;i<red.size();i++)	{
			Organism org=(Organism)red.elementAt(i);
			org.draw(buffGfx);
		}
		for (int i=0;i<blue.size();i++)	{
			Organism org=(Organism)blue.elementAt(i);
			org.draw(buffGfx);
		}*/
		for (int i=0;i<orgs.size();i++)	{
			//Organism org=(Organism)orgs.get((Integer)(keys.elementAt(i)));
			Organism org=(Organism)orgs.elementAt(i);
			org.draw(buffGfx);
		}
		g.drawImage(buffImg, 0, 0, this);
	}
	public void iterate()	{
		//System.out.println("__________________");
		//System.out.println("begin iterate");
		/*for (int i=0;i<red.size();i++)	{
			((Organism)red.elementAt(i)).move();
		}
		for (int i=0;i<blue.size();i++)	{
			((Organism)blue.elementAt(i)).move();
		}*/
		//siz=keys.size();
		/*for (int i=0;i<siz;i++)	{
			try	{
				((Organism)orgs.get((Integer)(keys.elementAt(i)))).move();
			} catch(Exception e)	{System.out.println("curiositY");}
			System.out.println(keys.elementAt(i));
		}*/
		//System.out.println(orgs.size());
		for (int i=0;i<orgs.size();i++)	{
			//System.out.println("Begin move" + i);
			((Organism)orgs.elementAt(i)).move();
			//System.out.println("End move");
		}
		//System.out.println("Reassign");
		Organism.reassign();
		//System.out.println("End reassign");
		//battles, mating...FOR NOW, redundancy isn't important (so it exists, naturally!), but later it might be, & this would have to be changed
		/*for (int i=0;i<red.size();i++)	{
			((Organism)red.elementAt(i)).pickAFight();
			((Organism)red.elementAt(i)).pickAMate();
		}
		for (int i=0;i<blue.size();i++)	{
			((Organism)blue.elementAt(i)).pickAFight();
			((Organism)blue.elementAt(i)).pickAMate();
		}*/
		//siz=newSiz;
		for (int i=0;i<orgs.size();i++)	{
			//System.out.println("Begin pickafight" + i);
			((Organism)orgs.elementAt(i)).pickAFight();
			//System.out.println("End pickafight");
			if ((((Organism)orgs.elementAt(i)).sex[1]) && (((Organism)orgs.elementAt(i)).age>8))	{
				//System.out.println("begin mate" + i);
				((Organism)orgs.elementAt(i)).pickAMate();
				//System.out.println("End mate");
			}
		}
		//siz=newSiz;//jus in case
		iterationNumber++;
		iterLabel.setText("Iteration # " + (new Integer(iterationNumber)).toString());
		//System.out.println("End iterate");
	}
	/*public boolean keyDown(Event e, int key)	{
		if (!running)
			iterate();
		else	{
			kicker.stop();
			running=false;
			goButton.setLabel("Run");
			kicker=new Thread(this);
		}
		return true;
	}*/
	public void run()	{
		while ((running) && (orgs.size()>0))	{//(siz>0))	{//(keys.size()>0))	{//((red.size()>0) || (blue.size()>0)))	{
			iterate();
			repaint();	//i forgot this at first..
			try	{
				Thread.sleep(iterationDelay);
				Thread.yield();
			} catch(Exception e)	{System.out.println("Gotcha!");}
		}
		goButton.setLabel("Run");
		running=false;
		kicker=new Thread(this);
		iterationNumber=0;
	}
	public void actionPerformed(ActionEvent e)	{
		if (!running)	{
			running=true;
			goButton.setLabel("Stop");
			kicker.start();
		}
		else	{
			kicker.stop();
			running=false;
			goButton.setLabel("Run");
			kicker=new Thread(this);
		}
	}
	public void mousePressed(MouseEvent e)	{}
	public void mouseClicked(MouseEvent e)	{
		int x=(int)Math.floor(e.getX()/ADescolada.cellWidth);
		int y=(int)Math.floor(e.getY()/ADescolada.cellHeight);
		if (which==2)	{
			((Organism)(ADescolada.orgs.elementAt(ADescolada.keys[x+ADescolada.height*y]))).showInfo();
		}
		else if (which==1)	{
			if (keys[x+ADescolada.width*y]==-1)	{
				keys[x+y*ADescolada.width]=-2;
				foods.addElement(new Integer(x+y*ADescolada.width));
				repaint();
			}
			else if (keys[x+ADescolada.width*y]==-2)	{
				keys[x+y*ADescolada.width]=-1;
				foods.removeElementAt(x+y*ADescolada.width);
				repaint();
			}
			else	{
				Organism org=(Organism)ADescolada.orgs.elementAt(keys[x+ADescolada.width*y]);
				org.die();
			}
		}
		else	{
		if (keys[x+ADescolada.width*y]==-1)	{
			Organism org;
			boolean[] genes=new boolean[10];
			Color col=null;
			switch (this.strength.getSelectedIndex())	{
				case 0:
					genes[0]=false;
					genes[1]=false;
					genes[2]=false;
					break;
				case 1:
					int rnb=(int)Math.floor(3*Math.random());
					for (int i=0;i<3;i++)	{
						if (i==rnb)
							genes[i]=true;
						else
							genes[i]=false;
					}
					break;
				case 2:
					int rnd=(int)Math.floor(3*Math.random());
					for (int i=0;i<3;i++)	{
						if (i==rnd)
							genes[i]=false;
						else
							genes[i]=true;
					}
					break;
				case 3:
					genes[0]=true;
					genes[1]=true;
					genes[2]=true;
					break;
			}
			switch (this.ms.getSelectedIndex())	{
				case 0:
					genes[3]=false;
					genes[4]=false;
					break;
				case 1:
					if (Math.random()<.5)
						genes[3]=true;
					else
						genes[3]=false;
					genes[4]=!genes[3];
					break;
				case 2:
					genes[3]=true;
					genes[4]=true;
					break;
			}
			switch (this.md.getSelectedIndex())	{
				case 0:
					genes[5]=false;
					genes[6]=false;
					break;
				case 1:
					if (Math.random()<.5)
						genes[5]=true;
					else
						genes[5]=false;
					genes[6]=!genes[5];
					break;
				case 2:
					genes[5]=true;
					genes[6]=true;
					break;
			}
			switch (this.sex.getSelectedIndex())	{
				case 0:
					genes[7]=false;
					break;
				case 1:
					genes[7]=true;
					break;
			}
			switch (this.color.getSelectedIndex())	{
				case 0:
					col=Color.red;
					break;
				case 1:
					col=Color.blue;
					break;
			}
			switch (this.lifespan.getSelectedIndex())	{
				case 0:
					genes[8]=false;
					genes[9]=false;
					break;
				case 1:
					if (Math.random()<.5)
						genes[8]=true;
					else
						genes[8]=false;
					genes[9]=!genes[8];
					break;
				case 2:
					genes[8]=true;
					genes[9]=true;
					break;
			}
			org=new Organism(x, y, col, genes[0], genes[1], genes[2], genes[3], genes[4], genes[5], genes[6], genes[7], genes[8], genes[9]);
			ADescolada.orgs.addElement(org);
		//addition to keys is inside orgs contructor
			repaint();
		}
		else if (keys[x+y*ADescolada.width]!=-2)	{
			Organism org=(Organism)ADescolada.orgs.elementAt(keys[x+ADescolada.width*y]);
			org.die();
		}
		else	{
			keys[x+y*ADescolada.width]=-1;
			foods.removeElement(new Integer(x+y*ADescolada.width));
			repaint();
		}
		}
	}
	public void mouseReleased(MouseEvent e)	{}
	public void mouseEntered(MouseEvent e)	{}
	public void mouseExited(MouseEvent e)	{}
	public static void battle(Organism a, Organism b)	{
		//System.out.println("Brawl!");
		if (a.getStrength()>b.getStrength())	{
			b.die();
			//experience points? shorter life? more strength? etc? but DON'T change genes!!
		}
		else if (b.getStrength()>a.getStrength())	{
			a.die();
			//see above comment
		}
		else	{
			//nothing happens...think about: decrease boths' strength by one? (but NOT genes!!)
		}
	}
	public static void mate(Organism male, Organism female)	{
		//System.out.println("Mate! and i don't mean check...");
		female.pregnant=true;
		female.embryo=combine(male, female);
		//System.out.println("all done");
	}
	public static boolean[] combine(Organism dad, Organism mom)	{
		boolean[] returnval=new boolean[10];
		int dec=(int)(Math.random()*6);
		int[] flags=new int[2];
		switch(dec)	{
			case 0:
				returnval[0]=dad.strength[0];
				flags[0]=1;
				break;
			case 1:
				returnval[0]=dad.strength[1];
				flags[0]=2;
				break;
			case 2:
				returnval[0]=dad.strength[2];
				flags[0]=3;
				break;
			case 3:
				returnval[0]=mom.strength[0];
				flags[0]=4;
				break;
			case 4:
				returnval[0]=mom.strength[1];
				flags[0]=5;
				break;
			case 5:
				returnval[0]=mom.strength[2];
				flags[0]=6;
				break;
		}
		//System.out.println("First strength done");
		dec=(int)(Math.random()*6);
		boolean undone=true;
		while (undone)	{
			dec=(int)(Math.random()*6);
			switch(dec)	{	//add if statements
				case 0:
					if (flags[0]!=1)	{
						returnval[1]=dad.strength[0];
						flags[1]=1;
						undone=false;
					}
					break;
				case 1:
					if (flags[0]!=2)	{
						returnval[1]=dad.strength[1];
						flags[1]=2;
						undone=false;
					}
					break;
				case 2:
					if (flags[0]!=3)	{
						returnval[1]=dad.strength[2];
						flags[1]=3;
						undone=false;
					}
					break;
				case 3:
					if (flags[0]!=4)	{
						returnval[1]=mom.strength[0];
						flags[1]=4;
						undone=false;
					}
					break;
				case 4:
					if (flags[0]!=5)	{
						returnval[1]=mom.strength[1];
						flags[1]=5;
						undone=false;
					}
					break;
				case 5:
					if (flags[0]!=6)	{
						returnval[1]=mom.strength[2];
						flags[1]=6;
						undone=false;
					}
					break;
			}
		}
		//System.out.println("2nd strength done");
		undone=true;
		dec=(int)(Math.random()*6);
		while (undone)	{
			dec=(int)(Math.random()*6);
			switch(dec)	{	//add if statements
				case 0:
					if ((flags[0]!=1) && (flags[1]!=1))	{
						returnval[2]=dad.strength[0];
						undone=false;
					}
					break;
				case 1:
					if ((flags[0]!=2) && (flags[1]!=2))	{
						returnval[2]=dad.strength[1];
						undone=false;
					}
					break;
				case 2:
					if ((flags[0]!=3) && (flags[1]!=3))	{
						returnval[2]=dad.strength[2];
						undone=false;
					}
					break;
				case 3:
					if ((flags[0]!=4) && (flags[1]!=4))	{
						returnval[2]=mom.strength[0];
						undone=false;
					}
					break;
				case 4:
					if ((flags[0]!=5) && (flags[1]!=5))	{
						returnval[2]=mom.strength[1];
						undone=false;
					}
					break;
				case 5:
					if ((flags[0]!=6) && (flags[1]!=6))	{
						returnval[2]=mom.strength[2];
						undone=false;
					}
					break;
			}
		}
		//System.out.println("3rd strength done");
		flags=null;
		dec=(int)(Math.random()*2);
		if (dec==0)	{
			returnval[3]=dad.movementSame[(int)(Math.random()*2)];
			returnval[4]=mom.movementSame[(int)(Math.random()*2)];
		}
		else	{
			returnval[3]=mom.movementSame[(int)(Math.random()*2)];
			returnval[4]=dad.movementSame[(int)(Math.random()*2)];
		}
		dec=(int)(Math.random()*2);
		if (dec==0)	{
			returnval[5]=dad.movementDiff[(int)(Math.random()*2)];
			returnval[6]=mom.movementDiff[(int)(Math.random()*2)];
		}
		else	{
			returnval[5]=mom.movementDiff[(int)(Math.random()*2)];
			returnval[6]=dad.movementDiff[(int)(Math.random()*2)];
		}
		returnval[7]=dad.sex[(int)(Math.random()*2)];
		dec=(int)(Math.random()*2);
		if (dec==0)	{
			returnval[8]=dad.lifespan[(int)(Math.random()*2)];
			returnval[9]=mom.lifespan[(int)(Math.random()*2)];
		}
		else	{
			returnval[8]=mom.lifespan[(int)(Math.random()*2)];
			returnval[9]=dad.lifespan[(int)(Math.random()*2)];
		}
		return returnval;
	}
	public static void makeFood()	{
		boolean done=false;
		while (!done)	{
			int x=(int)Math.floor(Math.random()*ADescolada.width);
			int y=(int)Math.floor(Math.random()*ADescolada.height);
			if (keys[x+width*y]==-1)	{
				keys[x+y*width]=-2;
				foods.addElement(new Integer(x+y*width));
				done=true;
			}
		}
	}
}
public class Organism	{
	int[] location;
	Color color, NOTcol;
	boolean[] strength;
	boolean[] movementSame;
	boolean[] movementDiff;
	boolean[] sex;
	boolean[] lifespan;
	boolean pregnant;
	int age, lifeExpectancy;
	boolean[] embryo;
	int key;
	int pregCounter;
	int foodCounter;
	public Organism(int x, int y, Color col, boolean s1, boolean s2, boolean s3, boolean ms1, boolean ms2, boolean md1, boolean md2, boolean gender, boolean LS1, boolean LS2)	{
		age=0;
		this.foodCounter=0;
		this.key=ADescolada.orgs.size();//make sure this works...
		ADescolada.keys[x+y*ADescolada.width]=this.key;
		location=new int[2];
		location[0]=x;
		location[1]=y;
		strength=new boolean[3];
		strength[0]=s1;
		strength[1]=s2;
		strength[2]=s3;
		movementSame=new boolean[2];
		movementSame[0]=ms1;
		movementSame[1]=ms2;
		movementDiff=new boolean[2];
		movementDiff[0]=md1;
		movementDiff[1]=md2;
		sex=new boolean[2];
		sex[0]=false;
		sex[1]=gender;
		lifespan=new boolean[2];
		lifespan[0]=LS1;
		lifespan[1]=LS2;
		lifeExpectancy=60;
		if (LS1)
			lifeExpectancy+=15;
		if (LS2)
			lifeExpectancy+=15;
		pregnant=false;
		color=col;
		if (col==Color.red)
			this.NOTcol=Color.blue;
		else
			this.NOTcol=Color.red;
		if (!sex[1])
			embryo=new boolean[10];
		this.pregCounter=0;
	}
	public Organism(int x, int y, Color col, boolean[] embryoDNA)	{
		age=0;
		this.foodCounter=0;
		location=new int[2];
		location[0]=x;
		location[1]=y;
		strength=new boolean[3];
		strength[0]=embryoDNA[0];
		strength[1]=embryoDNA[1];
		strength[2]=embryoDNA[2];
		movementSame=new boolean[2];
		movementSame[0]=embryoDNA[3];
		movementSame[1]=embryoDNA[4];
		movementDiff=new boolean[2];
		movementDiff[0]=embryoDNA[5];
		movementDiff[1]=embryoDNA[6];
		sex=new boolean[2];
		sex[0]=false;
		sex[1]=embryoDNA[7];
		lifespan=new boolean[2];
		lifespan[0]=embryoDNA[8];
		lifespan[1]=embryoDNA[9];
		lifeExpectancy=10;
		if (lifespan[0])
			lifeExpectancy+=10;
		if (lifespan[1])
			lifeExpectancy+=10;
		pregnant=false;
		color=col;
		if (!sex[1])
			embryo=new boolean[10];
		this.pregCounter=0;
	}
	public void move()	{
		age++;
		foodCounter++;
		if (this.pregnant)
			this.pregCounter++;
	if ((age>lifeExpectancy) && (Math.random()<.1))	{
		this.die();
	}
	if (this.foodCounter>20)	{
		this.die();
	}
	else	{
		//there are 4 possible moves--how about give them strength based on genes' preference?
		int up=2, down=2, left=2, right=2;	//start at 2 so can add OR subtract right off
		//have to have separate if sequences for ms, md...darn...or imbed...yuck...OR!! this way
		if (((!check(this.location[0], this.location[1]-1)) && (!check(this.location[0]-1, this.location[1])) && (!check(this.location[0], this.location[1]+1)) && (!check(this.location[0]+1, this.location[1]))) || this.age==0)	{
			//can't move
		}
		else	{
			//ADescolada.orgs.remove(this);
			//ADescolada.keys.removeElement(new Integer(this.location[0]+ADescolada.width*this.location[1]));
			if ((!sex[1]) && (this.pregnant) && (Math.random()>.15) && (this.pregCounter>3))	{
				Organism offspring;
				//System.out.println("birth! miraculous birth!");
				pregCounter=0;
				for (int dec=(int)(Math.random()*4);pregnant;dec++)	{
					if ((dec==0) && (this.location[1]>0))	{
						if (ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]-1)]<0)	{//ADescolada.orgs.get(new Integer(this.location[0]+ADescolada.width*(this.location[1]-1)))!=null)	{//ADescolada.orgArray[this.location[0]+ADescolada.width*(this.location[1]-1)]==0)	{
							if (ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]-1)]==-2)	{
								ADescolada.foods.removeElement(new Integer(this.location[0]+ADescolada.width*(this.location[1]-1)));
								ADescolada.makeFood();
							}
							offspring=new Organism(this.location[0], this.location[1]--, this.color, embryo);
							offspring.age=-1;
							this.pregnant=false;
							//if (this.col==Color.red)	{
								//ADescolada.red.addElement(offspring);
								//ADescolada.orgArray[this.location[0]+ADescolada.width*(this.location[1]-1)]=1;
							ADescolada.orgs.addElement(offspring);
							/*ADescolada.orgs.put(new Integer(this.location[0]+ADescolada.width*(this.location[1]-1)), offspring);
							ADescolada.keys.addElement(new Integer(this.location[0]+ADescolada.width*(this.location[1]-1)));
							ADescolada.newSiz++;*/
							//}
							//else	{
							//	ADescolada.blue.addElement(offspring);
							//	ADescolada.orgArray[this.location[0]+ADescolada.width*(this.location[1]-1)]=2;
							//}
						}
					}
					else if ((dec==1) && (this.location[0]<(ADescolada.width-1)))	{
						if (ADescolada.keys[this.location[0]+1+ADescolada.width*this.location[1]]<0)	{//ADescolada.orgs.get(new Integer(this.location[0]+1+ADescolada.width*(this.location[1])))==null)	{
							if (ADescolada.keys[this.location[0]+1+ADescolada.width*this.location[1]]==-2)	{
								ADescolada.foods.removeElement(new Integer(this.location[0]+1+ADescolada.width*this.location[1]));
								ADescolada.makeFood();
							}
							offspring=new Organism(this.location[0]++, this.location[1], this.color, embryo);
							offspring.age=-1;
							this.pregnant=false;
							ADescolada.orgs.addElement(offspring);
							/*ADescolada.orgs.put(new Integer(this.location[0]+1+ADescolada.width*(this.location[1])), offspring);
							ADescolada.newSiz++;
							ADescolada.keys.addElement(new Integer(this.location[0]+1+ADescolada.width*(this.location[1])));*/
							/*if (this.col==Color.red)	{
								ADescolada.red.addElement(offspring);
								ADescolada.orgArray[this.location[0]+1+ADescolada.width*(this.location[1])]=1;
							}
							else	{
								ADescolada.blue.addElement(offspring);
								ADescolada.orgArray[this.location[0]+1+ADescolada.width*(this.location[1])]=2;
							}*/
						}
					}
					else if ((dec==2) && (this.location[1]<(ADescolada.height-1)))	{
						if (ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]+1)]<0)	{//ADescolada.orgs.get(new Integer(this.location[0]+ADescolada.width*(this.location[1]+1)))==null)	{
							if (ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]+1)]==-2)	{
								ADescolada.foods.removeElement(new Integer(this.location[0]+ADescolada.width*(this.location[1]+1)));
								ADescolada.makeFood();
							}
							offspring=new Organism(this.location[0], this.location[1]++, this.color, embryo);
							offspring.age=-1;
							this.pregnant=false;
							ADescolada.orgs.addElement(offspring);
							/*ADescolada.orgs.put(new Integer(this.location[0]+ADescolada.width*(this.location[1]+1)), offspring);
							ADescolada.newSiz++;
							ADescolada.keys.addElement(new Integer(this.location[0]+ADescolada.width*(this.location[1]+1)));*/
							/*if (this.col==Color.red)	{
								ADescolada.red.addElement(offspring);
								ADescolada.orgArray[this.location[0]+ADescolada.width*(this.location[1]+1)]=1;
							}
							else	{
								ADescolada.blue.addElement(offspring);
								ADescolada.orgArray[this.location[0]+ADescolada.width*(this.location[1]+1)]=2;
							}*/
						}
					}
					else if ((dec==3) && (this.location[0]>0))	{
						if (ADescolada.keys[this.location[0]-1+ADescolada.width*(this.location[1])]<0)	{//ADescolada.orgs.get(new Integer(this.location[0]-1+ADescolada.width*(this.location[1])))==null)	{
							if (ADescolada.keys[this.location[0]-1+ADescolada.width*(this.location[1])]==-2)	{
								ADescolada.foods.removeElement(new Integer(this.location[0]-1+ADescolada.width*(this.location[1])));
								ADescolada.makeFood();
							}
							offspring=new Organism(this.location[0]--, this.location[1], this.color, embryo);
							offspring.age=-1;
							this.pregnant=false;
							ADescolada.orgs.addElement(offspring);
							/*ADescolada.orgs.put(new Integer(this.location[0]-1+ADescolada.width*(this.location[1])), offspring);
							ADescolada.newSiz++;
							ADescolada.keys.addElement(new Integer(this.location[0]-1+ADescolada.width*(this.location[1])));*/
							/*if (this.col==Color.red)	{
								ADescolada.red.addElement(offspring);
								ADescolada.orgArray[this.location[0]-1+ADescolada.width*(this.location[1])]=1;
							}
							else	{
								ADescolada.blue.addElement(offspring);
								ADescolada.orgArray[this.location[0]-1+ADescolada.width*(this.location[1])]=2;
							}*/
						}
					}
					else if (dec==4)
						dec=-1;//b/c it will ++ on loop//when terminate????oh, b/c you know there's an opening somewhere....
				}
			}
			else	{
				ADescolada.keys[this.location[0]+ADescolada.width*this.location[1]]=-1;//this was moved so that pregnancies won't take themselves out...
				//System.out.println("on the road...");
				if ((!movementSame[0]) && (!movementSame[1]))	{	//away from same col...
					//scan for nearby (w/in 2 moves) org's
					//rate moves accordingly
					//if (this.color==Color.red)	{
					try	{
						if ((this.location[1]>1) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]-2)])).color==this.color))
							up--;
					} catch(Exception e)	{}
					try	{
						if ((this.location[0]>1) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]-2+ADescolada.width*this.location[1]])).color==this.color))
							left--;
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]<(ADescolada.height-2)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]+2)])).color==this.color))
							down--;
					} catch(Exception e)	{}
					try	{
						if ((this.location[0]<(ADescolada.width-2)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+2+ADescolada.width*this.location[1]])).color==this.color))
							right--;
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]>0) && (this.location[0]>0) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]-1+ADescolada.width*(this.location[1]-1)])).color==this.color))	{
							left--;
							up--;
						}
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]>0) && (this.location[0]<(ADescolada.width-1)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+1+ADescolada.width*(this.location[1]-1)])).color==this.color))	{
							right--;
							up--;
						}
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]<(ADescolada.height-1)) && (this.location[0]<(ADescolada.width-1)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+1+ADescolada.width*(this.location[1]+1)])).color==this.color))	{
							right--;
							down--;
						}
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]<(ADescolada.height-1)) && (this.location[0]>0) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]-1+ADescolada.width*(this.location[1]+1)])).color==this.color))	{
							left--;
							down--;
						}
					} catch(Exception e)	{}
					//}
					/*else	{
						if ((this.location[1]>1) && (ADescolada.orgArray[this.location[0]+ADescolada.width*(this.location[1]-2)]==2))
							up--;
						if ((this.location[0]>1) && (ADescolada.orgArray[this.location[0]-2+ADescolada.width*this.location[1]]==2))
							left--;
						if ((this.location[1]<(ADescolada.height-2)) && (ADescolada.orgArray[this.location[0]+ADescolada.width*(this.location[1]+2)]==2))
							down--;
						if ((this.location[0]<(ADescolada.width-2)) && (ADescolada.orgArray[this.location[0]+2+ADescolada.width*this.location[1]]==2))
							right--;
						if ((this.location[1]>0) && (this.location[0]>0) && (ADescolada.orgArray[this.location[0]-1+ADescolada.width*(this.location[1]-1)]==2))	{
							left--;
							up--;
						}
						if ((this.location[1]>0) && (this.location[0]<(ADescolada.width-1)) && (ADescolada.orgArray[this.location[0]+1+ADescolada.width*(this.location[1]-1)]==2))	{
							right--;
							up--;
						}
						if ((this.location[1]<(ADescolada.height-1)) && (this.location[0]<(ADescolada.width-1)) && (ADescolada.orgArray[this.location[0]+1+ADescolada.width*(this.location[1]+1)]==2))	{
							right--;
							down--;
						}
						if ((this.location[1]<(ADescolada.height-1)) && (this.location[0]>0) && (ADescolada.orgArray[this.location[0]-1+ADescolada.width*(this.location[1]+1)]==2))	{
							left--;
							down--;
						}
					}*/
				}
				else if ((movementSame[0]) && (movementSame[1]))	{	//towards same col...
					//if (this.color==Color.red)	{
					try	{
						if ((this.location[1]>1) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]-2)])).color==this.color))
							up++;
					} catch(Exception e)	{}
					try	{
						if ((this.location[0]>1) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]-2+ADescolada.width*this.location[1]])).color==this.color))
							left++;
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]<(ADescolada.height-2)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]+2)])).color==this.color))
							down++;
					} catch(Exception e)	{}
					try	{
						if ((this.location[0]<(ADescolada.width-2)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+2+ADescolada.width*this.location[1]])).color==this.color))
							right++;
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]>0) && (this.location[0]>0) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]-1+ADescolada.width*(this.location[1]-1)])).color==this.color))	{
							left++;
							up++;
						}
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]>0) && (this.location[0]<(ADescolada.width-1)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+1+ADescolada.width*(this.location[1]-1)])).color==this.color))	{
							right++;
							up++;
						}
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]<(ADescolada.height-1)) && (this.location[0]<(ADescolada.width-1)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+1+ADescolada.width*(this.location[1]+1)])).color==this.color))	{
							right++;
							down++;
						}
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]<(ADescolada.height-1)) && (this.location[0]>0) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]-1+ADescolada.width*(this.location[1]+1)])).color==this.color))	{
							left++;
							down++;
						}
					} catch(Exception e)	{}
					//}
					/*else	{
						if ((this.location[1]>1) && (ADescolada.orgArray[this.location[0]+ADescolada.width*(this.location[1]-2)]==2))
							up++;
						if ((this.location[0]>1) && (ADescolada.orgArray[this.location[0]-2+ADescolada.width*this.location[1]]==2))
							left++;
						if ((this.location[1]<(ADescolada.height-2)) && (ADescolada.orgArray[this.location[0]+ADescolada.width*(this.location[1]+2)]==2))
							down++;
						if ((this.location[0]<(ADescolada.width-2)) && (ADescolada.orgArray[this.location[0]+2+ADescolada.width*this.location[1]]==2))
							right++;
						if ((this.location[1]>0) && (this.location[0]>0) && (ADescolada.orgArray[this.location[0]-1+ADescolada.width*(this.location[1]-1)]==2))	{
							left++;
							up++;
						}
						if ((this.location[1]>0) && (this.location[0]<(ADescolada.width-1)) && (ADescolada.orgArray[this.location[0]+1+ADescolada.width*(this.location[1]-1)]==2))	{
							right++;
							up++;
						}
						if ((this.location[1]<(ADescolada.height-1)) && (this.location[0]<(ADescolada.width-1)) && (ADescolada.orgArray[this.location[0]+1+ADescolada.width*(this.location[1]+1)]==2))	{
							right++;
							down++;
						}
						if ((this.location[1]<(ADescolada.height-1)) && (this.location[0]>0) && (ADescolada.orgArray[this.location[0]-1+ADescolada.width*(this.location[1]+1)]==2))	{
							left++;
							down++;
						}
					}*/
				}
				if ((!movementDiff[0]) && (!movementDiff[1]))	{	//away from diff col...
					//if (this.color==Color.red)	{
					try	{
						if ((this.location[1]>1) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]-2)])).color==this.NOTcol))
							up--;
					} catch(Exception e)	{}
					try	{
						if ((this.location[0]>1) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]-2+ADescolada.width*this.location[1]])).color==this.NOTcol))
							left--;
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]<(ADescolada.height-2)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]+2)])).color==this.NOTcol))
							down--;
					} catch(Exception e)	{}
					try	{
						if ((this.location[0]<(ADescolada.width-2)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+2+ADescolada.width*this.location[1]])).color==this.NOTcol))
							right--;
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]>0) && (this.location[0]>0) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]-1+ADescolada.width*(this.location[1]-1)])).color==this.NOTcol))	{
							left--;
							up--;
						}
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]>0) && (this.location[0]<(ADescolada.width-1)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+1+ADescolada.width*(this.location[1]-1)])).color==this.NOTcol))	{
							right--;
							up--;
						}
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]<(ADescolada.height-1)) && (this.location[0]<(ADescolada.width-1)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+1+ADescolada.width*(this.location[1]+1)])).color==this.NOTcol))	{
							right--;
							down--;
						}
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]<(ADescolada.height-1)) && (this.location[0]>0) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]-1+ADescolada.width*(this.location[1]+1)])).color==this.NOTcol))	{
							left--;
							down--;
						}
					} catch(Exception e)	{}
					//}
					/*else	{
						if ((this.location[1]>1) && (ADescolada.orgArray[this.location[0]+ADescolada.width*(this.location[1]-2)]==1))
							up--;
						if ((this.location[0]>1) && (ADescolada.orgArray[this.location[0]-2+ADescolada.width*this.location[1]]==1))
							left--;
						if ((this.location[1]<(ADescolada.height-2)) && (ADescolada.orgArray[this.location[0]+ADescolada.width*(this.location[1]+2)]==1))
							down--;
						if ((this.location[0]<(ADescolada.width-2)) && (ADescolada.orgArray[this.location[0]+2+ADescolada.width*this.location[1]]==1))
							right--;
						if ((this.location[1]>0) && (this.location[0]>0) && (ADescolada.orgArray[this.location[0]-1+ADescolada.width*(this.location[1]-1)]==1))	{
							left--;
							up--;
						}
						if ((this.location[1]>0) && (this.location[0]<(ADescolada.width-1)) && (ADescolada.orgArray[this.location[0]+1+ADescolada.width*(this.location[1]-1)]==1))	{
							right--;
							up--;
						}
						if ((this.location[1]<(ADescolada.height-1)) && (this.location[0]<(ADescolada.width-1)) && (ADescolada.orgArray[this.location[0]+1+ADescolada.width*(this.location[1]+1)]==1))	{
							right--;
							down--;
						}
						if ((this.location[1]<(ADescolada.height-1)) && (this.location[0]>0) && (ADescolada.orgArray[this.location[0]-1+ADescolada.width*(this.location[1]+1)]==1))	{
							left--;
							down--;
						}
					}*/
				}
				else if ((movementDiff[0]) && (movementDiff[1]))	{	//towards diff col...
					//if (this.color==Color.red)	{
					try	{
						if ((this.location[1]>1) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]-2)])).color==this.NOTcol))
							up++;
					} catch(Exception e)	{}
					try	{
						if ((this.location[0]>1) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]-2+ADescolada.width*this.location[1]])).color==this.NOTcol))
							left++;
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]<(ADescolada.height-2)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]+2)])).color==this.NOTcol))
							down++;
					} catch(Exception e)	{}
					try	{
						if ((this.location[0]<(ADescolada.width-2)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+2+ADescolada.width*this.location[1]])).color==this.NOTcol))
							right++;
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]>0) && (this.location[0]>0) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]-1+ADescolada.width*(this.location[1]-1)])).color==this.NOTcol))	{
							left++;
							up++;
						}
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]>0) && (this.location[0]<(ADescolada.width-1)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+1+ADescolada.width*(this.location[1]-1)])).color==this.NOTcol))	{
							right++;
							up++;
						}
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]<(ADescolada.height-1)) && (this.location[0]<(ADescolada.width-1)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+1+ADescolada.width*(this.location[1]+1)])).color==this.NOTcol))	{
							right++;
							down++;
						}
					} catch(Exception e)	{}
					try	{
						if ((this.location[1]<(ADescolada.height-1)) && (this.location[0]>0) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]-1+ADescolada.width*(this.location[1]+1)])).color==this.NOTcol))	{
							left++;
							down++;
						}
					} catch(Exception e)	{}
					//}
					/*else	{
						if ((this.location[1]>1) && (ADescolada.orgArray[this.location[0]+ADescolada.width*(this.location[1]-2)]==1))
							up++;
						if ((this.location[0]>1) && (ADescolada.orgArray[this.location[0]-2+ADescolada.width*this.location[1]]==1))
							left++;
						if ((this.location[1]<(ADescolada.height-2)) && (ADescolada.orgArray[this.location[0]+ADescolada.width*(this.location[1]+2)]==1))
							down++;
						if ((this.location[0]<(ADescolada.width-2)) && (ADescolada.orgArray[this.location[0]+2+ADescolada.width*this.location[1]]==1))
							right++;
						if ((this.location[1]>0) && (this.location[0]>0) && (ADescolada.orgArray[this.location[0]-1+ADescolada.width*(this.location[1]-1)]==1))	{
							left++;
							up++;
						}
						if ((this.location[1]>0) && (this.location[0]<(ADescolada.width-1)) && (ADescolada.orgArray[this.location[0]+1+ADescolada.width*(this.location[1]-1)]==1))	{
							right++;
							up++;
						}
						if ((this.location[1]<(ADescolada.height-1)) && (this.location[0]<(ADescolada.width-1)) && (ADescolada.orgArray[this.location[0]+1+ADescolada.width*(this.location[1]+1)]==1))	{
							right++;
							down++;
						}
						if ((this.location[1]<(ADescolada.height-1)) && (this.location[0]>0) && (ADescolada.orgArray[this.location[0]-1+ADescolada.width*(this.location[1]+1)]==1))	{
							left++;
							down++;
						}
					}*/
				}
				//evaluate move ranks
				boolean upb, rightb, downb, leftb;
				upb=check(this.location[0], this.location[1]-1);
				rightb=check(this.location[0]+1, this.location[1]);
				downb=check(this.location[0], this.location[1]+1);
				leftb=check(this.location[0]-1, this.location[1]);
				int high=up;
				if (right>high)
					high=right;
				if (down>high)
					high=down;
				if (left>high)
					high=left;
				int counter=0;
				Vector yes=new Vector();
				for (int i=high;counter==0;i--)	{
					if ((up==i) && (upb))	{
						counter++;
						yes.addElement(new Integer(0));
					}
					if ((right==i) && (rightb))	{
						counter++;
						yes.addElement(new Integer(1));
					}
					if ((down==i) && (downb))	{
						counter++;
						yes.addElement(new Integer(2));
					}
					if ((left==i) && (leftb))	{
						counter++;
						yes.addElement(new Integer(3));
					}
				}
				if (counter==0)	{
					//somethin's up!
					System.out.println("fd up");
				}
				else	{
					//something
					int dir=(int)Math.floor(counter*(Math.random()));
					int move;
					move=((Integer)yes.elementAt(dir)).intValue();
					switch (move)	{
						case 0:
							/*ADescolada.orgArray[this.location[0]+(this.location[1]-1)*ADescolada.width]=ADescolada.orgArray[this.location[0]+this.location[1]*ADescolada.width];
							ADescolada.orgArray[this.location[0]+this.location[1]*ADescolada.width]=0;*/
							/*ADescolada.orgs.remove(this);
							ADescolada.keys.removeElement(new Integer(this.location[0]+this.location[1]*ADescolada.width));
							ADescolada.orgs.put(new Integer(this.location[0]+(this.location[1]-1)*ADescolada.width), this);
							ADescolada.keys.addElement(new Integer(this.location[0]+(this.location[1]-1)*ADescolada.width));*/
							this.location[1]--;
							break;
						case 1:
							/*ADescolada.orgArray[this.location[0]+1+this.location[1]*ADescolada.width]=ADescolada.orgArray[this.location[0]+this.location[1]*ADescolada.width];
							ADescolada.orgArray[this.location[0]+this.location[1]*ADescolada.width]=0;*/
							/*ADescolada.orgs.remove(this);
							ADescolada.keys.removeElement(new Integer(this.location[0]+this.location[1]*ADescolada.width));
							ADescolada.orgs.put(new Integer(this.location[0]+1+this.location[1]*ADescolada.width), this);
							ADescolada.keys.addElement(new Integer(this.location[0]+1+this.location[1]*ADescolada.width));*/
							this.location[0]++;
							break;
						case 2:
							/*ADescolada.orgArray[this.location[0]+(this.location[1]+1)*ADescolada.width]=ADescolada.orgArray[this.location[0]+this.location[1]*ADescolada.width];
							ADescolada.orgArray[this.location[0]+this.location[1]*ADescolada.width]=0;*/
							/*ADescolada.orgs.remove(this);
							ADescolada.keys.removeElement(new Integer(this.location[0]+this.location[1]*ADescolada.width));
							ADescolada.orgs.put(new Integer(this.location[0]+(this.location[1]+1)*ADescolada.width), this);
							ADescolada.keys.addElement(new Integer(this.location[0]+(this.location[1]+1)*ADescolada.width));*/
							this.location[1]++;
							break;
						case 3:
							/*ADescolada.orgArray[this.location[0]-1+this.location[1]*ADescolada.width]=ADescolada.orgArray[this.location[0]+this.location[1]*ADescolada.width];
							ADescolada.orgArray[this.location[0]+this.location[1]*ADescolada.width]=0;*/
							/*ADescolada.orgs.remove(this);
							ADescolada.keys.removeElement(new Integer(this.location[0]+this.location[1]*ADescolada.width));
							ADescolada.orgs.put(new Integer(this.location[0]-1+this.location[1]*ADescolada.width), this);
							ADescolada.keys.addElement(new Integer(this.location[0]-1+this.location[1]*ADescolada.width));*/
							this.location[0]--;
							break;
					}
				}
				if (ADescolada.keys[this.location[0]+ADescolada.width*this.location[1]]==-2)	{
					this.foodCounter=0;
					ADescolada.foods.removeElement(new Integer(this.location[0]+ADescolada.width*this.location[1]));
					ADescolada.makeFood();
				}
				ADescolada.keys[this.location[0]+ADescolada.width*this.location[1]]=this.key;//moved...
			}
			//ADescolada.orgs.remove(this);    MOVED THIS
			//ADescolada.keys.removeElement(new Integer(this.location[0]+ADescolada.width*this.location[1]));
			/*ADescolada.keys.addElement(new Integer(this.location[0]+ADescolada.width*this.location[1]));
			ADescolada.orgs.put(new Integer(this.location[0]+ADescolada.width*this.location[1]), this);*/
		}
	}
	}
	public void draw(Graphics g)	{
		g.setColor(this.color);
		if (this.sex[1])
			g.fillRect(this.location[0]*ADescolada.cellWidth+2, this.location[1]*ADescolada.cellHeight+2, ADescolada.cw-3, ADescolada.ch-3);
		else
			g.fillOval(this.location[0]*ADescolada.cellWidth+2, this.location[1]*ADescolada.cellHeight+2, ADescolada.cw-3, ADescolada.ch-3);
	}
	public static boolean check(int x, int y)	{
		if ((x<0) || (y<0) || (x>(ADescolada.width-1)) || (y>(ADescolada.height-1)))	{
			return false;
		}
		/*for (int i=0;i<ADescolada.red.size();i++)	{
			if ((((Organism)ADescolada.red.elementAt(i)).location[0]==x) && (((Organism)ADescolada.red.elementAt(i)).location[1]==y))	{
				return false;
			}
		}
		for (int i=0;i<ADescolada.blue.size();i++)	{
			if ((((Organism)ADescolada.blue.elementAt(i)).location[0]==x) && (((Organism)ADescolada.blue.elementAt(i)).location[1]==y))	{
				return false;
			}
		}*/
		//for (int i=0;i<ADescolada.keys.size();i++)	{
			//if (keys[x+ADescolada.width*y]!=-1)	{//((((Organism)ADescolada.orgs.get((Integer)(ADescolada.keys.elementAt(i)))).location[0]==x) && (((Organism)ADescolada.orgs.get((Integer)(ADescolada.keys.elementAt(i)))).location[1]==y))	{
			//	return false;
			//}
		//}
		return (ADescolada.keys[x+ADescolada.width*y]<0);
	}
	public void die()	{
		/*if (this.color==Color.red)	{
			ADescolada.red.removeElement(this);
			//ADescolada.red.pack();
		}
		else	{
			ADescolada.blue.removeElement(this);
			//ADescolada.blue.pack();
		}*/
		//System.out.println("Dath...aaa");
		ADescolada.orgs.removeElementAt(ADescolada.keys[this.location[0]+ADescolada.width*this.location[1]]);
		ADescolada.keys[this.location[0]+ADescolada.width*this.location[1]]=-1;
		reassign();//????? ok...might be slow!!!!
		//
		//MAKE IT SO THAT KEYS ARE REASSIGNED WHEN VECTOR IS PAKCED...maybe just wait 'till end of iteration
		//
		//ADescolada.orgs.remove(this);
		//ADescolada.newSiz--;
		//ADescolada.siz--;
		//ADescolada.keys.removeElement(new Integer(this.location[0]+ADescolada.width*this.location[1]));	//oh yeah...im an idiot
		//System.out.println(ADescolada.keys.elementAt(0));
	}
	public static void reassign()	{
		Vector tempVector=new Vector();
		int j=0;
		for (int i=0;i<ADescolada.orgs.size();i++)	{
			if (ADescolada.orgs.elementAt(i)!=null)	{
				Organism tempOrg=(Organism)ADescolada.orgs.elementAt(i);
				tempOrg.key=j;
				ADescolada.keys[tempOrg.location[0]+ADescolada.width*tempOrg.location[1]]=j;
				tempVector.addElement(tempOrg);
				j++;
			}
		}
		ADescolada.orgs=tempVector;//HERE**************************
	}
	/*public boolean[] pseudomeiosis()	{
		boolean[] ret=new boolean[10];
		ret[0]=this.strength[0];
		ret[1]=this.strength[1];
		ret[2]=this.strength[2];
		ret[3]=this.movementSame[0];
		ret[4]=this.movementSame[1];
		ret[5]=this.movementDiff[0];
		ret[6]=this.movementDiff[1];
		ret[7]=this.sex[1];
		ret[8]=this.lifespan[0];
		ret[9]=this.lifespan[1];
		return ret;
	}*/
	public int getStrength()	{
		return (strength[0])?((strength[1])?((strength[2])?4:3):((strength[2])?3:2)):((strength[1])?((strength[2])?3:2):((strength[2])?2:1));  //if this works....!!
	}
	public void pickAFight()	{	//check 4 adjacents fer opponents
		try	{
			if ((this.location[1]>0) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]-1)])).color==this.NOTcol))	{
				ADescolada.battle(this, ((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]-1)])));//yep.......!!!!
			}
		} catch(Exception e)	{}
		try	{
			if ((this.location[0]<(ADescolada.width-1)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+1+ADescolada.width*(this.location[1])])).color==this.NOTcol))	{
				ADescolada.battle(this, ((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+1+ADescolada.width*(this.location[1])])));//yep.......!!!!
			}
		} catch(Exception e)	{}
		try	{
			if ((this.location[1]<(ADescolada.height-1)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]+1)])).color==this.NOTcol))	{
				ADescolada.battle(this, ((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]+1)])));//yep.......!!!!
			}
		} catch(Exception e)	{}
		try	{
			if ((this.location[0]>0) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]-1+ADescolada.width*(this.location[1])])).color==this.NOTcol))	{
				ADescolada.battle(this, ((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]-1+ADescolada.width*(this.location[1])])));//yep.......!!!!
			}
		} catch(Exception e)	{}
	}
	public void pickAMate()	{	//check around for babes!!  unless it's female...actually, this is now only called on males haha
		try	{
			if ((this.location[1]>0) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]-1)])).color==this.color) && (!((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]-1)])).sex[1]) && (!((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]-1)])).pregnant))	{
				ADescolada.mate(this, ((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]-1)])));//yep.......!!!!
			}
		} catch(Exception e)	{}
		try	{
			if ((this.location[0]<(ADescolada.width-1)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+1+ADescolada.width*(this.location[1])])).color==this.color) && (!((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+1+ADescolada.width*(this.location[1])])).sex[1]) && (!((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+1+ADescolada.width*(this.location[1])])).pregnant))	{
				ADescolada.mate(this, ((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+1+ADescolada.width*(this.location[1])])));//yep.......!!!!
			}
		} catch(Exception e)	{}
		try	{
			if ((this.location[1]<(ADescolada.height-1)) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]+1)])).color==this.color) && (!((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]+1)])).sex[1]) && (!((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]+1)])).pregnant))	{
				ADescolada.mate(this, ((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]+ADescolada.width*(this.location[1]+1)])));//yep.......!!!!
			}
		} catch(Exception e)	{}
		try	{
			if ((this.location[0]>0) && (((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]-1+ADescolada.width*(this.location[1])])).color==this.color) && (!((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]-1+ADescolada.width*(this.location[1])])).sex[1]) && (!((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]-1+ADescolada.width*(this.location[1])])).pregnant))	{
				ADescolada.mate(this, ((Organism)ADescolada.orgs.elementAt(ADescolada.keys[this.location[0]-1+ADescolada.width*(this.location[1])])));//yep.......!!!!
			}
		} catch(Exception e)	{}
	}
	public void showInfo()	{
		DispWin dw=new DispWin(this.age, this.foodCounter, this.location[0], this.location[1], this.strength[0], this.strength[1], this.strength[2], this.movementSame[0], this.movementSame[1], this.movementDiff[0], this.movementDiff[1], this.sex[1], this.lifespan[0], this.lifespan[1], this.pregnant, this.color);
	}
}
public class createListener implements ActionListener	{
	ADescolada ad;
	public createListener(ADescolada ad)	{
		this.ad=ad;
	}
	public void actionPerformed(ActionEvent e)	{
		//new CreateWin(this.ad);
		this.ad.createFrame.setVisible(true);
	}
}
public class CreateWin extends Frame implements ActionListener, WindowListener	{
	ADescolada ad;
	Choice loca, strengt, msa, mdi, se, colo, lifespa;
	Choice loc, strength, ms, md, sex, color, lifespan;
	public CreateWin(ADescolada ad)	{
		super("Create");
		setLayout(new GridLayout(0,2));
		this.ad=ad;
		loca=new Choice();
		loca.addItem("Location");
		loca.addItem("x-coordinate, y-coordinate");
		strengt=new Choice();
		strengt.addItem("Strength");
		strengt.addItem("1=weakest, 4=strongest");
		msa=new Choice();
		msa.addItem("Move Same");
		msa.addItem("1=move away from same color");
		msa.addItem("2=no preference");
		msa.addItem("3=move towards same color");
		mdi=new Choice();
		mdi.addItem("Move Different");
		mdi.addItem("1=move away from other color");
		mdi.addItem("2=no preference");
		mdi.addItem("3=move towards other color");
		se=new Choice();
		se.addItem("Gender");
		colo=new Choice();
		colo.addItem("Color/tribe of new organism");
		lifespa=new Choice();
		lifespa.addItem("Natural Lifespan");
		lifespa.addItem("1=shortest");
		lifespa.addItem("2=medium");
		lifespa.addItem("3=longest");
		this.loc=new Choice();
		for (int i=0;i<ADescolada.width;i++)	{
			for (int j=0;j<ADescolada.height;j++)	{
				if ((Organism.check(i, j)) && (ADescolada.keys[i+ADescolada.width*j]!=-2))	{
					loc.addItem("" + i + ", " + j);
				}
				else	{
					//System.out.println("Success*");
					loc.addItem("*" + i + ", " + j);
				}
			}
		}
		this.strength=new Choice();
		this.strength.addItem("1");
		this.strength.addItem("2");
		this.strength.addItem("3");
		this.strength.addItem("4");
		this.strength.select(1);
		this.ms=new Choice();
		this.ms.addItem("1");
		this.ms.addItem("2");
		this.ms.addItem("3");
		this.ms.select(1);
		this.md=new Choice();
		this.md.addItem("1");
		this.md.addItem("2");
		this.md.addItem("3");
		this.md.select(1);
		this.color=new Choice();
		this.color.addItem("Red");
		this.color.addItem("Blue");
		this.sex=new Choice();
		this.sex.addItem("Female");
		this.sex.addItem("Male");
		this.lifespan=new Choice();
		this.lifespan.addItem("1");
		this.lifespan.addItem("2");
		this.lifespan.addItem("3");
		this.lifespan.select(1);
		add(loca);
		add(this.loc);
		add(strengt);
		add(this.strength);
		add(msa);
		add(this.ms);
		add(mdi);
		add(this.md);
		add(lifespa);
		add(this.lifespan);
		add(colo);
		add(this.color);
		add(se);
		add(this.sex);
		Button send=new Button("Create Organism");
		send.addActionListener(this);
		add(send);
		Button food=new Button("Create Food");
		food.addActionListener(new FoodListener(this, ad));
		add(food);
		this.addWindowListener(this);
		this.setSize(400,300);
		this.setVisible(true);
	}
	public void windowClosing(WindowEvent e)	{
			this.setVisible(false);
	}
	public void windowOpened(WindowEvent e)	{}
	public void windowClosed(WindowEvent e)	{}
	public void windowDeactivated(WindowEvent e)	{}
	public void windowActivated(WindowEvent e)	{}
	public void windowDeiconified(WindowEvent e)	{}
	public void windowIconified(WindowEvent e)	{}
	public void actionPerformed(ActionEvent e)	{
		send();
	}
	public void send()	{
		Organism org;
		boolean[] genes=new boolean[10];
		int x, y;
		Color col=null;
		switch (this.strength.getSelectedIndex())	{
			case 0:
				genes[0]=false;
				genes[1]=false;
				genes[2]=false;
				break;
			case 1:
				int rnb=(int)Math.floor(3*Math.random());
				for (int i=0;i<3;i++)	{
					if (i==rnb)
						genes[i]=true;
					else
						genes[i]=false;
				}
				break;
			case 2:
				int rnd=(int)Math.floor(3*Math.random());
				for (int i=0;i<3;i++)	{
					if (i==rnd)
						genes[i]=false;
					else
						genes[i]=true;
				}
				break;
			case 3:
				genes[0]=true;
				genes[1]=true;
				genes[2]=true;
				break;
		}
		switch (this.ms.getSelectedIndex())	{
			case 0:
				genes[3]=false;
				genes[4]=false;
				break;
			case 1:
				if (Math.random()<.5)
					genes[3]=true;
				else
					genes[3]=false;
				genes[4]=!genes[3];
				break;
			case 2:
				genes[3]=true;
				genes[4]=true;
				break;
		}
		switch (this.md.getSelectedIndex())	{
			case 0:
				genes[5]=false;
				genes[6]=false;
				break;
			case 1:
				if (Math.random()<.5)
					genes[5]=true;
				else
					genes[5]=false;
				genes[6]=!genes[5];
				break;
			case 2:
				genes[5]=true;
				genes[6]=true;
				break;
		}
		switch (this.sex.getSelectedIndex())	{
			case 0:
				genes[7]=false;
				break;
			case 1:
				genes[7]=true;
				break;
		}
		switch (this.color.getSelectedIndex())	{
			case 0:
				col=Color.red;
				break;
			case 1:
				col=Color.blue;
				break;
		}
		switch (this.lifespan.getSelectedIndex())	{
			case 0:
				genes[8]=false;
				genes[9]=false;
				break;
			case 1:
				if (Math.random()<.5)
					genes[8]=true;
				else
					genes[8]=false;
				genes[9]=!genes[8];
				break;
			case 2:
				genes[8]=true;
				genes[9]=true;
				break;
		}
		int loca=this.loc.getSelectedIndex();
		y=loca%ADescolada.height;	//oops i flipped these at first...
		x=(int)loca/ADescolada.height;
		org=new Organism(x, y, col, genes[0], genes[1], genes[2], genes[3], genes[4], genes[5], genes[6], genes[7], genes[8], genes[9]);
		/*if (this.color.getSelectedIndex()==0)	{
			ADescolada.red.addElement(org);
			ADescolada.orgArray[y*ADescolada.width+x]=1;
		}
		else	{
			ADescolada.blue.addElement(org);
			ADescolada.orgArray[y*ADescolada.width+x]=2;
		}*/
		//ADescolada.keys.addElement(new Integer(y*ADescolada.width+x));
		//ADescolada.orgs.put(new Integer(y*ADescolada.width+x), org);
		ADescolada.orgs.addElement(org);
		//addition to keys is inside orgs contructor
		this.setVisible(false);
		//wait...don't repaint the win...repaint the applet!  hehe...ehh...m
		//ADescolada.newSiz++;
		//ADescolada.siz++;
		ad.repaint();
		//repaint(); //i figure, what the heck, i'll go crazy w/ the repaint
		//repaint(x*ADescolada.cellWidth, y*ADescolada.cellHeight, ADescolada.cellWidth, ADescolada.cellHeight);
	}
}
public class destroyListener implements ActionListener	{
	ADescolada ad;
	public destroyListener(ADescolada ad)	{
		this.ad=ad;
	}
	public void actionPerformed(ActionEvent e)	{
		new DestroyWin(this.ad);
	}
}
public class DestroyWin extends Frame implements ActionListener, WindowListener	{
	ADescolada ad;
	Choice loc;
	Button doIt;
	public DestroyWin(ADescolada ad)	{
		super("Destroy");
		setLayout(new FlowLayout());
		this.ad=ad;
		this.loc=new Choice();
		for (int i=0;i<ADescolada.width;i++)	{
			for (int j=0;j<ADescolada.height;j++)	{
				if ((Organism.check(i, j)) && (ADescolada.keys[i+ADescolada.width*j]!=-2))	{
					loc.addItem("" + i + ", " + j);
				}
				else	{
					//System.out.println("Success*");
					loc.addItem("*" + i + ", " + j);
				}
			}
		}
		this.doIt=new Button("Make it so");
		this.doIt.addActionListener(this);
		add(loc);
		add(doIt);
		this.setSize(200,100);
		this.setVisible(true);
		this.addWindowListener(this);
	}
	public void windowClosing(WindowEvent e)	{
			this.setVisible(false);
	}
	public void windowOpened(WindowEvent e)	{}
	public void windowClosed(WindowEvent e)	{}
	public void windowDeactivated(WindowEvent e)	{}
	public void windowActivated(WindowEvent e)	{}
	public void windowDeiconified(WindowEvent e)	{}
	public void windowIconified(WindowEvent e)	{}
	public void actionPerformed(ActionEvent e)	{
		int loca=this.loc.getSelectedIndex();
		int y=loca%ADescolada.height;	//oops i flipped these at first...
		int x=(int)loca/ADescolada.height;
		((Organism)ADescolada.orgs.elementAt(ADescolada.keys[x+ADescolada.width*y])).die();
		this.setVisible(false);
		this.ad.repaint();
	}
}
public class itListen implements ActionListener	{
	ADescolada ad;
	public itListen(ADescolada app)	{
		this.ad=app;
	}
	public void actionPerformed(ActionEvent e)	{
		if ((!ADescolada.running) && (ADescolada.orgs.size()>0))	{
			ad.iterate();
			ad.repaint();
			if (ADescolada.orgs.size()==0)
				ADescolada.iterationNumber=0;
		}
		else if (ADescolada.orgs.size()==0)	{
			ADescolada.iterationNumber=0;
		}
		else	{
			ad.kicker.stop();
			ADescolada.running=false;
			ad.goButton.setLabel("Run");
			ad.kicker=new Thread(ad);
		}
	}
}
public class FoodListener implements ActionListener	{
	ADescolada ad;
	CreateWin cw;
	public FoodListener(CreateWin crw, ADescolada appl)	{
		this.ad=appl;
		this.cw=crw;
	}
	public void actionPerformed(ActionEvent e)	{
		int loca=this.cw.loc.getSelectedIndex();
		int y=loca%ADescolada.height;	//oops i flipped these at first...
		int x=(int)loca/ADescolada.height;
		ADescolada.foods.addElement(new Integer(x+ADescolada.width*y));
		ADescolada.keys[x+ADescolada.width*y]=-2;
		this.cw.setVisible(false);
		this.ad.repaint();
	}
}
public class DispWin extends Frame implements WindowListener, ActionListener	{
	Button close;
	public DispWin(int a, int b, int c, int d, boolean e, boolean f, boolean g, boolean h, boolean i, boolean j, boolean k, boolean l, boolean m, boolean n, boolean o, Color p)	{
		super("Displaying Organism Information");
		setLayout(new GridLayout(17,1));
		add(new Label("Age: " + a));
		add(new Label("Iterations since last meal: " + b));
		add(new Label("Location: (" + c + ", " + d + ")"));
		int strength=1;
		if (e)
			strength++;
		if (f)
			strength++;
		if (g)
			strength++;
		add(new Label("Strength: " + strength));
		int ms=1;
		String mss=new String();
		if (h)
			ms++;
		if (i)
			ms++;
		if (ms==1)
			mss="Away";
		else if (ms==2)
			mss="Impartial";
		else
			mss="Towards";
		add(new Label("Same color movement: " + mss));
		int md=1;
		String mds=new String();
		if (j)
			md++;
		if (k)
			md++;
		if (md==1)
			mds="Away";
		else if (ms==2)
			mds="Impartial";
		else
			mds="Towards";
		add(new Label("Different color movement: " + mds));
		if (l)
			add(new Label("Sex: Male"));
		else
			add(new Label("Sex: Female"));
		int ls=65;
		if (m)
			ls+=15;
		if (n)
			ls+=15;
		add(new Label("Life Expectancy: " + ls));
		if (!l)
			add(new Label("Pregnant: " + o));
		if (p==Color.red)
			add(new Label("Color: Red"));
		else
			add(new Label("Color: Blue"));
		close=new Button("Close");
		close.addActionListener(this);
		add(close);
		this.setSize(300,300);
		this.setVisible(true);
		this.addWindowListener(this);
	}
	public void actionPerformed(ActionEvent e)	{
		this.setVisible(false);
	}
	public void windowClosing(WindowEvent e)	{
			this.setVisible(false);
	}
	public void windowOpened(WindowEvent e)	{}
	public void windowClosed(WindowEvent e)	{}
	public void windowDeactivated(WindowEvent e)	{}
	public void windowActivated(WindowEvent e)	{}
	public void windowDeiconified(WindowEvent e)	{}
	public void windowIconified(WindowEvent e)	{}
}
public class WhichListener implements ActionListener	{
	ADescolada ad;
	public WhichListener(ADescolada a)	{
		this.ad=a;
	}
	public void actionPerformed(ActionEvent e)	{
		this.ad.which++;
		if (this.ad.which>2)	{
			this.ad.which=0;
		}
		if (this.ad.which==0)	{
			this.ad.whichButton.setLabel("Organism");
		}
		else if (this.ad.which==1)	{
			this.ad.whichButton.setLabel("Food");
		}
		else	{
			this.ad.whichButton.setLabel("Show Info");
		}
	}
}

Back to ADescolada

How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.

 Microsoft RIA Development Center
 IBM Rational Resource Center
 Destination .NET
XML error: not well-formed (invalid token) at line 33
advertisement
Receive Articles via our XML/RSS feed
Receive Articles via our XML/RSS feed

JavaBytes
Internet Cyclone
This powerful, easy-to-use, internet optimizer is for Windows 95, 98, ME, NT, 2000 and XP. It's designed to automatically optimize your Windows settings, boosting your Internet connection up to 200%.

Free VMware Server 2.0 Now Release Candidate
Linux Player Xandros Grabs Storied Rival Linspire
Hey Enterprise: Here Comes the 3G iPhone
MySpace Opens Profile Portability API
Microsoft Jumps Into Virtualization Fray
Eclipse Ganymede Makes It Easier for Devs
Open Source Nokia a Threat to Microsoft, Google?
Salesforce, Google Head for 2nd on Apps
HP Open Sources Unix File System for Linux
Red Hat Opens Its Network to Space

Build a Generic Histogram Generator for SQL Server
Beyond XML and JSON: YAML for Java Developers
Mastering the Windows Mobile Emulators
Avaya AE Services Provide Rapid Telephony Integration with Facebook
Featured Algorithm: Intel Threading Building Blocks: parallel_reduce
Getting Started with Windows Live Admin Center
Eight Key Practices for ASP.NET Deployment
Java ME User Interfaces: Do It with LWUIT!
Talking VPro: Transcript
Bringing Semantic Technology to the Enterprise

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers