5D Library › Dyadic Phase Coupling, Bilinear Compatibility Tensors and Spatiotemporal Grid Games · 中文

Chapter 6. When and Where to Act on a Turning Grid

Choosing time and direction as a decision problem

The permutations of Chapter 5 describe how the nine palaces turn, but not how a person should use them. Choosing a time and a direction can be written as a standard dynamic programme: the state is (palace, time slot); in each slot one may stay, step to a neighbouring palace, or “act” where one stands and receive that palace’s current value. Time is periodic — after a full turn the doors are back where they started — so the state space is the product of a spatial grid and a ring of time, and the optimal strategy is found by backward induction (Bellman 1957).

Calculation

The input to the model is an assumption. Following the traditional reading, the doors open, rest and life count +1, block and view 0, harm, death and fright −1, and the centre 0; each step or slot of waiting costs 0.1, and one must act within eight slots. These values are not measurements but inputs: every conclusion of this chapter rests on them.

The twelfth program compares three situations: direction and time both free; only the direction free (one must act at the first step); only the time free (one must go to a given outer palace).

Calculation

# Chapter 6. Where and when to act on a turning grid.
# The eight doors stand on the outer palaces in the ring order of p11:
#   Xiu Sheng Shang Du Jing Si Jing' Kai  (rest, life, harm, block, view,
#   death, fright, open), and turn one palace per time slot.
# By the conventional reading Kai, Xiu, Sheng are good (+1), Du and Jing
# ("view") are neutral (0), Shang, Si and Jing' ("fright") bad (-1); the
# centre counts 0. These values are an assumption fed into the model.
# A person starts in the centre at slot t0. Each slot they may stay or
# step to an orthogonal neighbour (cost 0.1 per slot), or act where they
# stand and collect that palace's current value; they must act within
# H = 8 slots. Backward induction over (cell, slot) gives the best plan,
# (a) when both direction and time are free, (b) when the direction is
# fixed (one given outer palace) and only the time is free, and (c) when
# the time is fixed (the first step) and only the direction is free.
import math

L = (4, 9, 2, 3, 5, 7, 8, 1, 6)
RING = [L.index(n) for n in (1, 8, 3, 4, 9, 2, 7, 6)]
DOOR_VALUE = [1, 1, -1, 0, 0, -1, -1, 1]   # Xiu .. Kai
H, COST, CENTRE = 8, 0.1, 4

def nbrs(c):
    r, k = divmod(c, 3)
    out = [c]
    for dr, dk in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        if 0 <= r + dr < 3 and 0 <= k + dk < 3:
            out.append((r + dr) * 3 + k + dk)
    return out

def value_at(cell, t):
    if cell == CENTRE:
        return 0.0
    return float(DOOR_VALUE[(RING.index(cell) - t) % 8])

def best(t0, allowed):
    v = {}
    for step in range(H, -1, -1):
        for c in range(9):
            act = value_at(c, t0 + step) if c in allowed else -9.0
            if step < H:
                act = max(act, max(v[(n, step + 1)] - COST
                                   for n in nbrs(c)))
            v[(c, step)] = act
    return v[(CENTRE, 0)]

if __name__ == "__main__":
    outer = [c for c in range(9) if c != CENTRE]
    free = [best(t, set(range(9))) for t in range(8)]
    fixed_dir = [best(t, {c}) for t in range(8) for c in outer]
    go_now = []
    for t in range(8):
        for c in outer:
            steps = 1 if c in nbrs(CENTRE) else 2
            go_now.append(value_at(c, t + steps) - COST * steps)
    fixed_time = [max(value_at(n, t + 1) for n in nbrs(CENTRE)
                      if n != CENTRE) - COST for t in range(8)]
    rows = (("(a) direction and time free:     ", free),
            ("(c) time fixed, direction free:  ", fixed_time),
            ("(b) direction fixed, time free:  ", fixed_dir),
            ("    same, but going at once:     ", go_now))
    for label, vals in rows:
        print("   {} mean value {:+.4f}, lowest {:+.3f}".format(
            label, math.fsum(vals) / len(vals), min(vals)))
    print("\nReading: the three good doors stand side by side, and the four")
    print("palaces next to the centre alternate around the ring, so a good")
    print("door is always one step from the centre: when the direction is")
    print("free, timing adds nothing. Timing matters only when the direction")
    print("is fixed; then waiting for a good door lifts the mean from below")
    print("zero to a clearly positive value. All of it rests on the values")
    print("put in.")
