[MOD 0.14] AAI Programmable Vehicles

Topics and discussion about specific mods
Post Reply
User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 711
Joined: Sun Nov 23, 2014 11:57 am
Contact:

[MOD 0.14] AAI Programmable Vehicles

Post by Earendel »

The attachment programmable-vehicles.png is no longer available
Title: AAI Programmable Vehicles
Short Description: Program and control autonomous vehicles using a remote control handset or circuit conditions and zones. Can be used for base enemy base assault, patrols, friendly base navigation, vehicle-based mining, vehicle-based resource transportation, and more advanced applications. Works with vanilla and modded vehicles.
Name: aai-programmable-vehicles
Factorio Version: 0.14
Mod State: Beta
Dependencies: Base, Data Raw Prototypes, Detached Gun Sounds, Off-Grid Effects, AAI Programmable Structures, AAI Signals, AAI Zones, AAI Vehicles: Miner, AAI Vehicles: Hauler
Optional Extras: Bullet Trails, AAI Vehicles: Chaingunner, AAI Vehicles: Flame Tumbler, AAI Vehicles: Laser Tank
Author: Earendel
Downloads: Mod Portal
Licence: See below

Long Description
The Advanced Autonomous Industries: Programmable Vehicles mod gives all car-type vehicles some basic AI and allows you to command, control, and automate vehicles.

Vehicle Turrets
Any vehicles with a weapon act like a turret when they are not be directly driven by a player and will shoot at enemy targets. If you hop out of your car to build something then your car will defend you.

RTS-style Command & Control
You start with a Unit Remote Controller, a remote control handset that lets you select groups of units and order them around. The movement commands use biter AI. It can be used to send miners to resource zones, order haulers around, or order vehicles towards enemy bases.
programmable-vehicles.png
programmable-vehicles.png (18.2 KiB) Viewed 168819 times
Paths and Waypoints
Press Y (twice) to get a Path Remote Controller. This lets you add waypoints to any number of paths.

Vehicles can be sent to a path start to follow a complicated path around your base. Waypoints can be attached to players other vehicles so you can have a vehicle loop between a mining vechile and a vehicle depot without needing to use any combinators.

Hauling Vehicles
Hauler-type vehicles have an automatic inventory transfer system based on their Unit Data (see below). Their default setting is to accept raw resources. Miner-type vehicles are by default configured to try and push resources to nearby haulers. All vehicles are by default configured to try and pull a bit of coal or wood from haulers so that they can keep running. Vehicle Unit Data settings can be set with a Vehicle Deployer or modified with the Unit Data Controller structure.

Unit Data
Vehicles can store signal data. The signal data can be read with a Unit Data Scanner, or set with a Vehicle Deployer (at deployment only) or a Unit Data Controller (at any time). Item Signals are used in the Automatic Inventory Transfer System (see below), but Item Signals and Virtual Signals (letters, numbers, zones) can also be used to store arbitrary information, such as unique identifiers, squad assignments, or signals to signify alternate behavior.

Automatic Inventory Transfer System
Hauler-type vehicles and other types of vehicle handle Unit Data a bit differently.
Most vehicles use any Item-type signals (Iron Ore, Piercing Rounds Magazine, etc) as a target amount of items to store in their inventory. If there is a Hauler-type vehicle nearby and the vehicle is below it’s target it will pull the missing items from the Hauler. If the vehicle is over it’s target amount then it will try to push the excess items to the Hauler IF the Hauler is set up to accept that item type. If a negative value is set it will always try to clear that type from its inventory. Most vehicles have default Unit Data of Coal 50, meaning they will try and take 1 stack of coal (for their fuel inventory). Miners are configured with Iron Ore -1, Copper Ore -1, Stone -1, Raw Wood 50, and Coal 100. This means they will try and get rid of Ore, and Stone but keep a bit of wood or coal for fuel and export the rest.
Hauler-type vehicles use any Item-type signals as acceptable limits for other vehicles to push items to them. Their default settings are to accept up to 12000 of raw resources. If two haulers meet and one is over it’s acceptable capacity for an item and the other hauler can accept that item then the other Hauler can take the excess up to their own acceptable limit. If you deploy a vehicle from a Vehicle Deployer it will be deployed with any signal data the deployer's build-in constant combinator (bottom right of the structure).

Other changes
The tech tree has been altered slightly to make it easier to get vehicles a bit earlier.

To help enforce a specialised vehicle roles a vehicle is only allowed 1 weapon type.

