EPC Event-driven Process Chain

posted in Event-driven engine for project Hangman
Published August 13, 2021
Advertisement

EPC Event-driven Process Chain is a flowchart for business process modelling. It is similar to BPMN Business Process Model Notation.

“An Event-driven process chain (EPC) is an ordered graph of events and functions. It provides various connectors that allow alternative and parallel execution of processes. Furthermore it is specified by the usages of logical operators, such as OR, AND, and XOR. A major strength of EPC is claimed to be its simplicity and easy-to-understand notation. This makes EPC a widely acceptable technique to denote business processes.”

In our case, the business process is the game logic. The last part that we want to extract from our code.

The main elements that I use for the flowcharts are the following:

  • Event → It represents something that has already happened. It can be just a String "<noun> <past verb>" like "door closed", "enemy detected", “bullet collided”, … Or you can use IDs or enums…
  • Function → It represents an action, a function or method of our code, it matches a part of our code. “<Verb> <noun>” like “Turn light on”, “Increase player damage”, “Reduce attempts”, …
  • Logical Connectors → They are arrows that link the other elements.
  • Logical Relationships → XOR, OR, AND.
  • Data → It represents input/output data.

Let's see some examples.

“When player enters the room, turn the light on”

“When play starts, select a random word”

For me it is easier to follow always the pattern Event-Action-Event. But it can be Event-Action-Action-Action-…-Event. Unreal BluePrints let you do that.
You can always use dummy events (hidden to the designer). In order to use the simple pattern.

Event-Action-DymmyEvent0-Action-DymmyEvent1-Action-DymmyEvent2-…-Event

Back to the last example, what happens with the information?


The function “selectRandomWord” needs a word category as input and it selects a word as output.
You can see that the flow of the event-action is different from the data flow.

The answer is that there is no standard to store the data that is interchanged between the functions.
All the methods I mentioned for eliminating the Magic Numbers are valid.
In my case, I store the data in plain text files that are used to create the components. So the game use components to share data between functions.
I will extend the event to include data (components) as result of the previous function. That way the data flows in the same way as the event/functions.

public class Event {
	private String EventName;	
	public final long timestamp;
	private Data data;
}

Let's see some examples with the logical relationships.

“When key is checked, update the Lifes image”
“When key is checked, update the TextBox content”
“When key is checked, update the Logic state”

We use the AND relationship to create multiple branches of execution.

“When key is checked, update the Logic-state"
“When time is over, update the Logic-state”

We use the OR relationship, because either condition activates the function.

“If state is WIN, display animationWIN”
“If state is LOST, display animationLOST”
“If state is RUNNING, read key”

Only one of the actions will be executed, they are mutually exclusive

Almost all the combinations are possible.
You can check them in this document
https://www.posccaesar.org/svn/pub/SemanticDays/2009/Tutoruals_Enterprise_architecture_frameworks_No_3.pdf

Depending on your implementation, you will need only some of them.

In my case, I use only the pattern Event-Action-Event, so I don't use relationships except this one Function→XOR→Multiple events.
Even if you see AND and OR in the diagram, they don't exist in my implementation.
The game loop is just a generic event managing system. Valid for all the games.
It needs an EPC flowchart, an Entity List and an initial event “game started”.

This was the first draft of the hangman mini-game using events (EPC).

Next Entry Release 0.2.1
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement