function RandomPlayer(name, race, homeworld)
{
	this.Construct(name, race, homeworld);
}
RandomPlayer.prototype = new AIPlayerBase();
RandomPlayer.prototype.type = "RandomPlayer";
RandomPlayer.className = "RandomPlayer";
Player.Classes["RandomPlayer"] = RandomPlayer;

RandomPlayer.prototype.Plan = function()
{
	// yearly maintenance
	this.Reports = [];
	
	//var me = this;
	//this.ColonizePlanets(function(planet){return me.ShouldColonize(planet);});
	this.ColonizePlanets();
	
	for (var a=0; a<this.Planets.length; a++)
	{
		var planet = this.Planets[a];
		this.PlanPlanet(planet);
	}
}


//RandomPlayer.prototype.ShouldColonize = function(planet)
//{
//	return true;
//}

RandomPlayer.prototype.PlanPlanet = function(planet)
{
	planet.priority[Planet.Priorities.Ship] = 20;

	if (this.shipLevel == 3)
	{
		// maxed out on tech.  Time to start building fleets in earnest.
		planet.priority[Planet.Priorities.Ship] = 60;
		planet.priority[Planet.Priorities.Research] = 0;
	}

	var targetPlanet = null;
	var excludeMine = (Math.random() > 0.3);
	var planets = Planet.ListInRange(this, excludeMine);
	if (planets.length > 0)
	{
		targetPlanet = planets[Math.floor( Math.random() * planets.length )];
	}
	else
	{
		// no planets to mess with.
		return;
	}
	
	
	var fleet = Fleet.GetByPlanetAndOwner(planet, this);
	var fleetThere = Fleet.GetByPlanetAndOwner(targetPlanet, this);
	
	if (!targetPlanet.owner)
	{
		// uninhabited
		if (!this.HasExplored(targetPlanet))
		{
			// TODO - this.HasSentScouts(targetPlanet)
			if (fleet && fleet.GetShipCount() >= 1)
			{
				fleet.SendTo(targetPlanet, [1,1,1,1]);
			}
		}
		else if (this.ShouldColonize(targetPlanet) && fleet && fleet.GetShipFirepower() >= Ship.ColonyFirepower)
		{
			fleet.SendTo(targetPlanet, [32,16,8,4]);
		}

	}
	else if (targetPlanet.owner != this)
	{
		// enemy (TODO: friend)
		if (fleetThere && !fleetThere.IsEmpty() && planet.population > 60 && Math.random() > 0.2)
		{
			// fleet in orbit of the target planet, and we have armies to send
			planet.TransportTo(targetPlanet, 20);
		}
		else if (fleet && fleet.GetShipCount() > 10 && Math.random()>0.2)
		{
//alert("sending fleet");
			fleet.SendTo(targetPlanet, [1000,1000,1000,1000]);
//alert("sent fleet from " + fleet.planet.name + " to " + targetPlanet.name + ", " + fleet.courseLength + ", " + fleet.courseProgress + ", " + fleet.inTransit);
		}
	}
	else
	{
		// mine
		if (targetPlanet.population < 20 && (targetPlanet.populationMax > targetPlanet.population + 20) && planet.population > 80)
		{
			// planet needs more people.
			planet.TransportTo(targetPlanet, 20);
		}
			
	}


}