Enemy structures can prevent nearby construction.

Example Uses
Use tile scanning to flag resources with zones. Send miners to those zones. Send haulers to the miners and then back to a depot when they have collected items.

Deploy combat vehicles with signal data of a certain zone, then send then to their assigned zone for patrols or attacks.

If vehicle health drops too low send them back to the base for repairs.

Use the tile scanner to find enemy bases, mark those with attack zones, and send vehicles in to attack without your involvement.

Current issues
Vehicles use biter AI when commanded with Unit Remote Controller or sent to an XY-Tile with a Unit Controller. The biter AI can be a bit derpy.

Demo Factory Save File
Exchange-Data.png
Exchange-Data.png (285.54 KiB) Viewed 160517 times
Tutorial Videos by Nilaus
1. Vehicles and Manual Commands https://youtu.be/paUEMY3lTyQ
2. Scanners and Controllers https://youtu.be/e93rbJmFTyU
3. Automatic Zone and Miner assignment https://youtu.be/z8zBhn4SBD0
4. Automatic Alien Search and Destroy https://youtu.be/e_S5FwEDxeY
5. Automatic Haulage from Miner to Depot https://youtu.be/QoVRsQ4e6RE

Tutorial Videos by Steejo
1. Structures and Vehicles https://www.youtube.com/watch?v=tduRKYp_-ng

Tutorial Videos by Seeeno (German / Deutsch)
1. Overview / Überblick: https://www.youtube.com/watch?v=FIv0P9bUG3M
2. Zoning / Zonen : https://www.youtube.com/watch?v=Mumq28aVCyM
3. Auto-Zoning / Auto.-Zone: https://www.youtube.com/watch?v=9ODmYLhamng
4. Military / Militär: https://www.youtube.com/watch?v=woSei_ziAmo
5. Logistics / Wirtschaft: https://www.youtube.com/watch?v=dKhWarfOcvg

Instructions
The Programmable Structures mod forum page has the details of structure inputs options and potential outputs. In the posts below are some basic but useful vehicle-specific setups to get you started but they can be improved. You are encouraged to try and make some clever configurations of your own and post them in this mods forums thread.

Vehicle Deployer
Vehicle-Depot.png
Vehicle-Depot.png (146.35 KiB) Viewed 160518 times
If you deploy a vehicle by hand (place it down) then it will have some default Unit Data based on it's type (miners export ore, haulers accept ore, vehicles request fuel). A vehicle deployed from the Vehicle Deployer will NOT have these defaults so you can set your own using the attached combinator. It is useful to have a separate deployer for miners, haulers, and other vehicles categoriesd by the ammo type they use. If you're feeling clever, you could instead use 1 deployer but change the signals based on the type of vehicle currently in the chest.

Vehicle Depot
warfare.jpg
warfare.jpg (241.19 KiB) Viewed 168773 times
You can use a Vehicle Depot to rapidly drop off cargo from vehicles, or resupply vehicles. There is a built-in combinator to the top right. Any signals set there or connected to it set the depot's exchange data, which functions like unit data. When interacting with most vehicles the depot acts like a hauler, but when interacting with haulers it acts like a normal vehicle. The effectively means that it acts as though it has a priority between the two.
The simple concept is that setting a high value means the depot is accepting that item, setting a negative value means it is trying to give that item away.

Here are some examples:
Depot signal is 20 Coal but has 0 Coal, Vehicle signal is -1 coal but has 200 coal: 20 Coal is given to the depot.
Depot signal is 200 Coal but has 50 Coal, Vehicle signal is -1 coal but has 200 coal: 150 Coal is given to the depot.
Depot signal is 200 Coal but has 50 Coal, Vehicle signal is 50 coal but has 200 coal: 0 Coal is given to the depot.
Depot signal is -50 Coal but has 50 Coal, Vehicle signal is 50 coal but has 200 coal: 0 Coal is given to the vehicle.
Depot signal is -50 Coal but has 50 Coal, Vehicle signal is 50 coal but has 0 coal: 50 Coal is given to the vehicle.
Depot signal is 20000 Coal but has 200 Coal, Hauler signal is 500 coal but has 5000 coal: 5000 Coal is given to the depot.
Depot signal is -1 Coal but has 700 Coal, Hauler signal is 500 coal but has 0 coal: 500 Coal is given to the hauler.


