# How to represent this in a chart or table?

Haven’t been around in a while – gotta renew my paid membership once I get not-busy enough to have a bit of time to breathe.

But I’m stuck on something, and I can’t figure out how best to present this type of information, so here goes:

Let’s say you have a state machine where a primary action will always be one of 8 actions, and a secondary action will also be one of 8 actions, but the behaviour of these secondary actions will depend on the primary action. It’s a very simple “If action A, then action B, do C; if action A, then action C, do D,” etc.

The question is, is it possible to represent this in a table or chart in the most efficient manner without listing out all 64 possible outcomes consecutively?

What do you mean by “without listing the 64 options consecutively?” Surely the outcomes have to be explicitly stated - isn’t that the information you’re trying to get across?

I agree with Blue Mood. If you have 64 target states, you are going to have to show 64 target states.

I would use a state transition diagram, unless you are going to the use a table to create table-driven code.

Well, yes, I do need to state all 64 possible states, I was just hoping to avoid making a 64-line list of each possible state and maybe instead graph it somehow into a more elegant and easily-followed format. I could just list them one-by-one but it seems a bit like describing a game by reading its source code. You can do it, you just have to assemble it in your head before it makes any sense. I was hoping there was maybe a cleaner way to present that data.

Are you trying to display what happens, or program it? For the display, it might make sense to do an 8 x 8 table, with primary actions on the left, secondary actions on top, and each cell describing what happens.

State transition diagram is the way to go. Also quickly shows if there is more than one path to a given end state.

I second this if the actions are straightforward as you say. Otherwise one of the diagrams CookingWithGas showed.

Hmm. Those are possibilities. But any given secondary state may turn into a number of different outcomes

To describe what it is I’m trying to do, I’m creating a model for a virtual touchscreen joystick that is intended to simulate the physical actions a player takes in moving the joystick, which differs from a basic joystick that has a neutral state and 8 absolute directions. For example, say a player pushes right on the joystick. That sets a primary state of moving right. Now, when a player physically moves a real joystick to the up-right diagonal position, they don’t push up-right, they push up because the joystick is already in the state of being pushed to the right. If they were playing a game where up-right executed a jump move on the screen then this makes sense. But what if it was an omni-directional scrolling game – say, an overhead-view soccer game. You could use the same system, but if the user wanted to move up instead of up-right after having been moving right, they’d have to push up-left to go straight up – but not so far up-left that they make the stick go to the up-left diagonal position, which is both counter-intuitive and fiddly.

So you can see the dilemma. My solution therefore is to set up a state machine that can be fed profiles that changes the behaviour of secondary movement states based on the context of the game being played. For a platform game where up-right is jump, I feed it a “platform” profile that treates a right->up sequence as a move to up-right. But for that overhead soccer game, I feed it an “omnidirectional” profile which treats movement in any direction as an absolute, with no secondary state at all.

So basically, I need to be able to diagram what happens during a secondary state when the stick is moved in any other direction, and I’d need to do this for each profile I create. If I were to list it out, it would probably look something like this:

• R + (U or UR) = UR
• R + (D or DR) = DR
• R + L = L
• R + UL = UL
• R + DL = DL
• U + (R or UR) = R
• U + (L or UL) = L
• U + D = D

And so on. (This would describe a platform profile).

With 8 possible actions you’ll need to go with a rotationally symmetric layout to avoid incomprehensible clutter; likely also color coding of similar actions on different starting states.

Take a look at Graphviz.

Are you looking to display this data on paper? or on-screen? or a web-page? Basically the question is static media vs dynamic media. If dynamic it’d be rather simple to display only current state and list of 8 possible actions at any point, and update when a choice is made.

Static, I’d second untrafilter’s 2-axis table - very clean, easy to find target state and easier to ignore all other states.