I have seen a lot of explanations of what Bayesian networks are, but I simply cannot wrap my head around their use in code. So here is my three part question.
- Am I right in my definition of Bayes nets? Bayesian networks are a way to (visually) portray how variables/events are linked and how they will affect each other. Probabilities can be added to each node to give you a greater sense of what will happen. In conjunction with an acting AI, Bayes nets are used to predict the AI's actions and inform what it should be doing, i.e. giving minimax a better prediction.
- Can you give a pseudo code representation of a Bayes net?
Let's get a little more specific. I have a creature simulator, the creature has a home where he sleeps and, there are patches of grass where he eats. There are other creatures out there that he wants to avoid because they will fight him. So his action -> reaction set is:
{hungry->find food -> eat food
tiered -> go to shelter -> sleep
in danger -> avoid other creature
under attack -> run to shelter}
I am trying to express this as an mdp so that it will learn what actions are best when; and what are the best spots (most prosperous & least dangerous) on the map.
How, if at all, am I supposed to use a Bayes net? If the situation requires probabilities feel free to add your own, pseudo code also appreciated.