Unit Data / Exchange Data Example
Vehicle-Deployer.png
Vehicle-Deployer.png (204.34 KiB) Viewed 160517 times
Licence
Last edited by Earendel on Fri Oct 05, 2018 1:57 am, edited 16 times in total.

User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 711
Joined: Sun Nov 23, 2014 11:57 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Earendel »

Getting Started Examples

Resource Zone Assignment
Scan nearby tiles and assign zones to those tiles.
Resource Zoning.jpg
Resource Zoning.jpg (236.42 KiB) Viewed 168846 times
Resource-Zoning.png
Resource-Zoning.png (31.76 KiB) Viewed 160549 times
Blueprint String
The distance input defines the scanner range. Starting with a smaller range is good to make sure the first zones placed are not too far away. This setup could be improved by scanning specific XY tiles in a spiral pattern instead of using the distance signal to scan a random tile.
The zone types used are arbitrary, you can use whichever zones you like.

Miner To Resource Zone
Sends a miner to a zone placed over a certain type of resource.
Miner To Resource Zone.jpg
Miner To Resource Zone.jpg (206.32 KiB) Viewed 168846 times
Miner To Resource Zone.png
Miner To Resource Zone.png (14.03 KiB) Viewed 160549 times
Blueprint String
In this example a specific miner (the 2nd miner placed) is sent to the first tile in a resource zone. The zone input should be whichever zone you want the miner to go to. This setup could be improved by looping through many miners, potentially differentiating assignments based on Unit Data.

Clear Empty Resource Zone
Scans an existing resource zone checking for empty tiles. If the resource has been depleted the zone is removed.
Clear Empty Resource Zone.jpg
Clear Empty Resource Zone.jpg (214.31 KiB) Viewed 160549 times
Clear Empty Resource Zone.png
Clear Empty Resource Zone.png (19.54 KiB) Viewed 160549 times
Blueprint String
In this case the zone used was intended to mark trees for harvesting. If there are no trees there anymore the zone is removed so a miner can move to the next tree.
An alternate approach could be to scan tiles around miners assigned to harvest wood.

Hauler loop from Depot to Miner and back.
Send a Hauler to a miner then back to a Depot.
Hauler Miner Depot Loop.jpg
Hauler Miner Depot Loop.jpg (247.64 KiB) Viewed 168846 times
Hauler-Miner-Depot-Loop.png
Hauler-Miner-Depot-Loop.png (33.74 KiB) Viewed 160549 times
Blueprint String
In this example a specific Hauler (Hauler 4) is sent to a specific Miner (Miner 4) to collect it’s inventory (Coal). Once it has a minimum amount of coal it is sent back to the depot to be unloaded.
In this case the depot is marked with a single-tile Zone Black Circle. It was the first Zone Black Circle tile to be placed so it has an index of 1.
Last edited by Earendel on Mon Feb 13, 2017 11:33 am, edited 5 times in total.

rubberduck
Burner Inserter
Burner Inserter
Posts: 15
Joined: Mon Apr 18, 2016 12:27 pm
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by rubberduck »

Well color me f*cking impressed!

I'm gonna use all of them AAI - xxx mods.
Someone really produced high quality here.
visit https://factorioprints.com/ for all your blueprint needs

fregate84
Fast Inserter
Fast Inserter
Posts: 233
Joined: Sun Jun 22, 2014 10:56 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by fregate84 »

Can we have some exemple how tank work ? How to set a patrol aroud a base for exemple, or how to attack automaticity a zone ?

it look nice, but difficult to understand without example.

User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 711
Joined: Sun Nov 23, 2014 11:57 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Earendel »

fregate84 wrote:Can we have some exemple how tank work ? How to set a patrol aroud a base for exemple, or how to attack automaticity a zone ?

it look nice, but difficult to understand without example.
Send Chaingunners to Attack Zone
Loop through all of the chaingunners on the map and send them to an Attack Zone.
vehicle-to-zone.jpg
vehicle-to-zone.jpg (276.97 KiB) Viewed 168785 times
units-to-zone.png
units-to-zone.png (25.97 KiB) Viewed 160550 times
In this case the attack zone is Diagonal Left Red, which you can place with the Zone Planner or a Zone Control Tower.
Each unit is sent to a tile based on it's ID * 6, so they are spaced 6 tiles apart and should bump in to each other slightly less, but it does mean you need to place at least 6 zone tiles to send 1 unit.
Last edited by Earendel on Mon Feb 13, 2017 11:28 am, edited 2 times in total.

User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 711
Joined: Sun Nov 23, 2014 11:57 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Earendel »

