function printShipsFile(name)
    local index = 0
    local numPlayers = universe.getNumPlayers()
    local outstring = HW2_FullPath..name..numPrints..".lua"
    print("Writing ships file: "..outstring)
    writeto(outstring)
    write("\n")
    while  index<numPlayers do
        print("Writing Player "..index.." info\n")
        write("-- Player "..index.." Ships\n")
        local player = universe.getPlayer(index)
        local playerShips = player.getShips()
        local numShips = playerShips.count()
        for i = 1,numShips,1 do
            ship.getName()
            write([[addShip("]]..ship.getName()..[["]]..", {"..shiploc[1]..", "..shiploc[2]..", "..shiploc[3].."}, "..index..", {"..-(shipor[1])..", "..-(shipor[2])..", "..-(shipor[3]).."})\n")
        end 
        index = (index + 1)
        write("\n")
    end 

    writeto()
    print("Success!")
    numPrints = (numPrints + 1)
end


function NoBuild_BuildList_Reb(playerIndex)

end

AllabilityList = { 
	AB_None,  
	AB_Move,  
	AB_Attack,  
	AB_Guard,  
	AB_Repair,  
	AB_Cloak,  
	AB_Harvest,  
	AB_Mine,  
	AB_Capture,  
	AB_Dock,  
	AB_AcceptDocking,  
	AB_Builder,  
	AB_Stop,  
	AB_Hyperspace,  
	AB_Parade,  
	AB_FormHyperspaceGate,  
	AB_HyperspaceViaGate,  
	AB_SensorPing,  
	AB_SpecialAttack,  
	AB_Retire,  
	AB_DefenseField,  
	AB_DefenseFieldShield,  
	AB_HyperspaceInhibitor,  
	AB_Salvage,  
	AB_Steering,  
	AB_Targeting,  
	AB_Sensors,  
	AB_Lights,  
	AB_Scuttle,  
	AB_UseSpecialWeaponsInNormalAttack, 
	}
AllabilityStrList = { 
	"AB_None",  
	"AB_Move",  
	"AB_Attack",  
	"AB_Guard",  
	"AB_Repair",  
	"AB_Cloak",  
	"AB_Harvest",  
	"AB_Mine",  
	"AB_Capture",  
	"AB_Dock",  
	"AB_AcceptDocking",  
	"AB_Builder",  
	"AB_Stop",  
	"AB_Hyperspace",  
	"AB_Parade",  
	"AB_FormHyperspaceGate",  
	"AB_HyperspaceViaGate",  
	"AB_SensorPing",  
	"AB_SpecialAttack",  
	"AB_Retire",  
	"AB_DefenseField",  
	"AB_DefenseFieldShield",  
	"AB_HyperspaceInhibitor",  
	"AB_Salvage",  
	"AB_Steering",  
	"AB_Targeting",  
	"AB_Sensors",  
	"AB_Lights",  
	"AB_Scuttle",  
	"AB_UseSpecialWeaponsInNormalAttack", 
	}

ActiveRules		= {}	-- Tracks the rule names
ActiveRulesInt	= {}	-- Tracks the interval of the rule, 0 means Rule_Add()
ActiveRulesStat = {}	-- Tracks the rules status "" means active

-- ----------------------------------------------------------------------------
-- this function intercepts calls to add rule to store them in a set of global 
--		rules lists.
-- ----------------------------------------------------------------------------
function Rule_Add_Debug(strRule)
	-- find out how many rules there are now
	local nIdx = getn(ActiveRules)

	-- append the new rule to the lists
	ActiveRules[(nIdx + 1)]		= strRule
	ActiveRulesInt[(nIdx + 1)]	= 0
	ActiveRulesStat[(nIdx + 1)]	= ""

	-- tell me any time there is a change
	PrintActiveRules()

	-- now add the rule
	Rule_Add(strRule)

end

-- ----------------------------------------------------------------------------
-- Same as above but it takes another argument for the interval
-- ----------------------------------------------------------------------------
function Rule_AddInterval_Debug(strRule, nInterval)
	-- find out how many rules there are now
	local nIdx = getn(ActiveRules)

	-- append the new rule to the lists
	ActiveRules[(nIdx + 1)]		= strRule
	ActiveRulesInt[(nIdx + 1)]	= nInterval
	ActiveRulesStat[(nIdx + 1)]	= ""

	-- tell me any time there is a change
	PrintActiveRules()

	-- now add the rule
	Rule_AddInterval(strRule, nInterval)

end

-- ----------------------------------------------------------------------------
-- Intercepts calls to remove rule so they can be set to 'Removed' in the
--		global active rules lists.
-- ----------------------------------------------------------------------------
function Rule_Remove_Debug(strRule)

	-- step thru the list and find the rule to be removed once we 
	--		find the rule to remove we just	set the status
	--		table for that rule to 'Removed :'
	for i = 1,getn(ActiveRules),1 do

		-- if the lengths are different this cannot be the one 
		--		we are looking for
		if strlen(ActiveRules[i])==strlen(strRule) then

			-- this may be it, do the string search	to be sure
			if strfind(ActiveRules[i], strRule)==1 then

				-- this is it, set the status
				ActiveRulesStat[i] = "                       Removed :"
			end	

		end
	
	end

	-- finally remove the rule
	Rule_Remove(strRule)

	-- tell me what's going on
	print("Rule Removed: "..strRule)

end

-- ----------------------------------------------------------------------------
-- Prints the list of rules, thier status, and call intervals to the log
-- ----------------------------------------------------------------------------
function PrintActiveRules()
	print(" ")
	print("============================================= Current Rule Set ==")
	for i = 1,getn(ActiveRules),1 do
		print(ActiveRulesStat[i]..ActiveRules[i]..", "..ActiveRulesInt[i])

	end

	print("==================================================  ===============")
	-- added these to insert some newlines and make the log easier to read
	print(" ")
	print(" ")
end

