Topic: Improving the AI
Tibor |
Posted at: 2019-12-04, 07:05
Is this OK?:
The second line is always referring to first position.... What about this?
Top Quote |
hessenfarmer |
Posted at: 2019-12-04, 09:07
it is partly ok. the for loop is iterating over the worker indexes in the building observer of this building type. this is the worker defined for the position in lua. the second line is evaluating the actual worker of the site working in this position. As this can be empty we need the if (cw) part.
Yes I need to replace the [0] with a counter variable. However I need to have a way to iterate over site.bo->positions as well.
this won't work as bo.positions does not have .worker I believe furthermore we need to have the actual worker here rather then the standard worker. after a short nightsleep I got the idea how to do it. I'll iterate ofer the actual positions of the site now as we can skip if a position is not manned should be more efficient. if position is manned i will compare with bo.positions.at(i) with i being the iterator variable. this should do it. If the code is working properly I'll copy it to the check_mines function as well. finally it should look like this
but I can't test this until tonight. Thanks for all the support Edited: 2019-12-04, 09:08
Top Quote |
Tibor |
Posted at: 2019-12-04, 09:28
The final code looks good to me, but back to this:
I think you first get 'cw' and immediately overwrite it in second line Top Quote |
hessenfarmer |
Posted at: 2019-12-04, 09:43
I don't know where you found this line. I always had for( auto worker : ... ) in my code. If it were like the above you would have been right of course. Top Quote |
Tibor |
Posted at: 2019-12-04, 09:49
Oh, sorry, I messed something badly, probably during copying/retyping Top Quote |
hessenfarmer |
Posted at: 2019-12-04, 09:53
No worries. will test this tonight on my atlanteans branch and if it works there I'll pull out a new branch for this, toghether with the crude statistics fix and the malus for unoccupied sites. How can I add you to the review? Are you enlisted in the git developers already? Top Quote |
Tibor |
Posted at: 2019-12-04, 09:57
I have an account on github, so you should be able to find me there. Top Quote |
hessenfarmer |
Posted at: 2019-12-04, 10:07
glad to hear that. So I will set you as the first reviewer. Await some work Top Quote |
hessenfarmer |
Posted at: 2019-12-05, 11:43
ok pull request with AI changes is up Top Quote |
hessenfarmer |
Posted at: 2019-12-05, 13:58
Damn, travis complains about code format but I don't know why as I didn't change the format. Top Quote |