some more AI code cleanup
Moderator: Committer
some more AI code cleanup
I make mistake in prev commits. But nobody notice it because it was in dead branch.
upd. Small patch with production cleanup. It does not cover lot of function, to avoid intersections.
upd. Small patch with production cleanup. It does not cover lot of function, to avoid intersections.
- Attachments
-
[The extension patch has been deactivated and can no longer be displayed.]
-
[The extension patch has been deactivated and can no longer be displayed.]
Last edited by Cjkjvfnby on Wed Feb 18, 2015 10:49 pm, edited 1 time in total.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: Automatic Ship Design for the AI
Hmm, that branch is a kind of fail-safe. Even if it currently is not exercised, I think it is prudent for it to remain. If you took it out then at the very least you'd have to add a comment warning about calling curBestMilShipRating() first, but I don't see any reason to go that route. I think we should simply correct the accidental name change (or conform the declaration and all other uses since that is the direction we want to go).Cjkjvfnby wrote:I make mistake in prev commits. But nobody notice it because it was in dead branch.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: Automatic Ship Design for the AI
AI code is real maze. Often than I try to close deadends, you suggest don't touch it, lets someone else visit it later.Dilvish wrote:Hmm, that branch is a kind of fail-safe. Even if it currently is not exercised, I think it is prudent for it to remain. If you took it out then at the very least you'd have to add a comment warning about calling curBestMilShipRating() first, but I don't see any reason to go that route. I think we should simply correct the accidental name change (or conform the declaration and all other uses since that is the direction we want to go).Cjkjvfnby wrote:I make mistake in prev commits. But nobody notice it because it was in dead branch.
shipDesign.description is broken. It should be function not property. It is you choice to remove it of fix it.
shipDesign.partsInSlotType is not used
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: some more AI code cleanup
I moved these posts to a new thread so this conversation doesn't excessively clutter Moric's thread.
I'm not sure what other times you are referring to-- I suggest we deal with this issue here and if you think there is an overall problem in approach then you can start a clear discussion of that, but don't jumble it with the decision about this particular code. I explained why I considered those lines of code to be useful, for reliability/robustness purposes, even if they are not currently visited. Your words rather strongly imply you think this is a mistake, but you don't say why. Do you consider these lines a 'maze' or too complicated? Do you think I am wrong in considering them to have value? If so, why? Do you have anything substantive to say regarding this particular situation?Cjkjvfnby wrote:AI code is real maze. Often than I try to close deadends, you suggest don't touch it, lets someone else visit it later.
Seems to be of no use to the AI, and unlikely to be of use for debugging. Any use not related to the AI is rather uncertain and distant, so I guess I'll remove it, it's trivial enough to recreate if there is a reason for it in the future.shipDesign.description is broken. It should be function not property. It is you choice to remove it of fix it.
There are a great many parts of the interface that are not currently used but nevertheless should stay. More importantly however, this seems not likely to ever be of use to the AI, or at least I can't think of a potential use. Similar reasoning as above, & it's removed.shipDesign.partsInSlotType is not used
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: some more AI code cleanup
Whole code is maze. If I want to check single small function, I need inspect couple of modules. My attention stack overflows too fast.Dilvish wrote:I moved these posts to a new thread so this conversation doesn't excessively clutter Moric's thread.
I'm not sure what other times you are referring to-- I suggest we deal with this issue here and if you think there is an overall problem in approach then you can start a clear discussion of that, but don't jumble it with the decision about this particular code. I explained why I considered those lines of code to be useful, for reliability/robustness purposes, even if they are not currently visited. Your words rather strongly imply you think this is a mistake, but you don't say why. Do you consider these lines a 'maze' or too complicated? Do you think I am wrong in considering them to have value? If so, why? Do you have anything substantive to say regarding this particular situation?Cjkjvfnby wrote:AI code is real maze. Often than I try to close deadends, you suggest don't touch it, lets someone else visit it later.
reliability/robustness purposes. Code is very reliable I am scared to touch a little piece of logic because it can fail in any place across other modules. And sometimes it is not oblivious, because when something bad happens we pretend that all is ok.
Unusable code takes time:
- It takes time for reading
- It takes time then you try to understand how system works
- It take time for support
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: some more AI code cleanup
I can sympathize-- when I first started working on the AI a framework was already in place but I only half understood it and there was no one to help explain it. I tried adding on to it in ways that made sense, and doing a little reorganization and refactoring, but not a whole lot of that. I acknowledge that my focus has been on augmenting AI capability, with less attention (some, but less) to making tha AI code as easy as possible for someone else to work with. Given that the AI is now tremendously more complex than when I started, it is probably even more difficult to dive into. I welcome the proposal you made for working on an overall reorganization of the AI code.Cjkjvfnby wrote:Whole code is maze. If I want to check single small function, I need inspect couple of modules. My attention stack overflows too fast.
This is starting to seem more like melodrama rather than an attempt at productive conversation.Code is very reliable I am scared to touch a little piece of logic because it can fail in any place across other modules.
What are you talking about?And sometimes it is not oblivious, because when something bad happens we pretend that all is ok.
Yes, yes, yes, I think you've restated this point quite a number of times now in multiple threads. I think continuing to repeat such generalities is a waste of time for everyone. Are you implicitly asserting the lines under discussion are unusable?Unusable code takes time:
- It takes time for reading
- It takes time then you try to understand how system works
- It take time for support
On a related but different point, I think there are actually a couple of unnecessary lines in curBestMilShipCost() and cur_best_mil_ship_rating() but they are different than the ones you are complaining about. I had written the initial lines
Code: Select all
if (fo.currentTurn()+1) in bestMilRatingsHistory:
bestMilRatingsHistory.clear()
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: some more AI code cleanup
I can't get the cleanup patch applied; rather large chunks get rejected and it doesn't appear to be a line-ending issue. Please try updating and remaking the patch & we'll see if it works then.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: some more AI code cleanup
Dilvish wrote:I can't get the cleanup patch applied; rather large chunks get rejected and it doesn't appear to be a line-ending issue. Please try updating and remaking the patch & we'll see if it works then.
I lunch [SVN 7944] with current trunk AI. Got some issues. Will inspect them now. In attached patch I change DEBUG -> ERROR
Melodrama Act I: "Life without designs."
Code: Select all
DEBUG AI : Error: exception triggered and caught: Traceback (most recent call last):
DEBUG AI : File "F:\projects\freeorion\FreeOrion\default\AI\ProductionAI.py", line 696, in generateProductionOrders
DEBUG AI : try: addMarkDesigns()
DEBUG AI : File "F:\projects\freeorion\FreeOrion\default\AI\ProductionAI.py", line 351, in addMarkDesigns
DEBUG AI : print "Available Hulls: %s" % ([hull for hull in empire.availableShipHulls])
DEBUG AI : AttributeError: 'empire' object has no attribute 'availableShipHulls'
- Attachments
-
[The extension patch has been deactivated and can no longer be displayed.]
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: some more AI code cleanup
Yes, the error you posted was from the example lines I put near the start of addMarkDesigns() in ProductionAI.py, for Moric's reference, you can just comment them out until your executable gets updated with the next weekly build. The sdl branch just got merged back into trunk also, though, so you'll also have a problem with an updated line in AIState.py. You could temporarily change the reference at line 800 from design.attackStats back to design.directFireStats, but of course you'll need to undo that as soon as you get the new executable. There might be other trouble as well from the mismatch between your executable and the current content, although at first glance those are the only things I see.Cjkjvfnby wrote:I lunch [SVN 7944] with current trunk AI. Got some issues.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: some more AI code cleanup
Code: Select all
r7978 | dilvish-fo | 2015-02-23 16:55:15 -0800 (Mon, 23 Feb 2015) | 1 line
AI patch by Cjkjvfnby adding chat message to player if AI triggers an exception when trying to add ship designs
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: some more AI code cleanup
Possible attribute error, there is no such method AllEmpireIDs:
https://github.com/freeorion/freeorion/ ... get.py#L75
TargetType.TARGET_EMPIRE is not used assigned, do we need it?
https://github.com/freeorion/freeorion/ ... get.py#L75
TargetType.TARGET_EMPIRE is not used assigned, do we need it?
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13603
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Re: some more AI code cleanup
The A should not be capitalized...Cjkjvfnby wrote:...there is no such method AllEmpireIDs
Code: Select all
def("allEmpireIDs", AIInterface::AllEmpireIDs, return_value_policy<return_by_value>());
Re: some more AI code cleanup
I have strong felling that this code is outdated, and can be removed. I am already remove big part of checking with TargetType.TARGET_SHIPGeoff the Medio wrote:The A should not be capitalized...Cjkjvfnby wrote:...there is no such method AllEmpireIDsCode: Select all
def("allEmpireIDs", AIInterface::AllEmpireIDs, return_value_policy<return_by_value>());
I think we can comment out this TargetType attributes:
Code: Select all
TARGET_INVALID = -1
TARGET_BUILDING = 0
TARGET_TECHNOLOGY = 1
TARGET_SHIP = 4
TARGET_EMPIRE = 6
TARGET_ALL_OTHER_EMPIRES = 7
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: some more AI code cleanup
Are you saying that you think that AIInterface::AllEmpireIDs() is outdated? If so, please clarify why you think so, otherwise please clarify what you were referring to. Or did you simply hit the "quote" button by accident instead of "reply"?Cjkjvfnby wrote:I have strong felling that this code is outdated, and can be removed.Geoff the Medio wrote:The A should not be capitalized...Cjkjvfnby wrote:...there is no such method AllEmpireIDsCode: Select all
def("allEmpireIDs", AIInterface::AllEmpireIDs, return_value_policy<return_by_value>());
It seems to me that this kind of decision fits into the "toolkit" side of our work-- we're trying to provide a toolkit from which an effective AI can be built (by ourselves or others). I could understand some reasoning that things like "empire", "all other empires" and "technology" are a substantially different class of target than fleets, systems and planets, but from that toolkit perspective what would be the reasoning for have TargetType enum for fleets, systems and planets but not including buildings and ships?I think we can comment out this TargetType attributes:...
We don't use it now, we can easily add them back then it will be really needed.
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0
Re: some more AI code cleanup
Yes.Dilvish wrote:Or did you simply hit the "quote" button by accident instead of "reply"?
May be because AI can target fleet but can't target buildings and ships? Toolkit for not implemented features look strange.Dilvish wrote:It seems to me that this kind of decision fits into the "toolkit" side of our work-- we're trying to provide a toolkit from which an effective AI can be built (by ourselves or others). I could understand some reasoning that things like "empire", "all other empires" and "technology" are a substantially different class of target than fleets, systems and planets, but from that toolkit perspective what would be the reasoning for have TargetType enum for fleets, systems and planets but not including buildings and ships?I think we can comment out this TargetType attributes:...
We don't use it now, we can easily add them back then it will be really needed.
upd.
Patch with remove checks for enum items that never set.
I comment out unused enum items.
- Attachments
-
[The extension patch has been deactivated and can no longer be displayed.]
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0