[Introduction task] AI: improve spy steal tech selection

Do you want to help out with Freeciv development? Then check out this forum.
sveinung
Elite
Posts: 427
Joined: Wed Feb 20, 2013 4:50 pm

[Introduction task] AI: improve spy steal tech selection

Postby sveinung » Tue Jan 27, 2015 10:06 pm

I think this may be a good introduction patch for a developer that is new to the Freeciv AI code. I hereby offer to give feed back on your patch, and when (/if) it becomes good enough, add it to Freeciv.

Skills you must learn/have to do this:
  • Changing a rule set (for testing)
  • Running auto games or playing Freeciv (for test games)
  • Compiling the Freeciv source code
  • Getting the Freeciv 3.0 (and 2.6) source code from SVN
  • C coding
  • Creating a patch

Background
In Freeciv 2.6 it will be possible to give a unit the ability to steal a specified tech without giving it the ability to steal a random tech. When a spy decides to steal a tech it will currently choose to steal a random tech ("Steal Tech") if that is legal. This improves the probability of success. If stealing a random tech is forbidden it will try to steal the first tech it finds using "Targeted Steal Tech". In the bundled rulesets "Steal Tech" is always legal when "Targeted Steal Tech" is.

Hints
The choice of what tech to steal is done the function choose_tech_to_steal() in ai/default/aidiplomat.c. The code that always choose to steal a random tech is located in the function dai_diplomat_city(), also located in ai/default/aidiplomat.c.

The task
The way choose_tech_to_steal() chooses target tech should be improved. A simple way of doing it is to go for the most expensive tech. A more complex solution would consider how much the AI wants each tech. (AI want)

If you are extremely confident about the way you select target tech you can also modify dai_diplomat_city() to go for "Targeted Steal Tech" in some cases where "Steal Tech" is legal. (That would be best to do in a follow up patch)

When your patch is ready for review attach it to patch #5767.