FreeOrion

Forums for the FreeOrion project
It is currently Tue Dec 12, 2017 4:38 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri Jan 22, 2016 5:33 pm 
Offline
Space Floater

Joined: Tue Dec 15, 2015 6:20 pm
Posts: 47
Location: Solaria
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

_________________
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)


Top
 Profile  
 
PostPosted: Fri Jan 22, 2016 8:05 pm 
Offline
AI Contributor

Joined: Tue Feb 17, 2015 11:54 am
Posts: 224
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).

Quote:
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 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.

_________________
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0


Top
 Profile  
 
PostPosted: Fri Jan 22, 2016 9:40 pm 
Offline
Space Floater

Joined: Tue Dec 15, 2015 6:20 pm
Posts: 47
Location: Solaria
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).


to generate the timing graphs I did something like this:
enable timers:
Code:
cat <<EOF >> default/AI/default_config.ini
[Timers]
timers_to_log = True
timers_dump = True
timers_dump_folder = /tmp/timers/

[main]
handlers =

EOF

call freeorion in a loop to create data
Code:
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


the vistime.py.log attachment created the images for the two different runs with and without the PR
Attachment:
without_patch.png
without_patch.png [ 93.64 KiB | Viewed 466 times ]

Attachment:
with_patch.png
with_patch.png [ 123.16 KiB | Viewed 466 times ]


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.

About that: from time to time i get:
Code:
[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'

Any clue/hints on that?

edit: missing closing qute


Attachments:
File comment: pythoncode - remove ".log" extension
vistime.py.log [1.56 KiB]
Downloaded 25 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)
Top
 Profile  
 
PostPosted: Sat Jan 23, 2016 9:25 am 
Offline
AI Contributor
User avatar

Joined: Tue Jun 24, 2014 9:55 pm
Posts: 444
banduri wrote:
to generate the timing graphs I did something like this:

You can create config in separate file and run it with `--ai-config <path>`

Quote:
Any clue/hints on that?

Looks like wired bug. Do you have log for this case?

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group