public void Resolve() {
		//if(!conflicted) return;
		if(_occupants.isEmpty()) {
			if(debug)
				System.out.println("Nothing to resolve");
			return;
		}
		
		// Resolve combat
		int nFleets = _occupants.size();
		Ship[][] fleets = new Ship[TurnManager.numPlayers][nFleets]; // Stores the different fleets
		int[] nShips = new int[TurnManager.numPlayers]; // stores how many ships in each fleet.
		int[] fleetCombat = new int[TurnManager.numPlayers];
		int[] fleetAlignments = new int[TurnManager.numPlayers];
		
//		for(int i = 0; i < nShips.length; i++) 
//			nShips[i] = 0;
	
		nFleets = 0;

		for(int i = 0; i < _occupants.size(); i++) {
			// For each ship:
			// Determine if loyalty is already accounted for.
			boolean accounted = false;
			Ship s = _occupants.get(i);
			for(int j = 0; j < nFleets; j++) {
				if(nShips[j] > 0 && fleets[j][0].getLoyalty() == s.getLoyalty()) {
					fleets[j][nShips[j]++] = s;
					accounted = true;
					break;
				}
			}
			
			if(!accounted) {
				if(debug) System.out.println("New ship added to fleet " + nFleets);
				fleetCombat[nFleets] = 0;
				fleets[nFleets][0] = s;
				fleetAlignments[nFleets] = s.getLoyalty();
				nShips[nFleets++]++;
			}
		}
		
		if(nFleets <= 1) {
			if(debug) System.out.println("Only one fleet");
			if(!_occupants.isEmpty() && _planet != null) {
				_planet.Invade(_occupants.get(0).getLoyalty());
			}
			conflicted = false;
			return;
		}
		
		if(debug) System.out.println("Resolving Combat");
		// Fleets have been determined.
		// Calculate combat for all fleets.
		if(debug) System.out.print("Combat powers are : ");
		for(int i = 0; i < nFleets; i++) {
			for(int j = 0; j < nShips[i]; j++) {
				fleetCombat[i] += fleets[i][j].getFirepower();
			}
			if(debug) System.out.print("(" + i + ") " + fleetCombat[i] + "   ");
		}
		if(debug) System.out.println("");
		
		// compare firepower against all fleets.
		int numCombats = nFleets;
		for(int i = 0; i < numCombats; i++) {
			// Determine combat distribution.
			if(debug) System.out.println("Resolving combat for fleet " + i + " with firepower " + fleetCombat[i]);
			while(fleetCombat[i] > 0) {
				int targetFleet; int nTries = 0;
				do {
					targetFleet = (int)(Math.random() * nFleets);
				} while ((nShips[targetFleet] <= 0 || fleets[targetFleet][0].getLoyalty() == fleetAlignments[i]) && nTries++ < 20);
				if(nTries >= 20) {
					// assume no more targets
					if(debug) System.out.println("-No more targets. Moving on...");
					break;
				}
				int targetShip = (int)(Math.random() * nShips[targetFleet]);
				float shipDef = fleets[targetFleet][targetShip].getArmor();
				if(debug) System.out.println("-Target fleet " + targetFleet + ", ship " + targetShip + " with defense of " + shipDef);
				if(!fleets[targetFleet][targetShip].Defend(fleetCombat[i])) {
					if(debug) System.out.println("-Ship destroyed. Removing from list.");
					// remove ship from array
					for(int s = targetShip; s < nShips[targetFleet] - 1; s++)
					{
						fleets[targetFleet][s] = fleets[targetFleet][s + 1];
					}
					nShips[targetFleet]--;
					if(nShips[targetFleet] <= 0) {
						if(debug) System.out.println("-Fleet destroyed. Removing from list.");
						// if fleet is empty, remove from array
						for(int f = targetFleet; f < nFleets - 1; f++)
						{
							fleets[f] = fleets[f + 1];
							nShips[f] = nShips[f + 1];
						}
						nFleets--;
					}
				}
				fleetCombat[i] -= shipDef;
				if(debug) System.out.println("Fleet Combat decreased to " + fleetCombat[i]);
			}
			
			if(debug) System.out.println("Remaining number of fleets is " + nFleets);
			if(nFleets > 1) {
				conflicted = true;
			} else 
			{
				conflicted = false;
			}
			/*if(nFleets > 2) {
				double[] distribution = new double[nFleets - 1];
				for(int j = 0; j < nFleets - 1; j++) {
					
				}
			} else {
				while(fleetCombat[i] > 0) {
					
				}
			}//*/
		}
		
		// If planet, determine planet's allegiance.
		if(_planet != null && !_occupants.isEmpty() && !conflicted) {
			if(_occupants.get(0).getLoyalty() != _planet.getAlliance())
				_planet.Invade(_occupants.get(0).getLoyalty());
		}
	}