Ai BFS part II

This PR extends branch AI BFS PART I version ii,
by cherry-picking this merge-commit into master:

https://github.com/wesnoth/wesnoth/commit/e038938a730c3e7f14d9e3ecb4c5b4ad1cc90aac