This is a basic bayesian network. This code is very dirty. Therefore, I have replaced the open bayesian network.