Now on GitHub!

So, I have for a while made Lua programs and such for computers and turtles in the mod ComputerCraft in Minecraft for a while. First starting out with a private server with a bunch of friends as building automation and mining, I made an A* library (2D, obstacle avoidance and world learning) to navigate buildings and such easily, even did some small autonomous systems. I still have that pathing script somewhere, but that was a bit ago.

Recent, I picked up MC again and went back to this. Why? Because a small system with small programs can be fun and challenging!

I have started on a project to add some AI control over a bale of turtles. The plan is to make a GOAP AI (Goal oriented/Action Planning) that will be tasked with some goal(s) and will control a community of turtles and such (I have wanted to make something like this ever since I was writing an AI for AoEII way back in the day).

Since there are limitations for memory, code/storage size, etc. for CC, the work is split between Lua in MC and a Python daemon providing a REST API. This should take load off of the server as well as make sure the entire scope is considered in each action taken. I'll provide more info later once I have something that functions (bitbucket, public-facing server, probably a second MC server next to the Retro MC server (Yes, that is still running!), API documentation).

Another project if I got really bored was to make a network infrastructure. Link-layer up to application-layer. From scratch. Why not? But that's for a later time! Or for someone else...

Thought I'd share considering the MC & coding community here.
boot1 and boot2 now work with the python backend, boot2 and all payload files and the startup config are grabbed on startup. Slowly working on the API list still. Progress!
Well, another thing I wasn't sure about is if the turtles would automatically start when the server restarts. Sure enough, I receive log messages that it starts as well as registers itself.

I'm in the middle of testing the Lua API that takes a point path from the server and navigates it. Sadly, I forgot that APIs have variables copied to global scope, not referenced, so movement is failing.
I got the pathing code working much better last night. I had it navigate to a position ~180 blocks away on the other side of a hill. After adding in scoring for turning the turtle, it was running fine. I'll try having it go very long distances, but I need to stay within loaded chunks, unless I bring in world anchors (Nope).
Cool! I love ComputerCraft, it's one of my favorite MC mods.
I will be mirroring my code over to github as I use a private mercurial repo/management site for lots of my code things. I'll need to get a README and license added, then I'll start the mirror.
Code has been migrated to github and is GPLv3'd. I'll be trying to get more on the Lua side of things and goals in Python. Later, I'll need to get data thrown into SQLite or something in Python, dump stuff to logs, make the project layout not dumb.
Nothing major to report, more tasks added to github. I've moved the python code into a module managed by setuptools and got the building and running of this with Docker. Easy way to quickly spin up a fresh server each time.
The explore and move actions are working more or less. I have a turtle that just roams around, collecting environmental data for a period of time, then returns home. More actions to come.

<edit>

Will focus on searching next, then the goal/action system some more. Overview on current progress is on github, updated daily.
Working on goal/action planner, it has some sanity showing when trying to figure out what needs to be done to build a house:
Code:
looking at requirement for need miner
  Can already claim it
looking at requirement for need house resources
  action get dirt from gather dirt has a helpfulness of 1
  action get 5 dirt from decon house has a helpfulness of 5
    but action get dirt is counter-productive!
I need gather dirt to get dirt (helpfulness 1)

These are the goals, requirements, actions, and variables used for resolving how to build a house:

Code:
needsMiner = VariableRequirement("need miner", "turtles.miner.free", ">=", NumericVariable("", 1))
needsBuilder = VariableRequirement("need miner", "turtles.builder.free", ">=", NumericVariable("", 1))
needsHouseResources = VariableRequirement("need house resources", "resources.dirt", ">=", NumericVariable("",5))
getsDirt = VariableIncreaseAction("get dirt", "resources.dirt", 1)
gets5Dirt = VariableIncreaseAction("get 5 dirt", "resources.dirt", 5)
getsHouse = VariableIncreaseAction("get house", "buildings.house", 1)
losesHouse = VariableDecreaseAction("lose house", "buildings.house", 1)
needsHouse = VariableRequirement("need house", "buildings.house", "==", 1)
gatherDirt = BasicGoal("gather dirt", [needsMiner], [getsDirt])
deconHouse = BasicGoal("decon house", [needsMiner, needsHouse], [gets5Dirt, losesHouse])
buildHouse = BasicGoal("build house", [needsBuilder, needsHouseResources], [getsHouse])

variables["turtles.miner.free"] = NumericVariable("",1)
variables["turtles.builder.free"] = NumericVariable("",1)
variables["buildings.house"] = NumericVariable("",0)
variables["resources.dirt"] = NumericVariable("",0)

goals = [gatherDirt, buildHouse, deconHouse]


The general idea is this: A turtle wants to build a house. In order to build a house, it needs a free miner and resources. Once it has these, it claims them and runs a list of commands. Once these are done, a new house is registered. These goals can get chained like crazy, so a planner that is careful to not get confused is needed. An example of a more detailed example:

Code:
Trying to build house
looking at requirement for need miner
  Can already claim it
looking at requirement for need house resources
  action get dirt from gather dirt has a helpfulness of 1
  action get 5 dirt from decon house has a helpfulness of 5
    but action get 5 dirt is counter-productive!
I need gather dirt to get dirt (helpfulness 1)
Trying to gather dirt
looking at requirement for need miner
  Can already claim it
looking at requirement for need mine
  action get mine from build mine has a helpfulness of 1
I need build mine to get mine (helpfulness 1)
Trying to build mine
I've been taking this even further now. Goals are made up of 3 sets of objects: requirements, actions, and results. Resolving a goal goes through a bunch of steps. First, all requirements must be "claimable", meaning that the requirements can be met and anything they need to claim, like resources, turtles, etc. can happen. From there, the goal can start to be resolved. The goal is deepcopied to get unique instances of everything and all requirements are claimed. Then on each processing step, the first available action is invoked which generates commands for a turtle or some other effect. When that action is successful, it is completed and the process continues for all actions (Ignoring failures for now, this is a perfect world with spherical cows in a vacuum). Once all actions are done, results get triggered and update any variables as needed and the goal is marked as resolved.

That's basically how goals and such are handled and it seems everything should work out in the end, even though there are quite a few limitations on this process.

This will take a while to get through, so nothing to show in MC for a bit.
I've started formalizing a breakdown on the GOAP module for this here. I haven't had much time to work on this project this weekend, but that will change this week.

Goals can start to be resolved and actions are starting to trigger now. Just need to hack my way through the general flow before I build an interface to the madness.
http://oc.cil.li/index.php?/page/index.html
Ivoah wrote:
http://oc.cil.li/index.php?/page/index.html

Thanks, issue made to look into it.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement