kyranf / robotarmyfactorio

A mod to add robot troop units and perhaps associated support buildings and items to produce and control them.
MIT License
35 stars 12 forks source link

Squads don't change targets if pathfinding fails #96

Closed ctcarton closed 7 years ago

ctcarton commented 7 years ago

I know factorio pathfinding isn't the most reliable. To compensate for that I would expect the squads to change targets if they can't find a path after some reasonable timeout, but they don't seem to do that. If the nearest alien hive is on an island or some other hard to path location the robots will just sit there forever instead of seeking out the second closest.

kyranf commented 7 years ago

Have you tried the "unstable" branch yet? It has some fixes for that. please test it for me :)

On Fri, Mar 10, 2017 at 3:05 AM, ctcarton notifications@github.com wrote:

I know factorio pathfinding isn't the most reliable. To compensate for that I would expect the squads to change targets if they can't find a path after some reasonable timeout, but they don't seem to do that. If the nearest alien hive is on an island or some other hard to path location the robots will just sit there forever instead of seeking out the second closest.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kyranf/robotarmyfactorio/issues/96, or mute the thread https://github.com/notifications/unsubscribe-auth/AHiOZtDuiE9tOShJ8glJjfqKuu26fZlHks5rkS6UgaJpZM4MZQk2 .

ctcarton commented 7 years ago

I just tried both unstable and development and got this error for both: http://imgur.com/7tw17in

kyranf commented 7 years ago

hey i just updated Unstable branch with a possible fix, please try it now. @ctcarton

kyranf commented 7 years ago

I fixed another bug I found later while testing, same part of the code.

thisismynombre commented 7 years ago

This is still happening, even with code I checked out from the unstable branch two days ago.

I am getting the same crash every time I deploy a robot.

0.002 2017-04-08 10:58:39; Factorio 0.14.22 (build 25342, win64, steam)
   0.002 Operating system: Windows 7 Service Pack 1
   0.002 Program arguments: "F:\Program Files (x86)\SteamLibrary\steamapps\common\Factorio\bin\x64\Factorio.exe" 
   0.002 Read data path: F:/Program Files (x86)/SteamLibrary/steamapps/common/Factorio/data
   0.002 Write data path: C:/Users/tpederson/AppData/Roaming/Factorio
   0.002 Binaries path: F:/Program Files (x86)/SteamLibrary/steamapps/common/Factorio/bin
   0.017 System info: [CPU: Intel(R) Core(TM) i7 CPU         950  @ 3.07GHz, 8 cores, RAM: 12279MB]
   0.017 Display options: [FullScreen: 1] [VSync: 1] [UIScale: 130%] [MultiSampling: OFF] [Screen: 255]
   0.018 Available display adapters: 1
   0.019  [0]: \\.\DISPLAY6 - NVIDIA GeForce GTX 1070 {0x05, [0,0], 2560x1600, 32bit, 60Hz}
   0.019 Create display on adapter 0. Size 1664x936 at position [438, 314].
   0.393 Initialised OpenGL:[0] GeForce GTX 1070/PCIe/SSE2; driver: 4.5.0 NVIDIA 378.92
   0.394     Video memory size (dedicated/total available/current available): 8192/8192/7833 MB
   0.425 DSound: Starting _dsound_update thread
   0.425 DSound: Enter _dsound_update; tid=7636
   0.426 Desktop composition is active.
   0.427 Graphics options: [Graphics quality: normal] [Video memory usage: all] [Light scale: 100%] [DXT: false]
   0.557 Loading mod core 0.0.0 (data.lua)
   0.563 Loading mod base 0.14.22 (data.lua)
   0.679 Loading mod Crafting_Speed_Research 0.1.4 (data.lua)
   0.754 Loading mod Nucular 1.0.4 (data.lua)
   0.835 Loading mod robotarmy 0.2.4 (data.lua)
   0.919 Loading mod upgrade-planner 1.2.14 (data.lua)
   1.006 Loading mod robotarmy 0.2.4 (data-updates.lua)
   1.087 Loading mod long-reach 0.0.6 (data-final-fixes.lua)
   1.180 Checksum for core: 1291735968
   1.180 Checksum for mod base: 786624017
   1.180 Checksum for mod Crafting_Speed_Research: 3928230558
   1.180 Checksum for mod long-reach: 3674062281
   1.180 Checksum for mod Nucular: 483423969
   1.180 Checksum for mod robotarmy: 1126326255
   1.180 Checksum for mod upgrade-planner: 696037660
   1.621 Info PlayerData.cpp:55: Local player-data.json available, timestamp 1491664226
   1.621 Info PlayerData.cpp:60: Cloud player-data.json available, timestamp 1480406473
   1.794 Initial atlas bitmap size is 16384
   1.811 Created atlas bitmap 16384x8724
   1.812 Created atlas bitmap 4096x1040
   1.814 Created atlas bitmap 4096x3660
   9.669 Sprites loaded
   9.669 Convert atlas 4096x1040 to: trilinear-filtering 
   9.710 Convert atlas 4096x3660 to: mipmap 
   9.847 Loading sounds...
  11.758 Custom inputs active: 0
  11.807 Factorio initialised
  14.780 Loading map C:\Users\tpederson\AppData\Roaming\Factorio\saves\1-OneMoreNewStart2.zip
  14.855 Info Scenario.cpp:152: Map version 0.14.22-0
  15.450 Checksum for script C:/Users/tpederson/AppData/Roaming/Factorio/temp/currently-playing/control.lua: 1057114497
  15.451 Checksum for script __Crafting_Speed_Research__/control.lua: 1826326919
  15.453 Checksum for script __Nucular__/control.lua: 2604603071
  15.461 Checksum for script __robotarmy__/control.lua: 3817749852
  15.464 Checksum for script __upgrade-planner__/control.lua: 2594213730
