Jump to content




[ICBM] [WIP] Skynet Missile Defence Network


21 replies to this topic

#21 Andrew2060

  • Members
  • 109 posts
  • LocationLos Angeles, California

Posted 23 June 2016 - 03:49 PM

So after taking a few months off and coming back to it,

I did a redesign of my code and with the help of some others found a leaner and meaner way to go about it.
This works by simply tasking multiple silos to fire and reload, then repeat the process till all threats are destroyed.
Im also working on the AI part now, calculating distances, trajectories, velocities all the good physics stuff i learned.

Anyhow here is the code:

Server:

--[[Skynet Nuclear ABM Defense Program by Andrew2060]]--
--[ABM Server, use with http://pastebin.com/aNsduCem]]--
--[System requires atleast 5 CC's with Modems and ABMs]]--
--[System has 5% chance of failure in killing missiles]]--

--[[Settings]]--
local waitDelay = 2
local countersPerMissile = 1
local missileDelay = 3

--[[Initialization]]--
local silos, curSilo = {}, 1
peripheral.find("modem", rednet.open)
term.setBackgroundColor(colors.blue)

local function red()
term.setBackgroundColor(colors.red)
print("												   ")
term.setBackgroundColor(colors.blue)
end

rednet.broadcast("ABM1")

repeat
    local id, msg = rednet.receive(waitDelay)
    if msg == "ABM" then table.insert(silos, id) end
until not id

--[[Main Programs]]--
while true do
    if not redstone.getInput("back") then
	    term.clear()
	    term.setCursorPos(1, 1)

	    red()
	    print("	    SKYNET DEFENSE SYSTEMS ACTIVATED		   ")
	    red()
	    print("	  ANTI-BALLISTIC MISSILE SHIELD ONLINE		 ")
	    red()
	    red()
	    print("			   [STANDBY ABM Silos]				 ")

	    for k, v in ipairs(silos) do print("  silo #" .. k .. " id = "..v) end
	    red()
	  
	    repeat os.pullEvent("redstone") until redstone.getInput("back")
    end
  
    term.clear()
    term.setCursorPos(1, 1)
    term.setTextColor(colors.red)
  
    print("Incoming Missiles:")
    print("Firing CounterMeasures\n")
  
maptab = peripheral.call("back","getEntities")
maptxt = textutils.serialize(maptab)
if maptxt ~= "{}" then
allDat = 0
for num in pairs(maptab) do
allDat = allDat+1
end
targets = allDat/3
for i=0,targets-1 do
	    local msg = {["x"] = math.floor(maptab["x_"..i]), ["y"] = math.floor(maptab["y_"..i]), ["z"] = math.floor(maptab["z_"..i])}

	    print("Incoming Missile Threat #" .. i .. " at X:" .. msg.x .. " Y:" .. msg.y .. " Z:" .. msg.z)
	    print("Launching " .. countersPerMissile .. " ABM Missile CounterMeasures...\n")

	    for i = 1, countersPerMissile do
		    rednet.send(silos[curSilo], msg)
		    curSilo = (curSilo == #silos) and 1 or (curSilo + 1)
		    sleep(missileDelay)
		    end
	    sleep(0)
	    end
	 sleep(0)
    end
   sleep(2)
end
sleep(1)

Edited by Andrew2060, 23 June 2016 - 03:49 PM.


#22 FoxData

  • Members
  • 159 posts

Posted 30 July 2016 - 05:29 PM

Its cool but no secure enough. No two-man rule, No launch-codes, And its wireless. But its still pretty cool,

Suggestions:

Add Two-man rule
Add a launch code





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users