Can a thesis not answer the research question and still be good? I have written a thesis about applying some AI techniques to a simulation that my professor introduced. To make this happen, I had to implement a very large amount of software, because the simulation works in another language, follows different principles etc.

After 6 months of hard work, I did not reach my goal. I was not able to actually implement the AI technique I wished to apply to the problem. I created a lot of reusable components that future developers (and in fact other students as I was told) will want to use. But the actual question and also the title of the thesis (which both had to be fixed ahead of time and cannot be changed once it has been started) don't match the main body of my work. 

Can a thesis still be considered good even if the question was not answered because it was not "reached"? If not, why? If yes, why? I can imagine this going either way but I'd like to hear opinions and experiences.

Basically I would require another 1-2 months and maybe someone to work on the problem as a team to get new ideas. I believe I still worked in a scientific manor (I prioritized reusability and usefullness over just reaching the question but without it being easily reusable) and no one ever said science is only good if it never misses a deadline. But I can also imagine an argument that simply states an unanswered research question is a bad work. 

My original intention was to apply this AI technique to the common example research problems (like Atari games or locomotion) but my professor insisted I apply it to his field of work (energy market simulation). I had to agree if I wanted him to take my thesis and I didn't know how complex the mapping of his problem to the commonly used tools would be. The argument "a good researcher is also capable of creating a reasonable problem scope" therefore is a little unfair as he sort of forced me to extend it.

Alternative B I write a preface / authors comment at the beginning, stating that the title/research question won't be matched but due to university regulations may not be changed retrospectively. 

Alternative C: A fellow researcher recommended me to just change the question and content but ignore the title. I hand in my thesis under the forced title but publish it under a more suitable title. That seems a little "fake" as I don't want to lie about my original goal and me missing the final goal.



Edit: Most suggestions go along the lines of "depends on your professor or institution". While I fear this is probably the only right answer that helps me personally, it doesn't seem right that it depends on the professors attitude or personal opinion. From an abstract perspective, is it OK to rate a scientific work as a bad work if it fails to reach a previously defined target when new information came to light along the way? Probably not. But is it common practice to change the research question at the end to better match / suit the line of argumentation? It seems to me the question should reflect what the researcher asked him/herself when he/she started the inquiry. If the results are not what was expected, that doesn't mean it's bad results.
The short answer to your question is yes, you can have a good result even if you don't (completely) answer the original question. However, the advice you really need is from your professor. Don't express negative feelings about how he "forced" you or anything like that. Ask him for his analysis of your work and how to best position it. 

Many research questions take a long time to resolve. Don't be discouraged by that. 

But the work isn't a failure, and you, especially, shouldn't think of it that way. You want to ask yourself, however, "What, exactly, did I demonstrate in this work". Your wording of the rest should revolve around answering that question and showing how you did a good job of it. 

You can have a final section that discusses how this work is part of a larger work and briefly describe the problem you started out to solve. 

However, some of your statements confuse me. You seem to be saying that at some earlier point you gave a title to the university that makes a claim of success to the earlier question, and that that can't be revised. Such a policy would surprise me and I would make doubly certain that you are correct. But advice from your professor would also be valuable here. 

When it comes time to publish your work, there is no rule anywhere that I know of that restricts you in the title of the paper(s) that get produced. So even if you are sort of "stuck" with an inappropriate title, you can just treat it long term as an anomaly. You then have a little joke you can share with future students if you stay in academia.