Laser Tank Patrol
Loop through all of the Laser Tanks on the map. If one is in a patrol zone send it to the next patrol zone.
laser-tank-patrol.jpg
laser-tank-patrol.jpg (148.33 KiB) Viewed 168765 times
laser-tank-patrol.png
laser-tank-patrol.png (26.54 KiB) Viewed 160550 times
In this case there are 4 zones in the patrol loop. A laser tank needs to be in a zone already to start the patrol, so you could kick the process off by parking a Laser Tank there, using the Unit Remote Controller, or place an entry zone outside a vehicle deployer.
The tanks in this setup will always try to move the the first zone tile placed. In some circumstances they might end up parking just outside the target zone. To get around this you can place a center tile first, then place more zone tiles around the edge so that the vehicle has to go further inside the zone to get to the first tile.

You can make a more complicated loop using more zone types. You could also use constant combinators to store a set of coordinates and use Unit Data to track how far around the loop they are (using something "P" signals or something).
Last edited by Earendel on Mon Feb 13, 2017 11:29 am, edited 2 times in total.

fregate84
Fast Inserter
Fast Inserter
Posts: 233
Joined: Sun Jun 22, 2014 10:56 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by fregate84 »

Earendel wrote:
fregate84 wrote:Can we have some exemple how tank work ? How to set a patrol aroud a base for exemple, or how to attack automaticity a zone ?

it look nice, but difficult to understand without example.
Send Chaingunners to Attack Zone
Loop through all of the chaingunners on the map and send them to an Attack Zone.
vehicle-to-zone.jpg
units-to-zone.png
In this case the attack zone is Diagonal Left Red, which you can place with the Zone Planner or a Zone Control Tower.
Each unit is sent to a tile based on it's ID * 6, so they are spaced 6 tiles apart and should bump in to each other slightly less, but it does mean you need to place at least 6 zone tiles to send 1 unit.
working, but complex... I will need time to understand all... Especially if Iwant to add a start zone, move back tank to reload/add fuel/repair to the start zone when need, and do no go patroling tank are not ready for this. And add a system to move to all patrolling zone (like each 'x' ticks, move to a a random other point od the zone)

User avatar
Sigma1
Fast Inserter
Fast Inserter
Posts: 231
Joined: Mon Nov 21, 2016 5:25 pm
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Sigma1 »

This is what I've been looking for for ages! And these are so high quality too! Thank you!
she/they

Sworn
Fast Inserter
Fast Inserter
Posts: 167
Joined: Sun Apr 03, 2016 8:10 pm
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Sworn »

Wow, really impressive! Well done.

Would be nice some "Spot light" videos about this.

admo
Inserter
Inserter
Posts: 27
Joined: Tue Jun 28, 2016 1:07 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by admo »

Hello, crash bug to report. Many of my attempts to put coal into a vehicle deployer cause the following error:

Code: Select all

Error while running event on_tick (ID 0)
__aai-programmable-
structures__/control.lua:387:attempt to index
field 'place_result' (a nil value)
Reproduction steps:
Place a vehicle deployer, do NOT put any vehicles inside the deployer, manually put coal in the deployer.

User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 711
Joined: Sun Nov 23, 2014 11:57 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Earendel »

admo wrote:Hello, crash bug to report. Many of my attempts to put coal into a vehicle deployer cause the following error:

Code: Select all

Error while running event on_tick (ID 0)
__aai-programmable-
structures__/control.lua:387:attempt to index
field 'place_result' (a nil value)
Reproduction steps:
Place a vehicle deployer, do NOT put any vehicles inside the deployer, manually put coal in the deployer.
Ok thanks, that has been fixed.

It was not intended to have non-vehicle items inserted but I can't prevent it.

Wildejackson
Long Handed Inserter
Long Handed Inserter
Posts: 53
Joined: Sun Jul 31, 2016 2:40 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Wildejackson »

Hey Earendel, amazing work so far! The mod seems super polished and the models are top notch, well done! I did have a few problems to report though:
I was very impressed with the vehicle prototype conversion, I totally did not expect to be able to program other mod's vehicles! (I particularly love the programmable planes) But it seems that this causes some issues with some other mods that use the vehicle prototype in an unorthodox manner. Satalite Uplink mod and the Avatars Mod both use buildings that you can enter, obviously borrowing from the vehicle prototype, but this means they get reset and broken. You can still enter the building fine, but nothing happens and the building now has a coal slot. I haven't looked into your migration code yet but perhaps its possible to specify certain mods to not be effected by the migration (a blacklist perhaps?).

