Posted 14 March 2014 - 03:17 AM
First time poster, be gentle as I'm fresh out of college so I have little experience, but I did whip this up today and thought I'd share for input/thoughts/others amusement.
This is Olland, my first attempt at an AI. He benefits greatly from both misc peripherals and open peripherals but neither is technically required. As of right now I only have a draft of his core program done. I plan on using him to control my AE crafting system and the like. The basic idea is for the core to give any functionality he really needs to add other functionality, storing most data in files and using outside functions to expand what he can do. The programs called should always return a string for Olland to "say" about completion or not and would accept a single argument table.
When needed I've also set up a server system that uses a handshake to get data about servers on the wireless network that can perform tasks other programs need as well (it lets the server know the AI's ID then lets the AI know what the server is for). I'm working on a redstone in motion elevator server/program that I can post examples of to show how the handshake to get info works as well as how the called programs should be set up if anyone is even remotely interested.
To do/planned features list includes:
-More error checking
-The ability to do updates to programs already downloaded
-The ability to download updates to the core program and cleanup old code
-More flexability on issuing a command
-Uh, y'know…comments would probably be good. Yeah…Adding those tomorrow when I get back up I think.
Update 3/14:
-Added comments to the core
-Fixed issues with the command aliasing
-Misc bugfixes
-Added example elevator code, both the elevator client itself and olland's program
Olland Core:
http://pastebin.com/VAjTYK1c
Olland's elevator program:
http://pastebin.com/ExjF1CYV
The elevator server. Not including the two other programs it interacts with on other PCs via redstone cables unless its asked for:
http://pastebin.com/f1FpZ0XA
Of particular note in the elevator server code is this snippet that is used to get information from olland and provide information about itself to Olland, you'll need it if you set up a server side program for olland to interact with:
This snippet actually sets up the table it sends to the server:
This is Olland, my first attempt at an AI. He benefits greatly from both misc peripherals and open peripherals but neither is technically required. As of right now I only have a draft of his core program done. I plan on using him to control my AE crafting system and the like. The basic idea is for the core to give any functionality he really needs to add other functionality, storing most data in files and using outside functions to expand what he can do. The programs called should always return a string for Olland to "say" about completion or not and would accept a single argument table.
When needed I've also set up a server system that uses a handshake to get data about servers on the wireless network that can perform tasks other programs need as well (it lets the server know the AI's ID then lets the AI know what the server is for). I'm working on a redstone in motion elevator server/program that I can post examples of to show how the handshake to get info works as well as how the called programs should be set up if anyone is even remotely interested.
To do/planned features list includes:
-More error checking
-The ability to do updates to programs already downloaded
-The ability to download updates to the core program and cleanup old code
-More flexability on issuing a command
Update 3/14:
-Added comments to the core
-Fixed issues with the command aliasing
-Misc bugfixes
-Added example elevator code, both the elevator client itself and olland's program
Olland Core:
http://pastebin.com/VAjTYK1c
Olland's elevator program:
http://pastebin.com/ExjF1CYV
The elevator server. Not including the two other programs it interacts with on other PCs via redstone cables unless its asked for:
http://pastebin.com/f1FpZ0XA
Of particular note in the elevator server code is this snippet that is used to get information from olland and provide information about itself to Olland, you'll need it if you set up a server side program for olland to interact with:
while not hostAiId do
local senderId, message, distance = rednet.receive()
if message == "AIREQNEWSERVER" then
print("AI sent request. Sending info")
tempAiId = senderId
rednet.send(tempAiId,textutils.serialize(computerInfo))
elseif message == "ACK" and senderId == tempAiId then
hostAiId = tempAiId
print("AI ID found")
file = fs.open("aiInfo","w")
file.write(hostAiId)
file.close()
end
end
This snippet actually sets up the table it sends to the server:
if not computerInfo["computerType"] then
computerInfo["computerType"] = "ELEVATOR"
print("Please enter an alias for this computer: ")
computerInfo["computerAlias"] = read()
file = fs.open("computerInfo","w")
file.write(textutils.serialize(computerInfo))
file.close()
end
Edited on 14 March 2014 - 08:42 PM