Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Programming Cause and Effect.

Sign in to follow this  
Tutorial Doctor


So, it is sunny outside, and that makes you happy, so you go outside to play. But then, it starts raining which makes it rainy, and that causes you to be sad. So, you decide to go to sleep.

I sat down today and thought of a way to program cause and effect. I came up with this notation:(initCondtion, initState, initBehavior) + Action = (deltaState, deltaCondition,deltaBehavior) = Reaction
The initial condition is that it is sunny outside.
The initial state is that you are happy.
This causes an initial behavior-- you go outside to play.

But then, something happens (an action).

It starts to rain. Now it is rainy outside.
Now you are sad.
This causes you to go back inside and go to sleep.

The action triggers a change in state and a change in condition.
This change in state and condition produces a reaction-- You go inside to go to sleep.

PseudoExample:--Statesnormal = truehappy = falsesad = false --Conditionsclear = truerainy= falsesunny = false --Behaviors --Initial Behaviorfunction GoOutToPlay() --Change in Behaviorfunction GoToSleep() --Actionfunction Rain()start to rainend --Reactionfunction ChangeState()sad = true function ChangeCondition()rainy = true function ChangeBehavior()if sad && rainyGoToSleep()
I wonder if this is solid enough to implement. hmm.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!