I really wanted to see if I could use this mod to get automated ships, so I downloaded the Ships Mod but that seems to throw a rather serious crash upon tick 0 (opening a map) that I have listed below. The crash kicks me back to the main menu.

Code: Select all

Error while running event on_tick (ID 0)
Error when running interface function data-raw.prototype: __data-raw-prototypes__/control.lua:27: attempt to concatenate local 'prototype_name' (a nil value)
stack traceback:
	__aai-programmable-vehicles__/control-unit-unit_type.lua:51: in function 'unit_setup_vehicle'
	__aai-programmable-vehicles__/control-unit-unit_type.lua:12: in function 'unit_setup_unit_types'
	__aai-programmable-vehicles__/control-unit.lua:47: in function 'unit_force_update'
	__aai-programmable-vehicles__/control.lua:51: in function 'force_update'
	__aai-programmable-vehicles__/control.lua:64: in function <__aai-programmable-vehicles__/control.lua:62>
Lastly, I know you said the biter AI was super derpy and I entirely understand that this is out of your control, but I'd thought I should tell you that with fast vehicles, such as the flame runner and some planes, the AI completely deeps out, as it seems to be unable to cope with vehicles that turn or drive so fast, and the cars just end up skidding around out of control. Again I know that there is probably nothing that can be done but I thought I should tell you.

But once more over, very well done on the mod, I look forward to seeing how it shapes up in the future!

User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 711
Joined: Sun Nov 23, 2014 11:57 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Earendel »

Wildejackson wrote:Hey Earendel, amazing work so far! The mod seems super polished and the models are top notch, well done! I did have a few problems to report though:
I was very impressed with the vehicle prototype conversion, I totally did not expect to be able to program other mod's vehicles! (I particularly love the programmable planes) But it seems that this causes some issues with some other mods that use the vehicle prototype in an unorthodox manner. Satalite Uplink mod and the Avatars Mod both use buildings that you can enter, obviously borrowing from the vehicle prototype, but this means they get reset and broken. You can still enter the building fine, but nothing happens and the building now has a coal slot. I haven't looked into your migration code yet but perhaps its possible to specify certain mods to not be effected by the migration (a blacklist perhaps?).

I really wanted to see if I could use this mod to get automated ships, so I downloaded the Ships Mod but that seems to throw a rather serious crash upon tick 0 (opening a map) that I have listed below. The crash kicks me back to the main menu.

Code: Select all

Error while running event on_tick (ID 0)
Error when running interface function data-raw.prototype: __data-raw-prototypes__/control.lua:27: attempt to concatenate local 'prototype_name' (a nil value)
stack traceback:
	__aai-programmable-vehicles__/control-unit-unit_type.lua:51: in function 'unit_setup_vehicle'
	__aai-programmable-vehicles__/control-unit-unit_type.lua:12: in function 'unit_setup_unit_types'
	__aai-programmable-vehicles__/control-unit.lua:47: in function 'unit_force_update'
	__aai-programmable-vehicles__/control.lua:51: in function 'force_update'
	__aai-programmable-vehicles__/control.lua:64: in function <__aai-programmable-vehicles__/control.lua:62>
Lastly, I know you said the biter AI was super derpy and I entirely understand that this is out of your control, but I'd thought I should tell you that with fast vehicles, such as the flame runner and some planes, the AI completely deeps out, as it seems to be unable to cope with vehicles that turn or drive so fast, and the cars just end up skidding around out of control. Again I know that there is probably nothing that can be done but I thought I should tell you.

But once more over, very well done on the mod, I look forward to seeing how it shapes up in the future!
Hey Wildejackson, Thanks. I'll try and fix those issues. I can probably detect some properties of immovable vehicles and exclude that way instead of a blacklist.

User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 711
Joined: Sun Nov 23, 2014 11:57 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Earendel »

Ships are now supported. Previously the units just couldn't handle being in water because biter pathfinding does not work in water so I had to switch pathfinding off for ships.

Any vehicle with a weight of 0 or a max speed of 0 should now be excluded from the programmable prototypes. This should mean that Avatars and Satalite Uplink would not cause problems but I have not been able to test this.

Wildejackson
Long Handed Inserter
Long Handed Inserter
Posts: 53
Joined: Sun Jul 31, 2016 2:40 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Wildejackson »

