{"action":"created","issue":{"url":"https://api.github.com/repos/TeamPorcupine/ProjectPorcupine/issues/726","repository_url":"https://api.github.com/repos/TeamPorcupine/ProjectPorcupine","labels_url":"https://api.github.com/repos/TeamPorcupine/ProjectPorcupine/issues/726/labels{/name}","comments_url":"https://api.github.com/repos/TeamPorcupine/ProjectPorcupine/issues/726/comments","events_url":"https://api.github.com/repos/TeamPorcupine/ProjectPorcupine/issues/726/events","html_url":"https://github.com/TeamPorcupine/ProjectPorcupine/issues/726","id":172883914,"number":726,"title":"Thoughts and early attempt at a new Job System","user":{"login":"vogonistic","id":159568,"avatar_url":"https://avatars.githubusercontent.com/u/159568?v=3","gravatar_id":"","url":"https://api.github.com/users/vogonistic","html_url":"https://github.com/vogonistic","followers_url":"https://api.github.com/users/vogonistic/followers","following_url":"https://api.github.com/users/vogonistic/following{/other_user}","gists_url":"https://api.github.com/users/vogonistic/gists{/gist_id}","starred_url":"https://api.github.com/users/vogonistic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vogonistic/subscriptions","organizations_url":"https://api.github.com/users/vogonistic/orgs","repos_url":"https://api.github.com/users/vogonistic/repos","events_url":"https://api.github.com/users/vogonistic/events{/privacy}","received_events_url":"https://api.github.com/users/vogonistic/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/TeamPorcupine/ProjectPorcupine/labels/discussion","name":"discussion","color":"e99695"},{"url":"https://api.github.com/repos/TeamPorcupine/ProjectPorcupine/labels/feedback%20requested","name":"feedback requested","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/TeamPorcupine/ProjectPorcupine/milestones/1","html_url":"https://github.com/TeamPorcupine/ProjectPorcupine/milestones/Version%200.1","labels_url":"https://api.github.com/repos/TeamPorcupine/ProjectPorcupine/milestones/1/labels","id":1955242,"number":1,"title":"Version 0.1","description":"","creator":{"login":"quill18","id":777633,"avatar_url":"https://avatars.githubusercontent.com/u/777633?v=3","gravatar_id":"","url":"https://api.github.com/users/quill18","html_url":"https://github.com/quill18","followers_url":"https://api.github.com/users/quill18/followers","following_url":"https://api.github.com/users/quill18/following{/other_user}","gists_url":"https://api.github.com/users/quill18/gists{/gist_id}","starred_url":"https://api.github.com/users/quill18/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quill18/subscriptions","organizations_url":"https://api.github.com/users/quill18/orgs","repos_url":"https://api.github.com/users/quill18/repos","events_url":"https://api.github.com/users/quill18/events{/privacy}","received_events_url":"https://api.github.com/users/quill18/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":4,"state":"open","created_at":"2016-08-22T13:16:18Z","updated_at":"2016-08-25T16:31:53Z","due_on":"2016-09-30T00:00:00Z","closed_at":null},"comments":22,"created_at":"2016-08-24T07:34:05Z","updated_at":"2016-08-25T20:02:07Z","closed_at":null,"body":"WARNING: I ramble a lot in here. It's past midnight, but I wanted it shared. I'll update this post as things gets fixed, catch fire, I give up. @svmnotn has volunteered to help.\r\n\r\nI've written this at an attempt at getting us a new job system. Link to the code is in the bottom, but there isn't that much to see. The code is purposely disconnected from the game. I wanted the logic to work before I tried to integrate it.\r\n\r\nHere is how it operates more or less: You create a Goal based on one or more Conditions:\r\n```cs\r\nnew Goal(\"Build a Wall\", new Vector2(0, 0), new Condition(\"inventory\", \"Steel Plate\", 5))\r\n```\r\nGoal will be a cheap wrapper around a Job, or maybe replaced by a Job. I also used a Vector2 for location to make it easy to calculate distance. It'll be replaced with a tile.\r\n\r\nResolve will create a PathToGoal from the Goal and for each PathToGoal we have, loop over a list of functions that looks for matches. If they find a match, they output an Action that has conditions it provides and requires. There is an initializer for PathToGoal that takes a PathToGoal and a new action to build on it. We keep going until we've exhausted the search or we found the goal. There is only have a single path implemented now, which is to fetch items. Here is the result of running it:\r\n\r\n```\r\nfoundPath =>  [PathToGoal cost: 42\r\n   [Goal name: Build a Wall, location: (0.0, 0.0), requires: ([Condition type: inventory, name: Steel Plate, details: (5))]\r\n   Fulfilled:\r\n     [Condition type: inventory, name: Steel Plate, details: (1)\r\n     [Condition type: inventory, name: Iron Ore, details: (1)\r\n   Actions:\r\n     [Action name: Forge Iron to Steel, cost: 22, location: (0.0, 20.0)]\r\n     [Action name: Fetch Iron Ore, cost: 20, location: (20.0, 0.0)]\r\n ]\r\n```\r\n\r\nThings I'm thinking about:\r\n  1. I'm currently tracking cost in time. Need to ask the Character if they want to apply a modifier to paths and actions (Afraid of open spaces? Hate a particular machine?)\r\n  1. Do we optimize the walking to the closest resource (create a walk action) or do we just check that it exists and let the character deal with it (recreate the pathfinding and verify that the resource still exists) as they pop the action?\r\n  1. How do you detect loops? Do we just let them happen and have a cutoff in how long the paths can be?\r\n  1. What can't we implement with a system like this?\r\n  1. If people are idling and have an organization skill, they could look at all the actions in the queue and determine that there is a need for 100 steel plates in room 42. If there is a stockpile, they could create a job to transfer the plates there.\r\n  1. How do we create a job to do basic housekeeping items? Removing dust, feeding the generator, stocking items, carrying stuff to stockpiles?\r\n  1. How does this work with something like defending against attackers?\r\n  1. How do we integrate some kind of smartness so that a guy a mile away doesn't grab a critical job, like building a tile in a bridge.\r\n\r\nNext actions:\r\n - [ ] We need to make Condition into an interface.\r\n - [ ] Need to be able to split InventoryConditions based on count\r\n - [ ] In XML version, add parameter for max on input and output (inventory prefab has default max stack size)\r\n - [ ] Need to take walking into account. I.e. if you need ice and steel, go fetch one, drop it off, fetch second, drop it off. Different path from being able to carry both.\r\n - [ ] Add code that can figure out if we need to drop off inventory or can pick up more\r\n - [ ] Let the Character modify cost for path and action\r\n - [ ] Split into 1 class per file\r\n - [ ] Integrate into game (Sounds easy!)\r\n\r\nIt's early code so take it for what it is: https://github.com/vogonistic/ProjectPorcupine/blob/job-optimizer/Assets/Scripts/Jobs/JobUtils.cs\r\n\r\n@svmnotn Ping!"},"comment":{"url":"https://api.github.com/repos/TeamPorcupine/ProjectPorcupine/issues/comments/242517563","html_url":"https://github.com/TeamPorcupine/ProjectPorcupine/issues/726#issuecomment-242517563","issue_url":"https://api.github.com/repos/TeamPorcupine/ProjectPorcupine/issues/726","id":242517563,"user":{"login":"vogonistic","id":159568,"avatar_url":"https://avatars.githubusercontent.com/u/159568?v=3","gravatar_id":"","url":"https://api.github.com/users/vogonistic","html_url":"https://github.com/vogonistic","followers_url":"https://api.github.com/users/vogonistic/followers","following_url":"https://api.github.com/users/vogonistic/following{/other_user}","gists_url":"https://api.github.com/users/vogonistic/gists{/gist_id}","starred_url":"https://api.github.com/users/vogonistic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vogonistic/subscriptions","organizations_url":"https://api.github.com/users/vogonistic/orgs","repos_url":"https://api.github.com/users/vogonistic/repos","events_url":"https://api.github.com/users/vogonistic/events{/privacy}","received_events_url":"https://api.github.com/users/vogonistic/received_events","type":"User","site_admin":false},"created_at":"2016-08-25T20:02:07Z","updated_at":"2016-08-25T20:02:07Z","body":"@Randshot This system would allow an idling character with the OCD/Organizer trait to look at the jobs and very quickly (like 1 ms) get a list of all the requirements for jobs in the queue and go fetch a stack of the biggest need."}}
{"actor":{"display_login":"vogonistic"}}