I had some fun with the AI. Did some profiling to figure out which part of the AI is slow. I think the _get_design_by_name in ShipDesignAI could be a little bit faster, if invalid designs are also cached. The Pullrequest https://github.com/freeorion/freeorion/pull/453 does that. It stores invalid designs in cache to increase cache hits. After a new design is created via issueCreateShipDesignOrder the cache gets updated. At the begining of each turn, durring the cache_consistency_check, invalid ship designs are removed from the cache.
I did some testing with a single AI and looked at the timers but I'm not sure about the changes since I'm not that familiar with the overall design of the AI. I would like to know whether I did something really bad
edit: removed quote-tags
[PR 453] aggressiv cache for _get_design_by_name (AI)
Moderator: Committer
[PR 453] aggressiv cache for _get_design_by_name (AI)
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project (this includes pullrequest of the useraccount banduri at github)
Re: [PR 453] aggressiv cache for _get_design_by_name (AI)
That seems like a good approach overall (for code discussion, see PR). Do you have any numbers concerning how often the cache was missed (There is some profiling information for ShipDesignAI included in the AI logs).
If you break the AI, you will notice it by ingame error chat messages and/or by errors in the logs. So if you do something "really bad" you will usually know.I did some testing with a single AI and looked at the timers but I'm not sure about the changes since I'm not that familiar with the overall design of the AI. I would like to know whether I did something really bad
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: [PR 453] aggressiv cache for _get_design_by_name (AI)
to generate the timing graphs I did something like this:Morlic wrote:That seems like a good approach overall (for code discussion, see PR). Do you have any numbers concerning how often the cache was missed (There is some profiling information for ShipDesignAI included in the AI logs).
enable timers:
Code: Select all
cat <<EOF >> default/AI/default_config.ini
[Timers]
timers_to_log = True
timers_dump = True
timers_dump_folder = /tmp/timers/
[main]
handlers =
EOF
Code: Select all
mkdir /tmp/timers /tmp/data; for i in $(seq 0 9);do ./freeorion -q -r --GameSetup.ai-players 1 --max-fps 15 --max-fps-no_focus 15 --auto-advance-n-turns 400 --auto-quit; cp ~/.freeorion/*.log /tmp/timers; mv /tmp/timers /tmp/data/timers_${i}; mkdir /tmp/timers;done
About that: from time to time i get:Morlic wrote:If you break the AI, you will notice it by ingame error chat messages and/or by errors in the logs. So if you do something "really bad" you will usually know.
Code: Select all
[debug] AI : Chat Message to human: AI_Error: AI script error in "survey_universe": "'NoneType' object has no attribute 'tags'"
[debug] AI :
[error] AI : PythonLoggingWrapper.cpp:41 : Traceback (most recent call last):
[error] AI : PythonLoggingWrapper.cpp:41 : File "/home/asklepios/GITs/freeorion_build/default/AI/FreeOrionAI.py", line 239, in generateOrders
[error] AI : PythonLoggingWrapper.cpp:41 : action()
[error] AI : PythonLoggingWrapper.cpp:41 : File "/home/asklepios/GITs/freeorion_build/default/AI/ColonisationAI.py", line 421, in survey_universe
[error] AI : PythonLoggingWrapper.cpp:41 : for metab in [tag for tag in this_spec.tags if tag in AIDependencies.metabolismBoostMap]:
[error] AI : PythonLoggingWrapper.cpp:41 : AttributeError: 'NoneType' object has no attribute 'tags'
edit: missing closing qute
- Attachments
-
- vistime.py.log
- pythoncode - remove ".log" extension
- (1.56 KiB) Downloaded 109 times
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project (this includes pullrequest of the useraccount banduri at github)
Re: [PR 453] aggressiv cache for _get_design_by_name (AI)
You can create config in separate file and run it with `--ai-config <path>`banduri wrote: to generate the timing graphs I did something like this:
Looks like wired bug. Do you have log for this case?Any clue/hints on that?
May be planet destroyed but it is still return owner and population?
PS. You can share python files via https://gist.github.com/
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0