brycas

Video, Jokes, On-Line

I do videos and podcasts and marbles leagues.


brandt
@brandt
Here's a recent After Effects contraption I built to showcase statistical probabilities during a game of backgammon. I had a lot to sync, so I built controls for just about every variable and tried to automate everything I could to finish roughly in time.
A GIF of three men playing backgammon. The bottom and right side of the screen is filled with stats that update as moves are made.
stat updates like this but for 35 minutes straight
Pretty much everything has a hold keyframe on it, which means no smooth tween frames, but also I don't have to worry about momentum drifts or matching accelerations or anything. Things just hold until told to do otherwise, nice and simple.

Animated dice roll onto screen. When selected, the value of the die is controlled by an input field. When the die composition is opened up, scrubbing through frames reveals each value on a separate frame.

Keyframed Dice Rolls

This is a technique I saw ages ago somewhere and I always use it for on-screen dice. This is also how I made selectable card suits in my previous what cards are they holding? tracker post. You start with a composition where every frame shows a different die value, then you drag that composition into your main composition. Now remap time on the die comp and make a slider control for your input. Use an expression to hook the time remap to the slider and because it reads time in milliseconds, we'll convert your input from frames to milli to make it more useable (in this case I'm running at 23.976fps, so 1 / 23.976 * slider value). Time values that land between keyframes will blend your die frames so you should either hold the keyframes or round to an integer.

Now you can just enter a number and the dice will show that number. Pretty neat!

A selected checker has two number input fields which control where it lands on the board. A checkbox disappears the checker when selected. The expression controlling its position is 17 lines of code.

Checker Grid

I mathed out a grid for the checkers to align with so that I can just give it a point and a number of checkers deep into that point and it'll drop the checker in the right place. Okay, this one might have been faster and more visually organic to just drag the checker where I want it, but I had grids on the mind at the time. Also with this method, if someone moves a checker 5 points, you can just enter "+5" into the point input field and you don't even need to look at the board, so it has its advantages.

I also have a checkbox rigged into the opacity so that when a player scores a point the checker can be fully removed from the board without any fuss. This had the unfortunate byproduct of stacking assets on each player's home board, because that's where they all end up before being removed, so I generally pushed the checkers up a bit or locked the layer so I couldn't select it again accidentally.

One layer's effect controls shows some 15 different stat properties that manipulate various stats shown on the overlay.

Control Panel

This is my primary control layer where I've built out a controller property for basically every variable that changes on screen, with a couple exceptions. This way, when a new move is made I can consult GNU Backgammon (where I got all of my stats from), click on one layer and just run down the list.

For the first half of the edit, I had all of these controllers on the layers they controlled, but centralizing them all into one layer made my life a lot easier.

An equity input field updates a number next to a notated move. When the equity changes, a box beneath automatically indicates whether the move is good or bad.

Equity Grading

So this value isn't a measure of true equity, it's equity relative to the best possible move you can make. I chose that because I think it's easier for new players to appreciate, even though it doesn't tell the full story. So because this is relative equity, that means all of these values will always be negative and typically on a scale from 0 to -1.

So I made the input field to automatically convert an integer to be the thousandths place, which allows me to use my numpad to just quickly enter the numbers I see instead of having to format it each time. Saves me a couple of key presses for every equity update, and more importantly, smooths out the process so I have more energy to edit. Give me one less thing to worry about.

It also automatically color codes the number based on GNU Backgammon's default equity ratings. I never would have had the time to do this manually, so it's nice that after setting this up I never had to think about it ever again.

The move rating just above "#14 of 14" also automatically updates text and background color based on the equity of the player's selected move at any given time. No keyframes on that bad boy, just some good ol' expression work.


As the total moves input field is updated, so is a box listing possible moves in the overlay. Changing the chosen move parameter highlights the corresponding box and changes the move quality box.

Dynamic Move List

When a player's move starts, I first update the total number of possible moves. If it's less than 6, the move list hides the unneeded moves, if it's more than 6, a table break appears automatically. The move notations have to be manually updated, it's just a text layer, but it's alpha matted to the object layers behind them so that when those disappear, so do the moves associated with them.

When a player makes a move (whether they stick with it or are just sketching out ideas), I match the "chosen move" property with that player's move as seen in the move list. Each move box is rigged to read this chosen move, and if they match, the background highlights purple. The move quality box relies on this property to know which equity to look at to grade the player. If the chosen move is greater than 5 but less than the number of total moves, a second table break is added.


I think that's the bulk of it. Thanks for reading! I got really into backgammon for a couple weeks while working on this one, it's a cool game! If you want to watch the whole video in context, you can find that here:


You must log in to comment.