Add tech levels to TD.
Remove super-spammy debug messages.
Reorganise AI base building logic.

- Now obeys defined structure percentages and limits.
- Faster.
- More readable and maintainable code.
Fix the bogus D2K AI definitions.
Merge pull request #5833 from pchote/cnc-techlevels

Closes #3221