5424.043 Error MainLoop.cpp:788: Exception at tick 1453920: Error while running event on_tick (ID 0)
__robotarmy__/robolib/Squad.lua:52: attempt to perform arithmetic on field '?' (a table value)
5430.703 DSound: Stopping voice
5430.703 DSound: Joining thread
5430.706 DSound: Exit _dsound_update; tid=7636
5430.706 DSound: Waiting for voice to stop ... signaled
5430.706 DSound: Joined thread
5430.706 DSound: Destroying thread
5430.706 DSound: Thread destroyed
5430.706 DSound: Releasing buffer
5430.706 DSound: Voice stopped
5430.707 DSound: Deallocating voice
5430.707 DSound: Deallocated voice
5430.770 Steam API shutdown.
5430.772 Goodbye
kyranf commented 7 years ago

@thisismynombre can you check out the latest unstable branch please and try again? On line 52 of Squad.lua I cannot see any possible situation that the code can fail with a nil table or arithmetic so this is really strange..

thisismynombre commented 7 years ago

Same thing, that's with code I downloaded off of the unstable branch just a few minutes ago.

   0.002 2017-04-11 09:37:42; Factorio 0.14.22 (build 25342, win64, steam)
   0.002 Operating system: Windows 7 Service Pack 1
   0.002 Program arguments: "F:\Program Files (x86)\SteamLibrary\steamapps\common\Factorio\bin\x64\Factorio.exe" 
   0.002 Read data path: F:/Program Files (x86)/SteamLibrary/steamapps/common/Factorio/data
   0.002 Write data path: C:/Users/tpederson/AppData/Roaming/Factorio
   0.002 Binaries path: F:/Program Files (x86)/SteamLibrary/steamapps/common/Factorio/bin
   0.017 System info: [CPU: Intel(R) Core(TM) i7 CPU         950  @ 3.07GHz, 8 cores, RAM: 12279MB]
   0.018 Display options: [FullScreen: 1] [VSync: 1] [UIScale: 130%] [MultiSampling: OFF] [Screen: 255]
   0.019 Available display adapters: 1
   0.019  [0]: \\.\DISPLAY1 - NVIDIA GeForce GTX 1070 {0x05, [0,0], 2560x1600, 32bit, 60Hz}
   0.019 Create display on adapter 0. Size 1664x936 at position [438, 314].
   0.354 Initialised OpenGL:[0] GeForce GTX 1070/PCIe/SSE2; driver: 4.5.0 NVIDIA 378.92
   0.354     Video memory size (dedicated/total available/current available): 8192/8192/7805 MB
   0.387 DSound: Starting _dsound_update thread
   0.387 DSound: Enter _dsound_update; tid=6300
   0.387 Desktop composition is active.
   0.388 Graphics options: [Graphics quality: normal] [Video memory usage: all] [Light scale: 100%] [DXT: false]
   0.515 Loading mod core 0.0.0 (data.lua)
   0.521 Loading mod base 0.14.22 (data.lua)
   0.637 Loading mod Crafting_Speed_Research 0.1.4 (data.lua)
   0.712 Loading mod Nucular 1.0.4 (data.lua)
   0.791 Loading mod robotarmy 0.2.4 (data.lua)
   0.875 Loading mod upgrade-planner 1.2.14 (data.lua)
   0.960 Loading mod robotarmy 0.2.4 (data-updates.lua)
   1.039 Loading mod long-reach 0.0.6 (data-final-fixes.lua)
   1.126 Checksum for core: 1291735968
   1.126 Checksum for mod base: 786624017
   1.126 Checksum for mod Crafting_Speed_Research: 3928230558
   1.126 Checksum for mod long-reach: 3674062281
   1.126 Checksum for mod Nucular: 483423969
   1.126 Checksum for mod robotarmy: 1431217322
   1.126 Checksum for mod upgrade-planner: 696037660
   1.553 Info PlayerData.cpp:55: Local player-data.json available, timestamp 1491921385
   1.553 Info PlayerData.cpp:60: Cloud player-data.json available, timestamp 1480406473
   1.735 Initial atlas bitmap size is 16384
   1.755 Created atlas bitmap 16384x8724
   1.756 Created atlas bitmap 4096x1040
   1.758 Created atlas bitmap 4096x3644
   9.325 Sprites loaded
   9.325 Convert atlas 4096x1040 to: trilinear-filtering 
   9.366 Convert atlas 4096x3644 to: mipmap 
   9.501 Loading sounds...
  11.390 Custom inputs active: 0
  11.439 Factorio initialised
  15.401 Loading map C:\Users\tpederson\AppData\Roaming\Factorio\saves\1-OneMoreNewStart2.zip
  15.512 Info Scenario.cpp:152: Map version 0.14.22-0
  16.589 Checksum for script C:/Users/tpederson/AppData/Roaming/Factorio/temp/currently-playing/control.lua: 1057114497
  16.590 Checksum for script __Crafting_Speed_Research__/control.lua: 1826326919
  16.591 Checksum for script __Nucular__/control.lua: 2604603071
  16.600 Checksum for script __robotarmy__/control.lua: 3943244410
  16.602 Checksum for script __upgrade-planner__/control.lua: 2594213730
  75.501 Error MainLoop.cpp:788: Exception at tick 3371783: Error while running event on_built_entity (ID 6)
