• Post Reply Bookmark Topic Watch Topic
  • New Topic

Rule implementation  RSS feed

Richard Torkington
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am currently "trying" to write a program, but I have writer's block over one major section of it.
Basically, im trying to pass objects through a rules engine (for want of a better word, not a true rules engine in the comp sci sense) which determines what action to take based on what attributes the object has.

Think like baseball; I pass a player object with an action the player wants to do, ie the guy who pitches for the team has the pitch skill and so has more chance of successfully pitching a good 'un.
So a pitcher would have a dice roll needed a 3 or more to pitch successfully, and everyone else needs 4 or more when he/she did the pitch action.
The spanner in the works is such: i want 2 or more sets of rules, for example windy rules (the weather is windy) which affects the pitch dice roll and has to make another dice roll or something (losing the analogy ).

I thought that I would have a state class for holding all the different information active in the program, like positions, score, and who's turn. I would then have a base rules class with the stuff that happens if no extra special skills are involved. Also needed would be the extended rules class with stuff like good batting skill, pitch skill etc for each rules version. Then I would need the "rules engine" bit, which determines the route through the rules that the player will take.

I was thinking using a state engine, since the baseball "pitch" would be that, and using a factory design pattern to gurgitate the changeable routes through the different rules methods as classes that the player object gets passed to.

The crux of my question is is there a better or simpler way to do this? And am I using the patterns correctly or are there better ones you could suggest? I'm sure that others may have come across something like this before, but Im bad at searching for it as Im unsure what to call the problem since rules engine means something slightly different.

Thanks for you time reading the gobble-de-gook

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!