Changelog
== 1.4.0 ==
** The vehicle learns what it can do: while driving, the mod measures how fast this vehicle type really turns at every speed (a car standing still does not turn, a slow car turns slowly - the 1.3.x log showed 2.5..4.5 times less than assumed, the reason for most "off track") and how hard it brakes. The planner builds its arcs and speeds from that; the driver steers with it. Kept per vehicle type; /vc-mark shows what was learned.
** Safety: the vehicle can always stop on the path it has (nothing beyond its end was checked); it no longer goes faster than the planned speed; near things it goes only as fast as it keeps to the line; the next stretch starts far enough ahead to slow down for a tight turn.
** Trains, other vehicles and people: the driver watches the path within stopping distance every tick, guesses where moving ones will be, and stops and waits (a train going past: until it is through). Standing trains are obstacles on the map, moving ones are not (the map is read again when a train starts or stops).
** Faster planning: a search node takes 2.5 times less time, map chunks are read faster and the work per tick is counted as it really is (about 1.4 ms at most for each search); the next stretch is no longer planned every tick at speed; a goal walled in is recognised at once (it took seconds).
** Fewer stops: a stretch that takes another lane no longer makes the whole way be planned again; a stretch found a moment late is still joined on; turning round on a narrow road and backing out of a bay are found much faster.
** Fixed: in follow mode the vehicle was never found stuck (every new plan reset the count); stopping (player close) let the vehicle roll on instead of braking; the vehicle could miss the end of its path after a very short last arc.
** Repeated "off track" at one spot counts as trouble there (more room, then giving up) instead of the same plan again and again.
** Tests: tests/sim runs the mod's own code outside the game on a model of the surface and the vehicle (see tests/sim/README.md).
== 1.3.1 ==
** Fixed zigzag driving (found with the 1.3.0 log): the local path was built only from fixed turns, and the gentlest of them still turns a car about 20 degrees per tile, so a way at any other angle came out as a saw tooth - even in open ground - and every tooth was an arc the vehicle had to slow down for.
- Direct way first: the next stretch is joined to the vehicle with an arc, a straight and an arc, as wide as fits (radius 16, 8, 4 tiles, then the gentle arc), checked against the vehicle's body. In the open this is the whole stretch: straight in any direction, wide arcs only where the heading changes, full speed.
- The search (needed near obstacles, for three-point turns and backing out) tries the direct way to the end of the stretch every few steps, and its forward parts are smoothed afterwards with such ways wherever the body fits - never with less room than before.
- Checked on paper (a model of the planner, same formulas): random forests and bases - no collisions, as many stretches found as before, half the arcs, a third of the slow driving; a long trip in the open - wide arcs and straights only.
- The log shows how a stretch was made (direct=start/nodeN, shots, smoothed) and the radius of every arc (e.g. fwd-cw/r16 2.3).
== 1.3.0 ==
** New route planning, without the engine pathfinder (it plans like a biter: an axis-aligned box on tile centres, and it chews through trees and rocks).
- Navigation map: for every point of a half-tile grid, how much room there is to the nearest obstacle (whatever the vehicle collides with: buildings, trees, rocks, cliffs, water). Read per 32x32 chunk where a search needs it, kept between trips, read again when something is built, mined or destroyed there (or after 2 minutes).
- Global path: A* over that map from the vehicle to the goal. Passages narrower than the vehicle are closed, being close to things costs more, so the way keeps to the middle of passages and away from trees and poles. Spread over ticks; straightened where a straight line has as much room.
- Local path: the next 20..50 tiles of the way are planned for the vehicle's real rotated body: arcs it can actually steer, forwards and backwards, each point with a speed. Three-point turns and backing out of corners are simply part of the plan. The next stretch is planned while driving and joined on without stopping.
** Driving follows the local path forwards and backwards, stops at every change of direction, and steers already while standing (in 1.2.x a manoeuvre starting with a turn pushed straight into the obstacle first and never got going - the most common "stuck").
** Stuck: the way that got stuck is not tried first again from the same spot, and the room kept around the body grows with every try there. Pushed off the path or something new in the way: the stretch is planned again from where the vehicle is. No stretch at all: the map there is read again and the whole way planned again.
** Giving up at a spot: in follow mode the next try waits longer every time (5 s, 10 s, 20 s ... up to 1 min) instead of trying (and burning fuel) every 5 s forever. Driving away from the spot resets it.
** Follow mode no longer plans again every 10 ticks when the spot near the player had to be moved to a free place more than 3 tiles away.
** Removed: engine path requests, the separate escape search, the long way around search and the local detours (all replaced by the above).
== 1.2.4 ==
** A vehicle getting out of a tight spot now drives about 10 tiles away from it before planning the route again (at least 3 tiles when there is no way that far). The manoeuvre search covers 16 tiles around the vehicle and may take up to about 4.5 s.
== 1.2.3 ==
** Backing out of tight spots goes three times further: each backward move of a manoeuvre is 1.5 tiles instead of 0.5 (still checked against the body all the way), and a way out is at least 3 tiles from where the vehicle got stuck.
== 1.2.2 ==
** Turning around at the start of a route is planned: when the route starts behind the vehicle, the manoeuvre search finds a way onto the route facing along it - forwards if there is room, a three-point turn or backing out if not - and the route is driven on from there. Before, the vehicle turned while driving forwards and could run into a cliff or a wall in front of it again and again.
** Getting stuck on the way works the same: the vehicle backs out carefully and gets onto its route a bit further on, without planning everything again.
== 1.2.1 ==
** Fixed "no route" past forests: the engine pathfinder plans like a biter and goes straight through trees, and the local detours (a small window) cannot get around a whole forest. When every engine path is blocked, the mod now searches a long way around itself: a 0.5 tile grid over an area around start and goal (up to 260x260 tiles), obstacles read only where the search goes, spread over ticks. Cells close to trees cost more, so the path keeps clear of them. The result goes through the usual checks, straight runs and arcs.
== 1.2.0 ==
** Getting out of tight spots is planned instead of guessed. When the vehicle is stuck, or no route can be planned because it is squeezed in between things, a manoeuvre is searched first: short moves forwards and backwards, straight or steering, checked against the real rotated body of the vehicle. The search runs over several ticks (up to about 2.5 s), collects up to 12 ways out and takes the best one (short, few changes between forwards and backwards, towards the goal and facing it). The manoeuvre is driven slowly; only then the full route is planned.
- Replaces blind backing up and nudging.
- Up to 4 escapes from one spot, then the vehicle gives up (driving away resets the count).
- Debug drawing shows the chosen manoeuvre (magenta forwards, white backwards); the log records the search and every move.
== 1.1.5 ==
** Fixed most "no route" cases (found with the 1.1.4 log): the engine pathfinder plans on tile centres, and when the vehicle stood close to a pole, turret, inserter or machine, its box at the nearest tile centre already touched it and the engine gave up at once, even for a goal 3 tiles away. The engine path now starts (and ends) at the nearest free tile centre; the mod checks the stretch from the vehicle to it itself.
** Nudging and backing up use the real rotated body of the vehicle and may steer: a vehicle at an angle to the corner of a building is no longer "pinned on both sides". The way steering turns while reversing is learned while driving.
** The nudge count resets after driving away from the spot.
== 1.1.4 ==
** Diagnostic log (mod setting, on by default): planning and driving problems are written to script-output/vehicle-commander/debug-N.log.
- Every route request (why, from where, goal and where it was moved to), every engine path result, the chosen route.
- "No route": the reason per variant, the blocked segment with the obstacles that block it, why no detour was found.
- Getting stuck, backing up, nudging, leaving the route, new obstacles on the route, the driver taking over.
- /vc-mark <text> adds a note with the state of your vehicles, /vc-log-clear starts afresh. At most two 4 MB files are kept.
== 1.1.3 ==
** Fixed "no route" after backing into something: a vehicle touching an obstacle could not get a path (the engine cannot start inside an obstacle, and the checks saw the obstacle closer than the required clearance), and every try counted as a failure.
- Right around the vehicle only its bare width has to be free (path check, detour search and live check).
- A vehicle pinned against something first moves straight away from it (forwards or backwards, where there is room) and then plans again; this does not count as a failed route.
- Backing up to get unstuck only happens when there is room behind.
== 1.1.2 ==
** Following is remembered: after a trip to a point (autopilot, ALT+M, GPS tag) the vehicle goes back to following instead of stopping. A vehicle that gets stuck while following keeps following after a pause.
** Fixed left/right twitching: vehicles snap to the nearest horizontal/vertical/diagonal axis (rotation_snap_angle), so headings just next to an axis cannot be held. Steering now drives along the axis there and corrects clearly outside the snap zone; it also no longer flips from full left to full right for a one-tick overshoot.
** Fixed endless re-planning when the goal is behind the vehicle: the start of such a route is treated as a U-turn, during which swinging away from the route is allowed.
== 1.1.1 ==
** Fewer "no route" failures:
- a goal inside water, a building or a tree is moved to the nearest free spot;
- obstacle checks measure the real distance to a box (growing boxes as squares blocked passages at every corner);
- detour search: real distance too, a larger area, several targets, a free cell next to a blocked goal;
- a segment the engine marks as "destroy" is accepted when nothing is actually in the way;
- when no detour exists but the vehicle itself fits, the spot is driven slowly instead of failing.
** Steering follows the route line (Stanley controller) instead of aiming at a point ahead, so arcs are no longer cut on the inside; arcs are driven 15% below the full-steering speed.
** Debug mode prints why a route failed for every variant.
== 1.1.0 ==
** Routes are now planned in full before driving, spread over several ticks:
- the engine is asked for 2-3 path variants (padded box, exact box, coarse grid for long routes);
- every variant is checked end to end against the mod's own collision model; blocked stretches (trees, rocks, poles) get a local A* detour;
- the zigzag grid path is straightened into the longest runs that keep clearance;
- every bend gets an arc the vehicle can actually drive, checked for collisions in advance (corner cutting is decided while planning, not while driving);
- every route point gets a speed, so the vehicle brakes in time for every corner ahead;
- the variant with the shortest estimated time is used.
** Driving follows the planned route (pure pursuit), re-checks the route ahead for new obstacles and plans again when needed.
** Code split into modules under script/.
== 1.0.11 ==
** Fixed driving into trees, rocks and poles: the engine pathfinder plans like a biter and may route through things it would destroy (needs_destroy_to_reach). The mod now checks the path ahead against its own collision model and finds a local detour (A* on a 0.5-tile grid) around blocked stretches.
** Fixed skipping a bend around an obstacle: progress along the path only looks a few segments ahead.
** Where there is no room for a straight run, the vehicle follows the path closely and slowly instead of cutting corners.
** New map setting: show vehicle routes (debug drawing).
== 1.0.10 ==
** Fixed: Ctrl + left click on the map did nothing (in remote view player.vehicle is nil; now uses physical_vehicle). Same for ALT+M.
** Fixed collisions on straight runs: the corridor now covers the vehicle in any heading (same padded size the path was planned with), and obstacles are found by comparing collision layers directly instead of relying on the search filter.
** Gentler turns: the heading is corrected within 2.5 tiles of travel and corners within 2 tiles, so the vehicle cuts corners less.
== 1.0.9 ==
** Straight runs: the vehicle drives straight to the furthest waypoint it can reach without hitting anything (line-of-sight check against entities and tiles), instead of following the zigzag grid path.
** Speed planning from the vehicle turn rate: full speed on straights, braking only as much as the next corner and the end of the path need. Braking strength is measured while driving.
** Steering dead zone matched to the vehicle turn rate and the distance to the aim point.
** New: Ctrl + left click while driving a car or tank turns on the autopilot to the clicked spot (world or map). Any driving key hands control back.
** ALT+M prefers the linked vehicle you are sitting in.
== 1.0.8 ==
** Backs up when stuck (straight, then left, then right) and re-plans; gives up with a message after several attempts.
** Re-plans when pushed off the path, after a failed search (with growing delay), and in follow mode when the player moves away from the path goal.
** Fewer collisions: paths keep a safety margin around the vehicle (falls back to the exact size in tight spots), steering looks ahead along the path, slows down for turns and before the end.
** No longer keeps driving blind while waiting for a new path.
** Point mode stops and reports when it arrives or when no route exists.
== 1.0.7 ==
** Fixed crash: surface.request_path was called without the required collision_mask; bounding_box is now the vehicle size instead of a search area.
** Fixed steering: vehicle.orientation is 0..1, it was compared with degrees, so the vehicle drove in circles.
** Vehicles are stored as entity references (works for any car-type vehicle, including modded ones).
** Removed storage writes from on_load; vehicle-lost message now uses on_entity_died.
** Follow mode retries pathfinding after a failed request or when stuck; brakes near the destination.
== 1.0.6 ==
** Fixed 2.x API mismatches: riding_state uses numeric defines, vehicle name read from entity.localised_name.
== 1.0.5 ==
** Rewrote vehicle driving: request_path waypoints + riding_state (the 2.x command API only works for enemies).
** Fixed localisation: locale files now use the required .cfg format.
== 1.0.4 ==
** Show the Link panel for every car-type vehicle; validate remote-driving support on link.
** HUD icon is created lazily so it appears on existing saves too.
** Temporary debug print (VC-DEBUG) on vehicle GUI open.
== 1.0.3 ==
** Fixed runtime error: use the 2.x prototypes API and entity.commandable check.
== 1.0.2 ==
** Fixed mod load error (util function removed in Factorio 2.x).
== 1.0.1 ==
** Version bump for portal re-upload (no functional changes).
== 1.0.0 ==
** First release for Factorio 2.1.
** Remote control for the base car and tank (no new vehicles).
** Link a vehicle from its GUI (Link button).
** HUD icon in the top-left corner with the list of linked vehicles.
** Follow mode with a configurable per-player radius (mod setting).
** Drive to a point: hotkey ALT+M at the mouse cursor position (world or map) or clicking a GPS tag.