Works perfectly with all of the above mods! Thank you, now I can make docks and shipping lanes.
I have to ask though, what is the X/Y Subtile data? I don't understand why the value is multiplied by 100? I understand that it allows for more accurate math without floating points, but there seems to be rounding errors with the system and seems to just add to complexity without any useful benefit. I have a picture with the rounding errors below:
http://imgur.com/a/9QCAj

But very nice job on the mod fixes! You continue to impress me again and again.

Alessandro
Burner Inserter
Burner Inserter
Posts: 7
Joined: Tue May 17, 2016 3:13 pm
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Alessandro »

I have a consult/bug report
Using the angel and Bob passive provider chests, It seems that any vehicule takes the info of the roboports.
I was trying the "Hauler loop from Depot to Miner and back." example from viewtopic.php?t=38475, trying to check the result I place a Unit dat Control / Scan, getting this werid data a mix of the unit data control plus items stored in Passive provider chest.
Derp.png
Derp.png (639.72 KiB) Viewed 168956 times

User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 711
Joined: Sun Nov 23, 2014 11:57 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Earendel »

Alessandro wrote:I have a consult/bug report
Using the angel and Bob passive provider chests, It seems that any vehicule takes the info of the roboports.
I was trying the "Hauler loop from Depot to Miner and back." example from viewtopic.php?t=38475, trying to check the result I place a Unit dat Control / Scan, getting this werid data a mix of the unit data control plus items stored in Passive provider chest.
Derp.png
Hi, sorry about that. That's a side-effect of me using roboports for the control towers but I didn't spot that in my testing. I fixed that issue last night but you need to update the AAI Programmable Structures mod to v0.1.5 (or higher).
Last edited by Earendel on Mon Dec 12, 2016 9:21 am, edited 1 time in total.

User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 711
Joined: Sun Nov 23, 2014 11:57 am
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Earendel »

Wildejackson wrote:Works perfectly with all of the above mods! Thank you, now I can make docks and shipping lanes.
I have to ask though, what is the X/Y Subtile data? I don't understand why the value is multiplied by 100? I understand that it allows for more accurate math without floating points, but there seems to be rounding errors with the system and seems to just add to complexity without any useful benefit. I have a picture with the rounding errors below:
http://imgur.com/a/9QCAj

But very nice job on the mod fixes! You continue to impress me again and again.
Image

Ok, so first why is X/Y Subtile data here?
X/Y Subtile data is for greater precision as you said, it helps get around an issue with signals where you can only use integers and decimal values are ignored.
The X/Y Subtile values are based on the direct multiplication of the entities real XY position within the game engine, the code is basically entity.position.x * 100.
This is different from the X/Y Tile value, which is math.floor(entity.position.x), in other words which Tile is the entity in.
The difference between the two value may seem trivial for the position of something static, but allows you to do more when doing things like tracking the position of a player or a vehicle. It allows for the possibility of commanding a vehicle using Angle and Speed Signals or a X/Y Subtile offset in order to position a vehicle exactly in the center or a tile, exactly at the point between a square of 4 tiles, or some other sub-tile position. Without X/Y Subtile data being returned you would not be able to make these sort of corrections.

Are there rounding errors?
It depends your definition. It may not work as you expect, but it is working as intended because it matches Factorio's coordinate system.
The combinatorics round to the nearest integer, but if you are trying to convert a subtile position to a tile position you need to floor the value instead. You can do the equivalent by subtracting 50 from the Subtile values before diving by 100.

User avatar
y.petremann
Filter Inserter
Filter Inserter
Posts: 407
Joined: Mon Mar 17, 2014 4:24 pm
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by y.petremann »

Could you add compatibility of your system to trains, basicaly the possibility to call a specific unit (train) depending on order of placement to order it to go to a specific station (which could also be numbered in order of placement), to check it's content, check if player is inside a wagon (so no manual control), check to which station it is ...

Alessandro
Burner Inserter
Burner Inserter
Posts: 7
Joined: Tue May 17, 2016 3:13 pm
Contact:

Re: [MOD 0.14] AAI Programmable Vehicles

Post by Alessandro »

Earendel wrote: Hi, sorry about that. That's a side-effect of me using roboports for the control towers but I didn't spot that in my testing. I fixed that issue last night but you need to update the AAI Programmable Structures mod to v0.1.5 (or higher).
Thanks for the fix, it works ok now, also thanks for the colission fix and all the others fixes.

Post Reply

Return to “Mods”