__robotarmy__/robolib/Squad.lua:52: attempt to perform arithmetic on field '?' (a table value)
kyranf commented 7 years ago

Okay I added a line before that, to try and print out what it has in the table before it gets to line 52 and has the error. It will still have the error, but can you tell me what it says just before the error? It will print a message to the game chat.

kyranf commented 7 years ago

@thisismynombre could you maybe upload your saved game as a .zip to here (as an attachment) so I can take a look at it? Can you also confirm that this is a new game, or if it's an old game that you've applied the updated files to?

thisismynombre commented 7 years ago

I'll attach the save shortly.

I created it last week, so it's new. However, I haven't tried a new save with each fix if that's what you mean.

I tried the print function above, but it crashed because it was expecting a number in that printf statement. I tried playing with it some, to get it to log or print, but I ran out of time this morning.

thisismynombre commented 7 years ago

Here's the save I've been using:

https://drive.google.com/open?id=0B7iwTPSnXJVzMGh5WlRnOEFNck0

thisismynombre commented 7 years ago

Here's a video of me trying your most recent merge with the print function:

https://goo.gl/SMAl2e

kyranf commented 7 years ago

@thisismynombre thanks, i'll load up your save and find out exactly what's going on. It seems like the global table never gets made, or my syntax which is meant to be catching and fixing that is actually causing the problem in the end.

kyranf commented 7 years ago

@thisismynombre Okay, I fixed it. I put a check in there to see if the table which was meant to be of "integer" type was actually of "table" type, and deleted/remade the entry as an integer. everything works properly now.

thisismynombre commented 7 years ago

That worked, I was able to deploy droids. I had a different crash after a bit, I'll open a new issue with the details.

Thanks for fixing that.

HoGo80 commented 5 years ago

Hi, still same problem :( In case the nearest alien hive is on island for examle, they just stop wandering / attacking and after some time just disappear. The simplest solution may be, if the simply retreat or start to wander, looking for new enemy after each turn. Btw. nice mod and very clean code with good structure, I liked it :)

kyranf commented 5 years ago

@HoGo80 yes there is some AI logic in there to give up trying to attack the ones on island and try to find others but in the end, if they are the ONLY targets in their hunting radius, then they will just keep doing the attempt and fail forever until you fix it.

The game currently deletes units which fail pathfinding, as a CPU saving measure by the developers. but obviously that is bad for my mod's users, because you guys spend a lot of resources on these bots. they aren't free like biters.

The new changes in 0.17 when it comes out will allow me to set all the units to not be deleted by the pathfinder failure, which is great. This will stop some of the issues you have. New control method for flying robots should allow them to path to, and kill, enemies on islands without path finding failure so that will come in 0.17 version of mod as well.

HoGo80 commented 5 years ago

@kyranf Great, thank you for fast reply and for effort you are making with this mod :)