#    (a) direction and time free:      mean value +0.9000, lowest +0.900
#    (c) time fixed, direction free:   mean value +0.9000, lowest +0.900
#    (b) direction fixed, time free:   mean value +0.6625, lowest +0.300
#        same, but going at once:      mean value -0.1500, lowest -1.200
#
# Reading: the three good doors stand side by side, and the four
# palaces next to the centre alternate around the ring, so a good
# door is always one step from the centre: when the direction is
# free, timing adds nothing. Timing matters only when the direction
# is fixed; then waiting for a good door lifts the mean from below
# zero to a clearly positive value. All of it rests on the values
# put in.

The most important result is in the first two lines: with direction and time both free the mean value is 0.900; with only the direction free and action required at once, the mean is also 0.900, and the same for every starting slot. In other words, as long as the direction can be chosen, timing adds no value at all.

The reason is a combinatorial fact. The three good doors are adjacent in the ring order of the eight doors (open, rest, life); the four palaces next to the centre (Kan, Zhen, Li, Dui) alternate around the ring. Any three adjacent ring positions include at least one of the alternating positions, so wherever the doors have turned, a good door is one step from the centre.

Only when the direction is fixed — when the destination of a journey has already been decided, say — does time matter. Then setting off at once gives a mean of −0.1500, at worst −1.200; waiting for a good door to turn to that direction and then acting gives a mean of +0.6625, at worst +0.300. The value of timing comes entirely from not being able to choose the direction.

A grid game against a rival

The second problem is adversarial: A chooses a palace to act in, a rival B chooses a palace to block; when blocked A gets 0, otherwise the palace’s value. To keep values positive, good, neutral and bad doors count 3, 2 and 1, and the centre 2. This “block one cell” game is a two-person zero-sum game with a closed-form solution: B blocks only the highest-valued palaces, A mixes over them with probabilities inversely proportional to their values, and the value of the game is V=(k−1)/∑i(1/vi)V = (k-1)\big/\sum_i (1/v_i), the sum running over those kk palaces (Alpern and Gal 2003). The thirteenth program solves the game in all eight slots and checks the first slot independently by fictitious play (Brown 1951; Robinson 1951).

Calculation

# Chapter 6. A two-person game on the turning grid.
# A chooses a palace to act in; a rival B chooses a palace to block. If B
# blocks A's palace A gets 0, otherwise A gets the palace's current value
# v: good door 3, neutral 2, bad 1, centre 2 (positive values, assumed).
# For this "block one cell" game the solution is known in closed form:
# B blocks only the k best cells, A mixes over them with p_i proportional
# to 1 / v_i, and the value is V = (k - 1) / sum(1 / v_i) over those
# cells, with k the largest support for which every blocking probability
# q_i = 1 - V / v_i is non-negative. The program solves the game at all 8
# slots of the door cycle and checks slot 0 by fictitious play.
from fractions import Fraction

L = (4, 9, 2, 3, 5, 7, 8, 1, 6)
RING = [L.index(n) for n in (1, 8, 3, 4, 9, 2, 7, 6)]
DOOR = [3, 3, 1, 2, 2, 1, 1, 3]            # Xiu .. Kai, as in p12 + 2

def values(t):
    v = [2] * 9
    for i, c in enumerate(RING):
        v[c] = DOOR[(i - t) % 8]
    return v

def solve(v):
    order = sorted(range(9), key=lambda c: -v[c])
    best = None
    for k in range(2, 10):
        s = order[:k]
        val = Fraction(k - 1) / sum(Fraction(1, v[c]) for c in s)
        if all(v[c] >= val for c in s):
            best = (val, s)
    val, s = best
    z = sum(Fraction(1, v[c]) for c in s)
    p = {c: Fraction(1, v[c]) / z for c in s}
    return val, p

def fictitious(v, rounds=20000):
    ca, cb = [0] * 9, [0] * 9
    a = b = 0
    for _ in range(rounds):
        ca[a] += 1
        cb[b] += 1
        a = max(range(9), key=lambda i: v[i] * (sum(cb) - cb[i]))
        b = max(range(9), key=lambda j: ca[j] * v[j])
    na, nb = sum(ca), sum(cb)
    upper = max(v[i] * (1 - cb[i] / nb) for i in range(9))
    lower = min(sum(ca[i] * v[i] for i in range(9) if i != j) / na
                for j in range(9))
    return lower, upper

