I have a complex wargame already developed in a aging Objective-C and I would like to improve the AI

I have built the logic for self-play, fitness evaluation and evolution The hard-time is the ability to run a lot of experiences of self-play with limited ressources (single Mac). Time is a factor but also memory. I am facing some random crashed after a given number of games

I was wondering - if people have faced the same issues with a large number of runs with objective-C - if other people have tried to use Genetic Programming or Reinforcement Learning with Objective-C or C#

  • $\begingroup$ What is your question? Being specific will result in clear concise answers. $\endgroup$ – DuttaA Feb 24 '19 at 9:02
  • $\begingroup$ OK, I have tried to emphasized it $\endgroup$ – Carrier Battles Feb 24 '19 at 9:47

I have not touched Obj-C, but I've played with evolution in PHP, which wasn't designed for that at all. If a slow script language on my 10-year old desktop PC can do it, Obj-C should be able to handle that.

Some tricks:

  1. This is a game, so - I assume - you've disabled all the graphics. A headless program is ideal for training. Waste no CPU cycles on stuff you don't need!
  2. Use more threads/instances. Threads around the number of cores should be ideal.
  3. Watch out for memory leaks! Even languages with GC can have problems with this when used in a wrong way. But you'll need to fix these bugs anyway. You can monitor memory consumption when you run it, and if it increases more-or-less steadily, that's a problem. There are various tools against memleaks under different systems/languages, I guess Obj-C has something similar. (these tools log every allocation and release, and list everything at exit that's left)
| improve this answer | |
  • $\begingroup$ Thank you sharing your experience :-) 1) Yes, this has been done. I think I will go even farther by making it a pure console program with some scheduling to come over the repeated crash issues 2) Not sure I have control on the cores. I think the Xcode simulator has full control on it and optimizes their use. 3) Indeed, the garbage collector is not efficient at all. and the program was quickly leaking. Using manual @autorlease allow me to contain the memory usage to 1-5 Gb $\endgroup$ – Carrier Battles Mar 2 '19 at 9:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.