Reputation: 2569
I have to implement a questionnaire engine, where each answer to a single question can end up in a completely different result.
So, if we have 10 question with 10 answers each, we'd have a 10 to the power of 10 possibilities.
This should be something like a scripted-AI i guess...
So, what kind of rule engine or implementation method would I use for a problem like this?
I guess this kind of algorithm is a little bit too straightforward?
if (x==1)
if (y==1)
{
if (z==1 || z==2)
// do sth
if (z==3)
// do sth different
}
Thanks for any advice on this.
Upvotes: 2
Views: 452
Reputation: 564631
There are libraries that can be used to implement this form of "rules engine".
For example, Windows Workflow Foundation allows basic rules to be determined via FlowDecision activities and other related classes.
Other alternatives are rules engines, such as Drools.Net.
That being said, for simple routines like above, I'd recommend trying to refactor your algorithm to avoid lots of criteria. By pushing this into multiple methods, you could create a series of clean conditions that would be much simpler to follow.
Upvotes: 4