AI doesn't move at all
Moderator: Oberlus
Forum rules
Always mention the exact version of FreeOrion you are testing.
When reporting an issue regarding the AI, if possible provide the relevant AI log file and a save game file that demonstrates the issue.
Always mention the exact version of FreeOrion you are testing.
When reporting an issue regarding the AI, if possible provide the relevant AI log file and a save game file that demonstrates the issue.
AI doesn't move at all
Recently built 0.4.4 (r7696) to have another go at FO but was dissappointed when the AI never moved any ships (or took any actions at all it would seem) on any of my games. The AI was tried on Maniacal, Aggressive and Typical. What further debug information is needed? Running on Fedora built with libraries from the repos.
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: AI doesn't move at all
AI and server log files to start. Start a new game, play one turn, located and attach the logs to a post.gvdm wrote:What further debug information is needed?
Re: AI doesn't move at all
please attach one of the AI log files (such as AI_1.log) found in the same directory as config.xml
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: AI doesn't move at all
Attached
- Attachments
-
- freeorion.log
- (341.11 KiB) Downloaded 103 times
-
- freeoriond.log
- (260.74 KiB) Downloaded 105 times
-
- AI_1.log
- (49.62 KiB) Downloaded 114 times
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: AI doesn't move at all
Is default/AI/timing.py present? Does it contain a definition for Timer?
Does anything change if you delete all the .pyc files that are generated? I'm not sure where these would be on Linux... possibly the same directory as the .py files?
Does anything change if you delete all the .pyc files that are generated? I'm not sure where these would be on Linux... possibly the same directory as the .py files?
Re: AI doesn't move at all
yes, the AI log makes it very clear what the problem was -- it wasn't able to do one of its imports. I would guess that you may for some reason be missing the default/AI/timer.py file. How did you install/update this installation of FO? Attached is a copy of the timer.py file that should probably work for you (unzip and drop into the default/AI/ folder of your freeorion installation).
If there is still any trouble, please attach a new AI logfile.
If there is still any trouble, please attach a new AI logfile.
- Attachments
-
- timing.py.zip
- (1.19 KiB) Downloaded 93 times
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: AI doesn't move at all
Yep, I came across it as well.
At the beginning I see:
2014-09-07 16:22:22,518 ERROR AI : File "freeorion-code/FreeOrion/default/AI/InvasionAI.py", line 14, in <module>
2014-09-07 16:22:22,519 ERROR AI : from timing import Timer
2014-09-07 16:22:22,520 ERROR AI : ImportError: cannot import name Timer
and later I see AttributeError: 'NoneType' object has no attribute 'generateOrders' and similar for many.
I installed FO via SVN, checked it out, I've also run svn update default/AI/timer.py which did not download it. I do see a timing.py but not a timer.py, timing.py does include the Timer class but I don't know why it isn't imported/found. Something to do with the Python path for libraries maybe?
Nothing changes if all the .pyc files are deleted.
At the beginning I see:
2014-09-07 16:22:22,518 ERROR AI : File "freeorion-code/FreeOrion/default/AI/InvasionAI.py", line 14, in <module>
2014-09-07 16:22:22,519 ERROR AI : from timing import Timer
2014-09-07 16:22:22,520 ERROR AI : ImportError: cannot import name Timer
and later I see AttributeError: 'NoneType' object has no attribute 'generateOrders' and similar for many.
I installed FO via SVN, checked it out, I've also run svn update default/AI/timer.py which did not download it. I do see a timing.py but not a timer.py, timing.py does include the Timer class but I don't know why it isn't imported/found. Something to do with the Python path for libraries maybe?
Nothing changes if all the .pyc files are deleted.
Re: AI doesn't move at all
right, the file is timing.pygvdm wrote:I installed FO via SVN, checked it out, I've also run svn update default/AI/timer.py which did not download it. I do see a timing.py but not a timer.py,
the python path looks fine, and I don't see how a problem with it would lead to this particular problem (other local imports are apparently working fine).timing.py does include the Timer class but I don't know why it isn't imported/found. Something to do with the Python path for libraries maybe?
It looks like default/AI/__init__.py is no longer in the repository -- I'll try to track down what happened, and fix it in svn. If you don't have one in your default/AI folder, then just create a blank one such as with
Code: Select all
touch default/AI/__init__.py
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: AI doesn't move at all
No joy with __init__.py - AI is still bricked.It looks like default/AI/__init__.py is no longer in the repository -- I'll try to track down what happened, and fix it in svn. If you don't have one in your default/AI folder, then just create a blank one such as withand see if that fixes thingsCode: Select all
touch default/AI/__init__.py
Any idea why
Code: Select all
from tools import dict_from_map, tech_is_complete
Code: Select all
from timing import Timer
Also, is default/AI/InvasionAI.py one of the first or first files to run? Is it the first to try importing Timer? My thinking is to narrow down whether it is a generic issue (just happens to crop up here because it runs first) or an issue with InvasionAI (other places import Timer fine before that) or with Timer (this is the first place to try importing Timer).
Re: AI doesn't move at all
Ah, yeah, I guess it's not needed here because of how the first of these modules gets loaded into python. For some reason in one of my installations there was a /default/AI/__init__.py (but not added to SVN), is what threw me off.gvdm wrote:No joy with __init__.py - AI is still bricked.
not yetAny idea whyin default/AI/InvasionAI.py is fine butCode: Select all
from tools import dict_from_map, tech_is_complete
is not?Code: Select all
from timing import Timer
'No' to the first question, and it looks like 'Yes' to the second. FreeOrionAI.py is the first to be loaded, and although it also includes an import of both InvasionAI and Timer, the import chain first reaches InvasionAI somewhat indirectly vi aAIstate etc. (you can see the full listing of files in as part of the error log in the AI log file).Also, is default/AI/InvasionAI.py one of the first or first files to run? Is it the first to try importing Timer?
To explore import sequence issue slightly you could edit FreeOrionAI.py to move line 24 ("from timing import Timer") up to just before line 11 (import AIstate) -- that causes no problem on my system but on yours it may cause the import trouble to be triggered immediately at that point rather than waiting for InvasionAI. (but before you try that check status as mentioned below)
The thing is, this seems to be only a problem for you, not anyone else. if you doMy thinking is to narrow down whether it is a generic issue (just happens to crop up here because it runs first) or an issue with InvasionAI (other places import Timer fine before that) or with Timer (this is the first place to try importing Timer).
Code: Select all
svn status default/AI/
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: AI doesn't move at all
The svn status just shows I added __init__.py and edited FreeOrionAI.py to make below happen, otherwise, it is exactly as SVN repo.
Making FreeOrionAI.py import Timer first makes it throw the error first:
So, I'm stumped. Seems kinda strange that it is only Timer that has the issue (other stuff in same fir works fine).
Making FreeOrionAI.py import Timer first makes it throw the error first:
Code: Select all
2014-09-07 20:52:51,940 ERROR AI : Traceback (most recent call last):
2014-09-07 20:52:51,940 ERROR AI : File "freeorion-code/FreeOrion/default/AI/FreeOrionAI.py", line 11, in <module>
2014-09-07 20:52:51,940 ERROR AI : from timing import Timer
Re: AI doesn't move at all
and then that part you quoted is followed by the same "ImportError: cannot import name Timer"?
one thing that might add a small bit of clarity is to change the manner of import -- instead of
perhaps try
It might possibly give a more informative error message when trying "import timer"
It would be nice to figure this out, but also in the meantime, if you want to just play some, the timer is not actually critical -- in InvasionAI.py you could simply comment out the Timer import and all the lines involving "invasion_timer", and do something similar in the other files that import Timer
one thing that might add a small bit of clarity is to change the manner of import -- instead of
Code: Select all
from timing import Timer
Code: Select all
import timing
Timer = timing.Timer
It would be nice to figure this out, but also in the meantime, if you want to just play some, the timer is not actually critical -- in InvasionAI.py you could simply comment out the Timer import and all the lines involving "invasion_timer", and do something similar in the other files that import Timer
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: AI doesn't move at all
A little more interesting, I replaced all occurences of
with
as suggested and this results in
Any clues forthcoming?
Code: Select all
from timing import Timer
Code: Select all
import timing
Timer = timing.Timer
Code: Select all
2014-09-07 22:39:36,989 ERROR AI : File "freeorion-code/FreeOrion/default/AI/InvasionAI.py", line 16, in <module>
2014-09-07 22:39:36,989 ERROR AI : Timer = timing.Timer
2014-09-07 22:39:36,990 ERROR AI : AttributeError: 'module' object has no attribute 'Timer'
Re: AI doesn't move at all
well it does seem to get us a little closer. to get some more info please try this: edit timing.py to comment out the line "import freeOrionAIInterface as fo" (just add a '#' at the start of the line). Then at the command line cd to default/AI and then run python, then "import timing" and then "help(timing)" and paste the results here.gvdm wrote:Any clues forthcoming?
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: AI doesn't move at all
As follows:
Code: Select all
Help on module timing:
NAME
timing
FILE
/home/gvdm/freeorion-code/FreeOrion/default/AI/timing.py
CLASSES
__builtin__.object
Timer
class Timer(__builtin__.object)
| Methods defined here:
|
| __init__(self, timer_name, write_log=False)
| Creates timer. Timer name is name that will be in logs header and part of filename if write_log=True
| If write_log true and timers logging enabled (DUMP_TO_FILE=True) save timer info to file.
|
| end(self)
| Stop timer, output result, clear checks.
| If dumping to file, if headers are not match to prev, new header line will be added.
|
| start(self, section_name)
| Stop prev timer if present and starts new.
|
| stop(self, section_name='')
| Stop timer if running. Specify section_name if want to override its name.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
FUNCTIONS
make_header(*args)
time(...)
time() -> floating point number
Return the current time in seconds since the Epoch.
Fractions of a second may be present if the system clock provides them.
DATA
DUMP_TO_FILE = False
TIMERS_DIR = 'timers'