if __name__ == "__main__":
    print("   slot   value V   cells A uses (palace numbers)")
    for t in range(8):
        val, p = solve(values(t))
        cells = " ".join(str(L[c]) for c in sorted(p, key=lambda c: L[c]))
        print("     {}    {:6.4f}   {}".format(t, float(val), cells))
    lower, upper = fictitious(values(0))
    print("\n   fictitious play, slot 0, 20,000 rounds: value between"
          " {:.4f} and {:.4f}".format(lower, upper))
    val, p = solve(values(0))
    v0 = values(0)
    good = [float(p[c]) for c in p if v0[c] == 3]
    neutral = [float(p[c]) for c in p if v0[c] == 2]
    print("   exact: V = {}; A plays each good palace with {:.3f} and each"
          .format(val, good[0]))
    print("   neutral palace with {:.3f}; B blocks only good palaces"
          .format(neutral[0]))
    print("\nReading: the door cycle only permutes the values over the")
    print("palaces, so the value of the game is the same in every slot. What")
    print("changes from slot to slot is where to stand, not how much there")
    print("is to win. A plays the neutral palaces MORE often than the good")
    print("ones: a predictable 'best direction' is exactly what a rival")
    print("would block.")
#    slot   value V   cells A uses (palace numbers)
#      0    2.0000   1 4 5 6 8 9
#      1    2.0000   1 2 3 5 8 9
#      2    2.0000   2 3 4 5 7 8
#      3    2.0000   3 4 5 6 7 9
#      4    2.0000   1 2 4 5 6 9
#      5    2.0000   1 2 5 7 8 9
#      6    2.0000   2 3 5 6 7 8
#      7    2.0000   1 3 4 5 6 7
#
#    fictitious play, slot 0, 20,000 rounds: value between 1.9879 and 2.0111
#    exact: V = 2; A plays each good palace with 0.133 and each
#    neutral palace with 0.200; B blocks only good palaces
#
# Reading: the door cycle only permutes the values over the
# palaces, so the value of the game is the same in every slot. What
# changes from slot to slot is where to stand, not how much there
# is to win. A plays the neutral palaces MORE often than the good
# ones: a predictable 'best direction' is exactly what a rival
# would block.

Both conclusions run against intuition. First, the value of the game is 2 in every slot. The turning of the doors only permutes the same set of values over the palaces, and the value of the game depends only on the multiset of values, not on where they stand; what changes from slot to slot is “where to stand”, not “how much there is to win”. After 20,000 rounds fictitious play brackets the value between 1.9879 and 2.0111, in agreement with the exact solution.

Second, A uses the neutral doors more than the good ones: each neutral palace is played with 0.200 and each good palace with only 0.133, while B blocks only good palaces. A “best direction” that everyone knows is exactly the direction a rival blocks first. Against a rival, being predictable is itself a cost.

Note

What this means for an “optimal direction and timing” feature. The optimal strategies of both models in this chapter are fixed entirely by the door values put in: change the values and the optimal direction and time change with them. All the models can guarantee is that, given the values, the strategy is optimal. Whether the values correspond to anything in the world, the models can neither prove nor have they tested.

Hypothesis · not established

The author’s hypothesis (not established): in a pre-registered double-blind experiment that randomly assigns participants a “good time and direction” or a “bad time and direction” by this chapter’s rules, the two groups do not differ detectably on an outcome defined in advance (say, the rate of closing a negotiation). What would show it to be wrong: a pre-registered primary outcome on which the good group does significantly better than the bad group in two independent samples.

Summary

Written as a dynamic programme on a turning grid, choosing a time and direction is decided by a combinatorial fact: the three good doors are adjacent and the centre’s four neighbours alternate around the ring, so when the direction is free a good door is always one step away and timing adds nothing (a mean of 0.900 in both cases). Timing has value only when the direction is fixed; then waiting raises the mean from −0.1500 to +0.6625. Against a rival, the turning of the doors only permutes values, so the value of the game is the same in every slot; in equilibrium A uses the neutral doors more, because a predictable best direction is exactly what the rival blocks. Every conclusion rests on the door values put in.

References

Alpern, Steve, and Shmuel Gal. 2003. The Theory of Search Games and Rendezvous. Kluwer Academic Publishers.
Bellman, Richard. 1957. Dynamic Programming. Princeton University Press.
Brown, George W. 1951. “Iterative Solution of Games by Fictitious Play.” In Activity Analysis of Production and Allocation, edited by Tjalling C. Koopmans. Wiley.
Robinson, Julia. 1951. “An Iterative Method of Solving a Game.” Annals of Mathematics 54 (2): 296–301.

Fan, Y. (2026). Dyadic Phase Coupling, Bilinear Compatibility Tensors and Spatiotemporal Grid Games: Asymmetric Kuramoto Locking, Stopping-Time Separation Hazards and Magic-Square Permutation Operators [双人相位耦合、双线性相容张量与时空网格博弈] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090172 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).