Skip to Content
AlgorithmsAlgorithms
  • Article
  • Open Access

10 May 2026

23 Pages

GRU Learning of Asymmetric Sequence Structure in Penney’s Game

and
1
School of Artificial Intelligence, Anhui University, Hefei 230601, China
2
Institute of Artificial Intelligence, Hefei Comprehensive National Science Center, Hefei 230026, China
3
National Key Laboratory of Human–Machine Hybrid Augmented Intelligence, Xi’an Jiaotong University, Xi’an 710049, China
*
Author to whom correspondence should be addressed.

Abstract

Alternation preference in random-sequence judgments has been linked to objective differences in pattern waiting times. The present study asks whether recurrent networks can learn such temporal asymmetries beyond single-pattern regularities and capture the more complex competitive structure of Penney’s game. To address this question, we adopt Penney’s game as a mathematically tractable testbed, in which competitive advantage is determined not by marginal sequence frequency but by the joint effect of self-overlap and cross-overlap structure. Based on Conway’s formula, we formulate two complementary tasks for gated recurrent units (GRUs): optimal counterstrategy prediction and win-probability estimation. Experimental results show that the GRU achieves strong performance on both tasks, recovering optimal or near-optimal second player responses and accurately estimating theoretical winning probabilities with good ranking consistency. These findings suggest that recurrent networks can learn structural regularities underlying asymmetric sequence competition, extending from single-pattern waiting-time effects to more complex competitive sequence settings.

1. Introduction

Recurrent neural networks (RNNs) have become an important computational framework for studying sequence learning and temporal cognition because they can continuously integrate historical information over time [1,2,3,4,5,6,7,8]. Unlike static mapping models, the hidden states of RNNs preserve contextual information during sequence unfolding and can dynamically represent processes such as partial matching, evidence accumulation, and state updating. This makes them useful not only for sequence modeling in engineering applications but also for investigating how cognitive systems extract structural regularities from temporal experience. However, existing studies have focused mainly on whether neural networks can successfully perform a given task, whereas less is understood about what structural variables are learned internally and how these learned representations support behavioral performance [9,10,11].
This issue is especially salient in sequence tasks characterized by asymmetries in waiting time. When exposed to random sequences, humans often show a preference for alternating patterns and tend to judge them as more random than repetitive ones. Previous studies have suggested that this phenomenon is not merely a subjective misjudgment, but is closely related to differences in the waiting times for different patterns to first appear in a random stream [12]. In particular, the self-overlap structure of a pattern systematically affects its waiting time, thereby providing an objective statistical basis for cognitive preference. Because this paradigm is both mathematically tractable and cognitively interpretable, it provides a useful entry point for examining how neural networks learn asymmetric sequence structure.
In our prior work [13], we used the Emergent framework to build a simple recurrent network (SRN) and examined whether the network could develop a preference for alternating patterns without explicit supervision. The results showed that, through continuous adaptation to random sequences alone, the network gradually formed differentiated internal representations of repetitive and alternating patterns and eventually exhibited a stable alternation preference. These findings suggest that RNNs can acquire structure related to waiting time from temporal experience, rather than merely fitting superficial input–output associations.
Many cognitive decisions, however, are not made by identifying an isolated pattern, but by comparing and selecting among multiple candidate patterns. Penney’s game provides a stricter and more challenging sequence competition paradigm of this kind. For two sequences of equal length, the outcome is not determined by their surface occurrence frequencies, but jointly by their self-overlap and cross-overlap structures, leading to pronounced asymmetric competitive relations. Compared with the alternation preference task, Penney’s game moves the problem from waiting time representation at the level of single patterns to composite structure learning in competitive sequence pairs. It is therefore a suitable testbed for examining whether RNNs can capture asymmetric sequence structure in a deeper and more transferable way.
Motivated by this, the present study focuses on asymmetric competition in Penney’s game and investigates whether gated recurrent units (GRUs) [14] can solve two core tasks: predicting the optimal counterstrategy for a given first player sequence and estimating the theoretical winning probability for an arbitrary sequence pair. By combining these two tasks, we further examine whether RNNs can learn the deeper regularities jointly determined by self-overlap and cross-overlap structure, and whether the representational capacity observed previously in single-pattern waiting time tasks can extend to more complex competitive sequence settings.

2. Theoretical Background and Problem Formulation

2.1. Penney’s Game

Penney’s game remains a canonical paradigm for studying nontransitive competition in random sequences and continues to be discussed in the literature [15,16,17,18,19]. Originally introduced by Walter Penney [20], and later popularized by Martin Gardner [21,22], it offers a particularly clear illustration of how structural asymmetry can arise in sequential matching tasks. In its standard form, two players each select a length-k binary sequence composed of H (heads) and T (tails). The second player observes the first player’s choice before making their own. A fair coin is then tossed repeatedly, and the player whose chosen sequence first appears as a contiguous subsequence in the resulting stream wins the game [23].
Intuitively, one might expect the competition to be symmetric: since every length-k sequence has the same marginal occurrence probability 2 − k , no sequence should be intrinsically favored. Yet Penney’s game reveals a striking asymmetry. When two sequences compete to appear first within the same random stream, the winning probability is generally far from 0.5 and is strongly biased toward one competitor. Moreover, for any sequence A chosen by the first player, the second player can always exploit A’s structural properties to select a sequence B such that P ( B ≻ A ) > 0.5 , where B ≻ A denotes the event that B appears before A. This guarantees a persistent second player advantage and implies that no sequence is globally dominant: every sequence can be beaten by some other sequence.
This asymmetry further leads to nontransitivity in the competitive relations among sequences. A sequence that has an advantage over one opponent does not necessarily retain that advantage against another. Importantly, this asymmetry does not arise from the marginal occurrence probability of an individual sequence, but from deeper structural relations between sequences. In particular, both self-overlap within a sequence and mutual-overlap between competing sequences jointly shape the probability that one sequence appears before the other.

2.2. Conway Formula

For two competing sequences A and B, Conway’s formula provides an analytic characterization of their winning relation in terms of overlap structure [24]. In its generalized q-ary form, q denotes the alphabet size, and the subscript in quantities such as A A q , B B q , A B q , and B A q indicates that the corresponding correlation string is interpreted as a number in base q.
Specifically, for any two sequences X and Y of length k, their correlation value is defined as
corr ( X , Y ) = X Y q = ∑ s = 0 k − 1 1 X [ s : ] = Y [ : k − s ] · q k − s − 1 ,
where X [ s : ] denotes the suffix of X starting at position s with length k − s , Y [ : k − s ] denotes the prefix of Y of length k − s , and 1 [ · ] is the indicator function. When a suffix of X exactly matches the corresponding prefix of Y, an overlap match is counted and weighted by q k − s − 1 . In this way, the definition systematically encodes all possible overlap patterns from full-length matching to single-symbol matching. In particular, s = 0 corresponds to a full-sequence match, whereas s = k − 1 corresponds to a one-symbol match.
On this basis, Conway’s formula gives the odds ratio between the two competing sequences as
P ( B ≻ A ) P ( A ≻ B ) = A A q − A B q B B q − B A q .
Accordingly, the winning probability of B against A can be written as
P ( B ≻ A ) = A A q − A B q A A q − A B q + B B q − B A q .
This expression makes the source of asymmetry explicit. The term A A q depends on the self-overlap of A, B B q depends on the self-overlap of B, and A B q and B A q quantify the directional mutual-overlap relations between the two sequences. Since A B q and B A q are generally not equal, the competitive relation between sequences is inherently directional and may even be nontransitive.

2.3. Problem Formulation

The goal of this study is to examine whether recurrent neural networks can learn and use the asymmetric structural regularities underlying Penney’s game. Evaluating only one output format is not sufficient for this purpose. On the one hand, if the model has truly captured the structural basis of the game, it should be able to convert this knowledge into an effective strategic choice. On the other hand, it should also be able to represent the graded competitive relation between sequence pairs in a continuous form. For this reason, we formulate two complementary supervised tasks: optimal counterstrategy prediction and win probability estimation.

2.3.1. Optimal Counterstrategy Prediction

The first task focuses on discrete strategy generation. Given a first player sequence A = ( a 1 , … , a k ) ∈ { 0 , … , q − 1 } k , the objective is to predict a second player response to A that maximizes the winning probability against it. Importantly, in the generalized q-ary setting, especially when q ≥ 3 , the optimal response is not necessarily unique: multiple distinct sequences may attain the same maximal winning probability against the same A. Therefore, the target of this task is defined as an optimal response set rather than a single sequence. Formally, the optimal response set is defined as
B * ( A ) = arg max B ∈ { 0 , … , q − 1 } k , B ≠ A P ( B ≻ A ) .
In the generalized q-ary case, this non-uniqueness mainly arises from permutation-equivalent symbol assignments when q ≥ 3 . Since the overlap structure underlying Conway’s formula depends on the pattern of symbol matches rather than the concrete symbol labels, some distinct second player sequences can be structurally equivalent and therefore achieve the same maximal winning probability against a given A. In our experimental settings, however, the size of the optimal-response set remains limited: the observed maximum cardinality of | B * ( A ) | is 2 for q = 3 , 3 for q = 4 , and 4 for q = 5 . Thus, although B * ( A ) may contain multiple sequences, the target multiplicity is structurally constrained rather than arbitrarily large.
This task examines whether the model can learn the mapping from the first player sequence to the optimal second player response set f θ : A ↦ B * ( A ) .
The rationale for this task is that Penney’s game is inherently a strategic choice problem. The key question is not merely whether the model can assign a higher score to a favorable sequence, but whether it can directly generate an advantageous response under the structural constraints imposed by self-overlap and mutual-overlap. Therefore, this experiment evaluates whether the learned representation can support discrete strategic behavior.

2.3.2. Win Probability Estimation

The second task focuses on continuous probability estimation. Given an ordered sequence pair ( A , B ) , the model is required to predict the probability that B appears before A, namely y ( A , B ) = P ( B ≻ A ) , where the target value is computed analytically by Conway’s formula in Equation (3).
This task can be written as a regression problem: g ϕ : ( A , B ) ↦ y ^ , where y ^ ∈ [ 0 , 1 ] .
Compared with the first task, this experiment imposes a stricter requirement on structural learning. The model must not only identify whether one response sequence is advantageous, but also capture fine grained differences in competitive strength across different sequence pairs. For a fixed first player sequence A, the predicted values y ^ ( A , B ) further induce a ranking over candidate second player sequences B. This makes it possible to evaluate whether the model has learned the directional probability landscape implied by the asymmetric overlap structure.

3. Methods and Experiments

3.1. GRU-Based Optimal Counterstrategy Prediction

3.1.1. Dataset Construction

For each configuration, each first player sequence A was treated as one basic sample, yielding a total of q k samples. Under each ( q , k ) configuration, all candidate first player sequences were enumerated, randomly shuffled at the sequence level using a fixed random seed, and then split independently into training and test subsets with a ratio of 70:30. Dataset sizes and the corresponding train–test splits are summarized in Table 1.
Table 1. Dataset sizes under different configurations.
For each first player sequence A, all candidate second player sequences satisfying B ≠ A were enumerated, and P ( B ≻ A ) was computed using Equation (3). The corresponding optimal response set B * ( A ) was then determined and used as the supervision label for that sample.

3.1.2. Model Architecture

The model adopts a single-encoder GRU architecture. We adopt GRU as the primary recurrent architecture because it provides a compact gated mechanism for modeling sequential dependencies. Compared with a vanilla RNN, GRU can regulate the update and retention of hidden-state information through gating operations, which alleviates the limitation of simple recurrent state transitions. Compared with LSTM, GRU has a simpler structure while retaining gated state updating, making it a compact choice for the present short discrete-sequence setting. The overall architecture is illustrated in Figure 1.
Figure 1. Schematic illustration of the GRU encoder architecture for optimal counterstrategy prediction.
Given an input sequence A = ( a 1 , … , a k ) , where a t ∈ { 0 , … , q − 1 } , each symbol is first mapped to a continuous vector through an embedding layer:
e t = Embedding ( a t ) ,
which is then fed sequentially into the GRU encoder:
h t = GRU ( e t , h t − 1 ) , t = 1 , … , k ,
for each input sequence, the initial hidden state is set to an all-zero vector, i.e., h 0 = 0 .
We adopt a single-encoder GRU because the first task only takes the first player sequence A as input and aims to predict a fixed-length counterstrategy B ^ . Under this setting, a single encoder is sufficient to summarize the relevant information of A into a global hidden representation. Moreover, since one goal of this study is to analyze whether the learned representation captures the asymmetric overlap structure underlying Penney’s game, a simple encoder-centered architecture is methodologically preferable to a more complex sequence-to-sequence or encoder–decoder design.
The final hidden state h k is taken as the global representation of the input sequence. For a q-ary response sequence of length k, the model performs position-wise classification at the output layer; that is, for each position t ∈ { 1 , … , k } , it predicts a symbol b t ∈ { 0 , … , q − 1 } .
Although B ^ is a structured sequence, we do not use an autoregressive decoder. In Penney’s game, the second player first observes the complete first player sequence A and then chooses an entire response sequence B as a counterstrategy. The task is therefore more naturally formulated as a fixed-length structured prediction conditioned on the full input rather than left-to-right sequence generation. Accordingly, we decode all positions of B ^ simultaneously from the final hidden state h k . This design also helps isolate whether h k itself encodes the asymmetric overlap structure of the game, rather than attributing performance to additional output-side sequence modeling.
Based on this design, the output layer linearly maps h k to
Z ∈ R k × q ,
where the t-th row corresponds to the logits over all candidate symbols at the t-th position of the predicted sequence. After applying softmax, the predicted sequence B ^ is obtained by selecting the symbol with the highest probability at each position.
Since the optimal response may not be unique, set-level supervision is adopted during training by maximizing the total probability mass assigned to the optimal response set. Specifically, let
P ( B ∣ A ) = ∏ t = 1 k Softmax ( Z t ) [ b t ] ,
where the sequence-level probability is thus factorized into position-wise probabilities predicted in parallel from the shared hidden representation h k . Under this formulation, dependencies among output positions are captured only implicitly through the shared representation, rather than being modeled explicitly at the decoder level.
Accordingly, the loss function is defined as
L set ( A , B * ) = − log ∑ B ∈ B * ( A ) P ( B ∣ A ) .
The detailed hyperparameter settings are summarized in Table 2. Training was terminated after the predefined number of epochs, and no early stopping criterion was used.
Table 2. Hyperparameter settings for optimal counterstrategy prediction.

3.1.3. Evaluation Metrics

To comprehensively evaluate model performance on the optimal counterstrategy prediction task, four metrics were designed to assess four aspects, namely, optimal-solution matching, win-probability loss, preservation of the second player advantage, and structural bias.
The equivalence-class accuracy, denoted by Acc eq , is used to measure whether the model prediction hits the theoretically optimal response set. Suppose that the test set contains N samples. For the i-th sample, given a first player sequence A i , the model produces a unique predicted sequence B ^ i through argmax decoding. The equivalence-class accuracy is defined as
Acc eq = 1 N ∑ i = 1 N 1 B ^ i ∈ B i * ,
where 1 [ · ] is the indicator function, which takes the value 1 when the condition holds and 0 otherwise. This metric does not require the model to output one prespecified standard answer; instead, it evaluates whether the prediction belongs to the functionally equivalent optimal response set. Since all sequences in B i * yield the same theoretically optimal win probability against A i , hitting any member of the set is regarded as a correct prediction. Compared with single-label accuracy, Acc eq is more suitable for characterizing how well the model learns the set of optimal strategies when multiple optimal solutions exist.
To further quantify the performance gap between the predicted strategy and the theoretical optimum, the average win-probability difference Δ P is defined as
Δ P = 1 N ∑ i = 1 N P i * − P ( B ^ i ≻ A i ) ,
where P i * = max B ≠ A i P ( B ≻ A i ) denotes the theoretically optimal win probability for the i-th sample. Δ P characterizes the average loss of the model prediction relative to the optimal strategy in terms of actual game payoff. When Δ P = 0 , all predictions achieve the theoretically optimal win probability. Compared with the discrete set-matching metric, Δ P can further distinguish predictions that miss the optimal set but remain close to optimal from those that deviate substantially from the optimum.
The proportion of advantage-preserving strategies, denoted by BetterB , is used to examine whether the model prediction preserves the competitive advantage of the second player sequence over the first player sequence, and is defined as
BetterB = 1 N ∑ i = 1 N 1 P ( B ^ i ≻ A i ) > 0.5 ,
where P ( B ^ i ≻ A i ) is computed using Conway’s formula. This metric measures the proportion of samples for which the predicted sequence B ^ i retains a second player advantage over the first player sequence A i , that is, the proportion of cases with win probability greater than 0.5 . Compared with Acc eq , BetterB is a more relaxed evaluation criterion: even if the prediction does not hit the theoretically optimal response set, the sample is still counted as successful as long as the predicted sequence preserves the second player advantage. Therefore, BetterB reflects the effectiveness of the generated strategy rather than merely its agreement with the optimal solution set.
In addition to behavioral correctness and advantage preservation, this study also examines whether the model learns key structural features associated with optimal responses. According to Conway’s formula, the B B q term in the denominator corresponds to the autocorrelation of sequence B, which characterizes its self-overlap structure. A smaller B B q usually indicates weaker self-overlap and is associated with a shorter waiting time for first occurrence. Statistical analysis over all candidate sequences shows that theoretically optimal responses tend to favor sequences with lower self-overlap and shorter waiting times. To examine whether the model exhibits the same structural bias, we define the input-dependent minimum self-overlap value as BB min ( A i ) = min B ≠ A i corr ( B , B ) , where B is taken from the candidate sequence space { 0 , … , q − 1 } k . The minimum-waiting-time sequence hit rate MinBB hit is then defined as
MinBB hit = 1 N ∑ i = 1 N 1 corr ( B ^ i , B ^ i ) = BB min ( A i ) ,
this metric measures whether the model prediction falls within the set of candidate sequences with minimum self-overlap, thereby reflecting whether the model implicitly captures the important structural regularity of preferring low-self-overlap sequences, which is closely related to optimal responses.

3.1.4. Results

Figure 2 shows representative test-set trajectories of Acceq under different q and k configurations. These curves are from a single representative run and are intended to illustrate the convergence behavior during training. The final quantitative results are reported in Table 3 as mean ± standard deviation over three independent runs with different training random seeds.
Figure 2. Representative test-set equivalence-class accuracy curves under different q and k configurations. For visual clarity, the curves shown here are from a single representative run.
Table 3. Evaluation metrics under different q and k configurations.
Overall, all 12 parameter configurations exhibit stable convergence trends. The curves rise rapidly in the early stage of training, indicating that the model is able to capture the basic structure of the optimal-response mapping in Penney’s game at an early stage. This is followed by a phase of slower improvement and gradual stabilization, suggesting that the later stage of training is dominated by fine-grained refinement rather than simple memorization of the training samples. The overall training dynamics indicate that the GRU can learn this task stably across different alphabet sizes and sequence lengths.
Across different parameter settings, the effect of sequence length k on convergence is not monotonic, but clear regularities can still be observed. Under the condition of q = 3 , as k increases from 5 to 8, the representative trajectories show an overall upward trend. In particular, in this representative run, the curve for k = 8 surpasses that for k = 7 in the later stage of training and finally reaches about 90.1%, which is substantially higher than the roughly 70.9% observed for k = 5 . This suggests that, under a relatively small alphabet, the sample expansion brought by longer sequences helps the model learn the competitive regularities of sequences more thoroughly. Under the condition of q = 4 , the curves for k = 7 and k = 8 almost overlap and both converge to around 95% within 50 epochs, indicating that when the alphabet size is moderate, the marginal effect of sequence length on learning efficiency becomes weaker. Under the condition of q = 5 , all configurations converge rapidly, and in this representative run the final accuracy remains above 93% in every case, with k = 6 and k = 7 reaching about 98.9% and 97.8%, respectively. Although the result for k = 8 is slightly lower than these two, it still remains at a high level of about 96.4%. Overall, larger values of q are generally associated with faster convergence, which may be related to the richer combinations of overlap patterns. By contrast, when q is smaller, the structural diversity and supervisory signals available to the model are more limited, and learning therefore proceeds more slowly.
Table 3 summarizes the final test performance of the model under the 12 configurations, where all reported values are the mean ± standard deviation over three independent runs with different training random seeds. Overall, although the size of the first player sequence space expands from 243 at q = 3 , k = 5 to 390,625 at q = 5 , k = 8 , spanning three orders of magnitude, the model still maintains strong and stable performance across configurations. These results suggest that the learned strategy is not restricted to a specific parameter regime and shows limited sensitivity to training randomness under the present experimental settings.
First, in terms of equivalence-class accuracy Acceq, the average mean accuracy across the 12 configurations is 89.5%, and 8 of them exceed 90%. When q ≥ 4 , the model achieves high accuracy in most cases. In particular, under q = 5 , the mean Acceq remains above 92% for all four values of k, reaching its highest value at k = 6 ( 98.97 ± 0.25 %). By contrast, under q = 3 , the model exhibits a more pronounced dependence on sequence length: as k increases from 5 to 8, the mean Acceq improves steadily from 71.18 ± 0.89 % to 90.55 ± 0.67 %. This suggests that under a smaller alphabet, increasing sequence length can partially alleviate the learning difficulty caused by limited structural pattern diversity.
Second, the winning-probability gap Δ P reflects the performance difference between the strategy predicted by the model and the theoretical optimal strategy. The results show that the mean Δ P remains below 0.016 in all configurations, indicating that even when the model does not strictly hit the optimal equivalence class, the predicted strategy remains very close to the theoretical optimum in terms of winning probability. In particular, under the k = 8 configurations, the mean Δ P further decreases to 0.0003 ± 0.0005 for q = 3 , 0.0003 ± 0.0002 for q = 4 , and 0.0001 ± 0.0002 for q = 5 , showing that the model can closely approximate the theoretical optimum in probabilistic terms. Notably, Δ P does not bear a simple linear relationship to Acceq. For example, under q = 3 , k = 7 , the mean Acceq is 86.27 ± 0.55 %, whereas the mean Δ P is only 0.0011 ± 0.0005 . By contrast, under q = 5 , k = 6 , although the mean Acceq is higher ( 98.97 ± 0.25 %), the corresponding mean Δ P is 0.0020 ± 0.0024 . This phenomenon suggests that in Penney’s game, besides the strictly optimal response set B * , there also exist suboptimal sequences whose winning probabilities are extremely close to optimal. Therefore, even when the model fails to hit the strictly optimal equivalence class, its prediction may still remain very close to the theoretical optimum in terms of actual competitive advantage.
Third, the two metrics BetterB and MinBBhit further reveal the structural characteristics of the learned strategy. BetterB remains above 92% in all configurations, with a mean of 98.6% across the 12 settings, indicating that in the vast majority of cases the model generates a second player strategy that is genuinely advantageous over the first player sequence A. The highest BetterB is observed at q = 5 , k = 7 , where it reaches 99.89 ± 0.11 %. Meanwhile, MinBBhit remains above 90% throughout, with a mean of 95.9%, indicating that the generated candidate sequences usually also satisfy the structural property of relatively low self-overlap. In particular, under the k = 8 configurations, BetterB reaches 99.58 ± 0.39 %, 99.61 ± 0.19 %, and 99.69 ± 0.27 % for q = 3 , q = 4 , and q = 5 , respectively, demonstrating strong stability across alphabet sizes.
This consistency is in line with the structural regularities characterized by Conway’s formula. According to Equation (3), the winning probability of the second player sequence B against the first player sequence A is jointly determined by A A q , B B q , A B q , and B A q , where B B q = corr ( B , B ) characterizes the self-overlap structure of sequence B. A smaller B B q means that B is less likely to match its own suffixes, which is favorable for improving its competitive advantage. From the perspective of waiting-time theory, B B q also corresponds to the expected waiting time E [ T B | ∅ ] for sequence B to occur for the first time starting from the empty state: lower self-overlap generally implies a shorter waiting time, and thus a greater chance of appearing first in competition. Accordingly, the high MinBBhit values indicate that the model’s predicted responses are strongly consistent with the low-self-overlap preference implied by the overlap-based structure of Penney’s game. This provides output-level behavioral evidence that the learned input–output mapping is sensitive to structural regularities related to self-overlap and waiting time.
It should also be noted that MinBBhit is higher than Acceq under all configurations. For example, under q = 3 , k = 5 , the two values are 94.13 ± 0.37 % and 71.18 ± 0.89 %, respectively, a gap of about 23 percentage points. This result indicates that selecting a low-self-overlap sequence is an effective but not sufficient strategy. At the same time, in some high-performing settings such as q = 5 , k = 6 and q = 5 , k = 7 , Acceq and MinBBhit become nearly identical, differing by less than 0.3 percentage points. This suggests that when the model performance is already very high, the low-self-overlap preference becomes more closely aligned with the actual optimal-response set. More generally, even when the predicted sequence does not attain the global minimum of B B q , it may still achieve a near-optimal winning probability as long as it has an appropriate mutual-overlap structure with the first player sequence, as reflected by A B q and B A q . Therefore, the model does not merely favor the minimum- B B q solution mechanically; rather, its output behavior appears to reflect the joint influence of self-overlap and mutual-overlap structures to some extent.
Taken together, the training dynamics and final results show that the GRU can effectively learn the optimal-response regularities in Penney’s game. The model not only achieves high accuracy in discrete strategy prediction, but also exhibits consistent output-level structural tendencies on metrics such as BetterB and MinBBhit. These findings indicate that the learned predictions are consistent with the overlap-based regularities associated with competitive advantage in Penney’s game.
Representative Architecture Comparison
To assess the dependence of the results on the recurrent architecture, we further compared GRU with two recurrent baselines, namely a vanilla RNN and an LSTM. To provide a representative but computationally feasible comparison, we selected three configurations: ( q , k ) = ( 3 , 5 ) , ( 4 , 6 ) , and ( 5 , 5 ) . These settings correspond to a relatively simple case, an intermediate case, and a larger-alphabet case, respectively. They were chosen to cover different levels of task complexity while avoiding the most computationally expensive long-sequence configurations in the full experimental grid. All models in this comparison were trained and evaluated under the same data split strategy and training protocol. To make the comparison consistent, a fixed random seed was used within each configuration. The reported values are from one representative run for each architecture and configuration.
As shown in Table 4, all three recurrent architectures achieve non-trivial performance, indicating that the ability to learn asymmetric sequence-competition regularities is not exclusive to GRU. However, GRU shows a more balanced overall pattern across the evaluated metrics. Although its average Acceq is slightly lower than that of LSTM, GRU achieves the lowest average Δ P and the highest average BetterB and MinBBhit among the three architectures. This indicates that the responses predicted by GRU are, on average, closer to the theoretically optimal response in terms of winning probability and are more frequently associated with the minimum-self-overlap response pattern measured by MinBBhit. Therefore, these results support the use of GRU as the primary architecture for the optimal counterstrategy prediction task, not because it dominates every individual metric under every configuration, but because it provides a favorable balance between prediction quality and architectural compactness.
Table 4. Representative architecture comparison under selected q and k configurations.
Systematic Error Analysis
To further examine where the residual errors are concentrated, we conducted a grouped diagnostic analysis based on the cardinality of the optimal-response set | B * ( A ) | . For each alphabet size q, test samples from k = 5 , 6 , 7 , 8 were pooled and then grouped according to | B * ( A ) | . The proportion of each subgroup was computed within the pooled test samples under the same q. To make the subgroup comparison consistent, the grouped diagnostic analysis was performed using the prediction results from a fixed random seed within each ( q , k ) configuration. For each input sequence A, we define the optimality margin as
Margin ( A ) = P ( B * ≻ A ) − P ( B second ≻ A ) ,
where B * ∈ B * ( A ) denotes an optimal response and where B second denotes the second-best response, i.e., the response with the highest winning probability among all admissible candidates outside the optimal-response set B * ( A ) . A smaller margin indicates that the optimal response is only weakly separated from its nearest non-optimal competitor.
Table 5 reports the grouped error analysis across different alphabet sizes.
Table 5. Grouped error analysis by the cardinality of the optimal-response set. Prop. denotes the subgroup proportion under the same q. This table is intended as a diagnostic breakdown of residual errors.
The grouped results reveal that the remaining errors are not uniformly distributed across different optimal-set-size groups. Within each alphabet size, groups with smaller optimal-response sets generally show lower Acceq and smaller margins. For example, when q = 3 , the unique-optimum group has a lower Acceq than the group with two optimal responses. Similarly, when q = 4 and q = 5 , the groups with smaller | B * ( A ) | show relatively lower Acceq than the groups with larger optimal-response sets.
Thus, the grouped results should not be interpreted solely as a mechanical consequence of having more acceptable labels in larger B * ( A ) sets. Rather, they indicate that the residual errors are concentrated in structurally less separable cases, where the optimality margin is small. Larger optimal-response sets in our results are often accompanied by larger margins, suggesting that their higher Acceq may reflect more distinguishable optimal structures rather than only a larger number of acceptable labels.

3.2. GRU-Based Win Probability Estimation

3.2.1. Dataset Construction

Since this task takes ordered sequence pairs ( A , B ) as the basic sample unit, the dataset size grows rapidly with increasing k. To control the combinatorial space and computational cost, a binary alphabet with q = 2 was adopted throughout, and experiments were conducted under six sequence-length settings, k ∈ { 4 , 5 , 6 , 7 , 8 , 9 } .
For each k, the split was performed at the level of first player sequences. All candidate first player sequences were enumerated, randomly shuffled at the sequence level using a fixed random seed, and then split independently into training and test subsets with a ratio of 70:30. For each first player sequence A, all candidate second player sequences satisfying B ≠ A were enumerated to construct ordered samples ( A , B , P ( B ≻ A ) ) . Therefore, for each configuration, the total number of first player sequences is 2 k , each first player sequence corresponds to 2 k − 1 ordered samples, and the total number of samples under each configuration is 2 k ( 2 k − 1 ) . Dataset sizes and the corresponding train–test splits are summarized in Table 6.
Table 6. Dataset sizes under different sequence length configurations.

3.2.2. Model Architecture

Following the same architectural motivation, the win-probability estimation model adopts a dual-branch GRU architecture with a shared encoder. The overall architecture is illustrated in Figure 3.
Figure 3. Architecture of the shared-weight GRU model for estimating the probability that sequence B appears before sequence A.
Given an input sequence pair ( A , B ) , where A = ( a 1 , … , a k ) and B = ( b 1 , … , b k ) , the first player sequence and the second player sequence are separately passed through an embedding layer and a GRU encoder with shared parameters, yielding the hidden representations of the two sequences h A , h B . Based on these representations, the sequence embeddings and their interaction features are concatenated as
f = [ h A , h B , h A ⊙ h B , h B − h A ] ,
h A and h B preserve the global representations of the two sequences, respectively. The element-wise interaction pattern combining multiplication and subtraction has been widely adopted and validated in siamese-style architectures for natural language inference and sentence similarity modeling [25,26]. In this study, h A ⊙ h B is used to characterize the matching relationship between the two sequence representations in hidden space, while the directional difference term h B − h A is retained to encode order-sensitive information explicitly. Unlike conventional similarity modeling, which often uses the absolute difference | h A − h B | to maintain symmetry, the present task concerns an ordered sequence pair ( A , B ) , for which P ( B ≻ A ) and P ( A ≻ B ) are generally not identical. Thus, preserving h B − h A allows the model not only to retain relative displacement in representation space, but also to capture the asymmetric overlap advantage underlying competitive outcomes in Penney’s game.
The joint feature vector f is then fed into a two-layer multilayer perceptron to produce the predicted probability:
logit = W 2 ReLU ( W 1 f + b 1 ) + b 2 ,
y ^ = σ ( logit ) .
During training, the theoretical probability y ( A , B ) = P ( B ≻ A ) computed using Equation (3) is used as the supervision signal, and the mean squared error loss is adopted:
L mse = 1 N ∑ i = 1 N ( y ^ i − y i ) 2 .
The detailed hyperparameter settings are summarized in Table 7. Training was terminated after the predefined number of epochs, and no early stopping criterion was used.
Table 7. Hyperparameter settings for win probability estimation.

3.2.3. Evaluation Metrics

To evaluate model performance on the win probability estimation task, two complementary aspects were considered: numerical prediction accuracy and ranking consistency over candidate sequences. The former measures the deviation between the predicted values and the theoretical probabilities given by Conway’s formula, whereas the latter assesses whether the model can correctly recover the relative competitive ordering among candidate second player sequences under a fixed first player sequence.
(1)
Probability Prediction Accuracy
Let the test set contain N ordered sequence pairs ( A i , B i ) , with theoretical labels y i = P ( B i ≻ A i ) ∈ [ 0 , 1 ] and model predictions y ^ i ∈ [ 0 , 1 ] .
The mean absolute error (MAE) is defined as
MAE = 1 N ∑ i = 1 N y ^ i − y i ,
which measures the average absolute deviation between predicted and theoretical probabilities.
The root mean square error (RMSE) is defined as
RMSE = 1 N ∑ i = 1 N y ^ i − y i 2 ,
which measures the overall dispersion of prediction errors. Compared with MAE , RMSE is more sensitive to large deviations and therefore better reflects the influence of high-error samples. In general, RMSE ≥ MAE on the same test set.
(2)
Ranking Consistency
Although MAE and RMSE quantify numerical fitting accuracy, they do not fully capture the strategic validity of the task. For a fixed first player sequence A, the key question is whether the model can correctly rank different candidate second player sequences B according to their competitive strength. Ranking-consistency metrics were therefore introduced to evaluate how well the model preserves the relative ordering induced by the theoretical win probabilities.
For each fixed first player sequence A in the test set, the corresponding subset is written as S A = { ( A , B i , y i , y ^ i ) } i = 1 m A , where m A is the number of candidate second player sequences paired with A, y i = P ( B i ≻ A ) is the theoretical win probability, and y ^ i is the predicted win probability. Ranking consistency is first computed within each subset and then averaged over all first player sequences.
Spearman’s rank correlation coefficient is defined as
ρ s ( A ) = corr rank ( y ) , rank ( y ^ ) ,
where rank ( · ) maps values to ranks and corr ( · , · ) denotes the Pearson correlation coefficient.
Kendall’s rank correlation coefficient evaluates ranking consistency from the perspective of pairwise agreement. For a fixed A, all pairwise comparisons ( B i , B j ) among candidate second player sequences are considered. If the relative ordering induced by the theoretical win probabilities agrees with that induced by the predicted win probabilities, the pair is concordant; otherwise, it is discordant. Since ties may occur in both theoretical and predicted probabilities, Kendall’s τ b with tie correction is adopted:
τ b ( A ) = C A − D A ( C A + D A + T y , A ) ( C A + D A + T y ^ , A ) ,
where C A and D A denote the numbers of concordant and discordant pairs, respectively, T y , A denotes the number of tied pairs in the theoretical probabilities, and T y ^ , A denotes the number of tied pairs in the predicted probabilities.
Overall, MAE and RMSE evaluate absolute probability fitting accuracy, whereas ρ s and τ b evaluate the preservation of relative competitive ordering among candidate second player sequences. Together, these metrics provide a comprehensive assessment of how well the model learns the directional probability structure of Penney’s game.

3.2.4. Results

Figure 4 shows representative test-set trajectories of MAE and RMSE over training epochs for the six k configurations. These curves are from a single representative run and are intended to illustrate the convergence behavior during training, whereas the final quantitative results are reported in Table 8 as mean ± standard deviation over three independent runs with different training random seeds.
Figure 4. Representative test-set MAE and RMSE curves over training epochs under different k configurations. For visual clarity, the curves shown here are from a single representative run.
Table 8. Prediction errors and normalized errors under different sequence length configurations. Results for MAE, RMSE, nMAE, and nRMSE are reported as mean ± standard deviation over three independent runs with different training random seeds. The baseline quantities MAE 0.5 and RMSE 0.5 are deterministic under the fixed test split and are therefore reported as single values.
Overall, all configurations exhibit clear and stable convergence trends: both errors decrease rapidly in the early stage of training, followed by a slower decline and gradual stabilization. In terms of the final converged results, the model achieves low prediction errors under all configurations, indicating that the GRU can approximate the theoretical winning probabilities characterized by Conway’s formula with high accuracy.
From the shapes of the representative trajectories, the trends of MAE and RMSE are highly consistent across all configurations, and RMSE is always slightly larger than MAE, which agrees with the theoretical fact that the root mean squared error is no smaller than the mean absolute error. The gap between the two metrics remains small overall, suggesting that the error distribution is relatively concentrated. In other words, the model’s prediction error is not dominated by a small number of extreme samples, but is instead distributed relatively evenly across the test set.
To eliminate the influence of changes in the scale of the label distribution across different k values when comparing errors, a constant-prediction baseline was further introduced. This baseline does not use any sequence-structure information and always outputs y ^ = 0.5 for any input sequence pair ( A , B ) , corresponding to random guessing under a no-information condition. Based on this baseline, the corresponding errors can be defined as
MAE 0.5 = E A , B ≠ A | 0.5 − y | , RMSE 0.5 = E A , B ≠ A ( 0.5 − y ) 2 ,
where y denotes the theoretical winning probability computed from Conway’s formula. It should be noted that, as k increases, the theoretical probability distribution becomes more concentrated around 0.5, and the competitive advantage between sequence pairs gradually becomes more subtle, causing the natural scale of the absolute error to decrease accordingly. Therefore, comparing only the raw MAE and RMSE is insufficient for a fair evaluation of learning performance across different k conditions. To address this issue, normalized error metrics are further adopted:
nMAE = MAE MAE 0.5 , nRMSE = RMSE RMSE 0.5 .
Here, both nMAE and nRMSE take the constant-baseline error as a reference and are used to measure the model’s relative error level with respect to no-information guessing, thereby making the results across different k values more comparable. When nMAE < 1 or nRMSE < 1 , the model outperforms the baseline; the smaller the value, the more effective information the model has extracted from the sequence structure.
Table 8 reports the final test-set prediction errors and normalized errors under different sequence-length configurations, where MAE, RMSE, nMAE, and nRMSE are reported as mean ± standard deviation over three independent runs with different training random seeds.
In terms of absolute error, the model achieves small MAE and RMSE values under all configurations, indicating high fitting accuracy to the theoretical winning probabilities. In particular, the lowest absolute errors are obtained at k = 8 , where the mean MAE and RMSE are 0.0020 ± 0.0004 and 0.0029 ± 0.0003 , respectively. Even for the most difficult settings in absolute terms, the errors remain at a low level overall, showing that the GRU can approximate the Conway-based winning probabilities with good precision.
On the normalized scale, all configurations yield nMAE and nRMSE values far below 1.0, which shows that even after correcting for changes in the natural error scale across different k values, the model still maintains a clear and stable advantage over the no-information baseline. Among these settings, the best normalized performance is observed around k = 5 , k = 7 , and k = 8 , where nMAE is close to 0.1 and nRMSE is below 0.11. This means that the model reduces the prediction error to roughly one tenth of the baseline level in these configurations.
At the same time, the normalized errors do not decrease monotonically with increasing k. In particular, a noticeable rebound appears at k = 6 and becomes more pronounced at k = 9 , where nMAE rises to 0.2033 ± 0.0164 and 0.2871 ± 0.0396 , respectively. This phenomenon suggests that although the raw errors tend to shrink as the theoretical probability distribution becomes more concentrated around 0.5, the increasing size and complexity of the sequence space still introduce nontrivial optimization challenges for the model.
Moreover, the reported standard deviations are generally small across configurations, indicating that the regression performance is stable under different training random seeds. Taken together, these results show that the GRU does not merely fit superficial numerical patterns, but instead learns sequence-structural information that is genuinely relevant to the asymmetric winning probabilities in Penney’s game.
From the perspective of the task itself, the winning relation in Penney’s game is not determined by local symbol frequency, but jointly by the self-overlap structure of each sequence and the mutual-overlap structure between sequences. Specifically, the asymmetry in winning probability arises from the combined relationship among the correlation values A A q , B B q , A B q , and B A q , where the mutual-overlap terms are generally not symmetric under exchange, that is, one typically has A B q ≠ B A q . The fact that the model can provide relatively accurate winning-probability predictions for arbitrary sequence pairs ( A , B ) suggests that its hidden-state representations may already encode this kind of direction-dependent structural information, rather than merely fitting the training samples at a superficial level.
Figure 5 summarizes the ranking consistency results under different k configurations at the final epoch. The bar heights represent the mean values over three independent runs, and the error bars denote the corresponding standard deviations. Overall, both Kendall’s τ b and Spearman’s ρ s remain at relatively high levels for all k values, with τ b generally above 0.6 and ρ s generally above 0.7. This indicates that the model is able not only to produce probability estimates close to the theoretical values in a numerical sense, but also to recover the relative competitive advantages among different candidate second player sequences under a fixed first player sequence. Moreover, the error bars are generally small across configurations, suggesting that the ranking performance is stable under different training random seeds.
Figure 5. Test-set ranking consistency results under different k configurations. Bars show the mean values over three independent runs with different training random seeds, and error bars indicate the standard deviation.
It is worth noting that both τ b and ρ s show some fluctuations across different k values, but exhibit an overall downward tendency as k increases, reaching 0.612 and 0.723, respectively, at k = 9 , which are the lowest values among all configurations. This phenomenon mainly arises for two reasons. First, as k increases, the theoretical winning-probability labels become more concentrated around 0.5, and the true advantage differences among candidate sequences become more subtle, thereby making ranking discrimination more difficult. Second, under larger k values, the number of candidate second player sequences corresponding to a fixed first player sequence increases, which also raises the combinatorial complexity of the ranking task itself. Even so, at k = 9 , both ranking metrics remain clearly above the expected level of 0 for random ranking, indicating that the model still retains effective ranking discrimination ability under the longest-sequence configuration.
Representative Architecture Comparison
To further assess whether the win-probability estimation results depend on the recurrent architecture, we also compared GRU with two recurrent baselines, namely a vanilla RNN and an LSTM. Since the probability-estimation task is defined over ordered sequence pairs and therefore involves a larger combinatorial sample space, we selected two representative configurations, k = 4 and k = 6 , for this comparison. These two settings provide different levels of task complexity while keeping the additional architecture comparison computationally feasible. The alphabet size was fixed to q = 2 , consistent with the main win-probability estimation experiment. All models were trained and evaluated under the same data split strategy and training protocol. To make the comparison consistent, a fixed random seed was used within each configuration. The reported values are from one representative run for each architecture and configuration.
As shown in Table 9, all three recurrent architectures are able to estimate the winning probability, suggesting that the probability structure induced by Conway’s formula can be captured by recurrent sequence models more generally. Compared with the vanilla RNN, the two gated recurrent models achieve lower prediction errors and higher rank-correlation coefficients in most cases, indicating that gated recurrent mechanisms are beneficial for modeling overlap-dependent probability regularities.
Table 9. Representative architecture comparison under selected k configurations for the win-probability estimation task.
Overall, GRU shows the most balanced performance across the evaluated metrics. It achieves the lowest MAE in both selected settings and obtains the highest Kendall’s τ b in both cases. Although LSTM gives a slightly lower RMSE and a higher Spearman’s ρ s in one setting, GRU achieves better overall rank consistency and competitive error values. Averaged over the selected settings, GRU obtains the lowest MAE and the highest Kendall’s τ b and Spearman’s ρ s , while its RMSE remains very close to that of LSTM. These results suggest that GRU provides a favorable balance between probability-estimation accuracy and ranking consistency.
Ablation on Pairwise Interaction Terms
To examine the contribution of the explicit interaction terms in the win-probability estimation task, we conducted an ablation study under the binary setting with q = 2 . The full model represents each ordered pair ( A , B ) as [ h A , h B , h A ⊙ h B , h B − h A ] , where h A and h B denote the recurrent hidden representations of the two sequences. We compared this full representation with three ablated variants: removing the element-wise product term, removing the difference term, and removing both interaction terms. For consistency with the architecture comparison and to keep the additional experiments computationally tractable, this ablation was conducted under the two representative sequence lengths k = 4 and k = 6 , which reflect relatively low and higher task complexity within the evaluated range.
As shown in Table 10, the full model achieved the best performance across the selected sequence lengths. Removing both interaction terms produced the weakest results, indicating that simply concatenating the two sequence representations is insufficient for accurately estimating the asymmetric win probability. Moreover, the variant without the product term consistently outperformed the variant without the difference term, suggesting that the directional difference h B − h A provides an especially useful order-sensitive comparison signal for modeling P ( B ≻ A ) . Overall, these results suggest that the explicit pairwise interaction terms provide useful inductive biases for comparing two sequence representations in the win-probability estimation task.
Table 10. Ablation study of pairwise interaction terms under selected k configurations for the win-probability estimation task.
Linear Probing of Conway Overlap Variables
To further examine whether the trained win-probability estimation model encodes Conway-style overlap structures in its internal representation, we conducted a linear probing analysis. After the main model was trained, all parameters of the original model were frozen. For each input pair ( A , B ) , we extracted the joint feature vector f defined in Equation (15), which is the same representation used as the input to the prediction MLP. We then trained independent linear regression probes to predict the four Conway overlap variables A A q , A B q , B A q , and B B q from f . During probing, only the linear readout layer was updated, while the original model remained fixed. The probing performance was evaluated on the held-out test set using R 2 , where a positive value indicates that the corresponding overlap variable is linearly decodable beyond the mean-prediction baseline. Following the same representative-setting protocol used in the preceding supplementary analyses, the probing experiment was conducted for k = 4 and k = 6 under the binary setting.
As shown in Table 11, Among the four Conway overlap variables, B A q and B B q show the highest decoding performance. This pattern is meaningful in light of Equation (2), whose denominator can be decomposed into the A-related component ( A A q − A B q ) and the B-related component ( B B q − B A q ) . Specifically, B B q captures the self-overlap structure of the second-player sequence B, whereas B A q captures the cross-overlap from B to A. Since the B-related component contributes directly to the relative competitive structure between the two sequences, the stronger linear decodability of B A q and B B q suggests that the learned joint feature vector f is particularly sensitive to the structural terms associated with the second player’s competitive advantage.
Table 11. Linear probing for Conway overlap variables in the win-probability estimation task.
In contrast, the more moderate decoding performance for A A q and A B q indicates that the A-related component is also represented, but with weaker linear accessibility. Overall, these probing results suggest that Conway-style overlap variables are linearly decodable from the learned joint feature vector f , with especially strong sensitivity to the terms related to the second-player sequence.

4. Discussion

Taken together, the results of the optimal counterstrategy prediction task and the win probability estimation task show that the GRU performs well in both discrete and continuous settings. The former examines whether the model can recover an optimal second player response from a given first player sequence, whereas the latter evaluates whether the model can accurately estimate the fine-grained competitive advantage between arbitrary sequence pairs. Although the two tasks differ in output format, both depend on the asymmetric competitive structure of Penney’s game jointly determined by self-overlap and mutual-overlap patterns. The consistently strong performance across both tasks therefore suggests that the GRU learns more than isolated input–output correspondences; rather, it captures structural information relevant to sequence competitive advantage.
From a structural perspective, the asymmetry in Penney’s game arises from the joint effect of within-sequence self-overlap and between-sequence mutual-overlap. Self-overlap affects the waiting time properties of a sequence itself, whereas mutual-overlap determines how different sequences interact during competition. In particular, the mutual-overlap terms are generally not exchange-symmetric, that is, A B q ≠ B A q in general, making the competitive relationship between sequence pairs inherently direction-dependent. In the optimal counterstrategy prediction task, the model generates second player sequences with clear competitive advantage under most configurations. In the win probability estimation task, it further provides accurate numerical characterizations of this advantage. These findings indicate that the hidden-state representations learned by the GRU can integrate self-overlap and mutual-overlap information and transform them into internal encodings useful for either decision making or regression.
The two tasks also provide converging evidence. In the optimal counterstrategy prediction task, even when the model does not always exactly hit the theoretically optimal equivalence class, its predictions often still achieve near-optimal win probabilities. In the win probability estimation task, the model not only yields low numerical errors but also preserves the relative ordering among candidate second player sequences well. This suggests that the internal representations formed by the GRU are not tied to a single output objective, but instead reflect relatively stable structural regularities underlying competitive advantage in Penney’s game. In this sense, the results of discrete optimal-strategy prediction and continuous probability estimation jointly support the conclusion that the GRU can effectively capture sequence asymmetry.
Several limitations should be noted. First, in the optimal counterstrategy prediction task, the decoder predicts all positions of the response sequence in parallel from the final hidden state, and therefore does not explicitly model dependencies among output positions at the decoder level. This is a reasonable simplification for Penney’s game, where the second player selects the entire response sequence only after observing the complete first player sequence, but more general sequence prediction problems may benefit from autoregressive or other structured decoders. Second, the present study focuses on a limited range of q and k, and therefore does not directly support conclusions about larger alphabets or longer sequences. Third, although the experiments are based on synthetic random sequences, this setting is not an arbitrary substitute for real-world data, but a standard theoretical setting in Penney’s game and related studies of pattern waiting times and sequence overlaps. The controlled nature of this setting allows the optimal counterstrategy and win probability to be exactly computed, making it suitable for testing whether recurrent networks can learn analytically defined asymmetric sequence structures. Nevertheless, future work should examine whether similar overlap-sensitive representations emerge in more complex sequence data, such as Markovian, noisy, behavioral, biological, or real-world event sequences. Fourth, although the model exhibits predictive behavior consistent with Conway’s formula, this does not imply that it explicitly reconstructs the formula itself at a symbolic level. A more cautious interpretation is that the GRU learns structural regularities consistent with Conway’s formula and forms hidden representations that support asymmetric competitive judgments. Future work could combine representational similarity analysis, hidden-state projection, probing methods, and ablation experiments to provide more direct evidence about these internal mechanisms.

5. Conclusions

This study systematically investigated the learning performance of the GRU on two tasks centered on the asymmetric competitive relationships in Penney’s game: optimal counterstrategy prediction and win probability estimation. The results show that the GRU can not only recover optimal second player responses with relatively high accuracy at the discrete strategy level, but also estimate the theoretical win probabilities between arbitrary sequence pairs with high precision in the continuous regression setting while maintaining good ranking consistency.
The findings from both tasks indicate that the GRU can effectively exploit key sequence regularities jointly determined by self-overlap and mutual-overlap structures, thereby forming stable representations of asymmetric competitive relationships in Penney’s game. This suggests that recurrent neural networks do not merely fit surface-level input–output mappings, but can also capture latent structural information that supports complex sequence-based competitive advantage during supervised learning.
Future work may proceed in three directions. First, the analysis can be extended to larger alphabets and longer sequences to examine the model’s ability to cope with more complex combinatorial spaces. Second, hidden-state probing, representational similarity analysis, and visualization methods can be introduced to more directly reveal the network’s internal coding mechanisms. Third, building on the recurrent-architecture comparison reported in this study, future work can further extend the analysis to Transformer-based and hybrid recurrent–attention models. Such comparisons would help examine whether attention-based sequence modeling mechanisms capture overlap-dependent asymmetry in the same way as recurrent hidden-state dynamics, or whether they form qualitatively different representations of self-overlap and mutual-overlap structures.

Author Contributions

Conceptualization, H.L. and Y.S.; methodology, H.L. and Y.S.; software, H.L.; validation, H.L.; formal analysis, H.L.; investigation, H.L.; visualization, H.L.; writing—original draft preparation, H.L.; writing—review and editing, Y.S.; supervision, Y.S. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding. The APC was funded by the authors.

Data Availability Statement

The datasets generated and analyzed in this study were synthetically constructed by enumerating sequence configurations and computing theoretical labels using Conway’s formula, as described in Section 3.1.1 and Section 3.2.1. No external datasets were used. The data are available from the corresponding author upon reasonable request.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Song, H.F.; Yang, G.R.; Wang, X.-J. Reward-based training of recurrent neural networks for cognitive and value-based tasks. eLife 2017, 6, e21492. [Google Scholar] [CrossRef] [Scilit]
  2. Salinas, D.; Flunkert, V.; Gasthaus, J.; Januschowski, T. DeepAR: Probabilistic forecasting with autoregressive recurrent networks. Int. J. Forecast. 2020, 36, 1181–1191. [Google Scholar] [CrossRef] [Scilit]
  3. Yang, G.R.; Wang, X.-J. Artificial Neural Networks for Neuroscientists: A Primer. Neuron 2020, 107, 1048–1070. [Google Scholar] [CrossRef] [Scilit]
  4. Li, J.-A.; Benna, M.K.; Mattar, M.G. Discovering cognitive strategies with tiny recurrent neural networks. Nature 2025, 644, 993–1001. [Google Scholar] [CrossRef] [Scilit]
  5. Low, I.I.C.; Giocomo, L.M.; Williams, A.H. Remapping in a recurrent neural network model of navigation and context inference. eLife 2023, 12, RP86943. [Google Scholar] [CrossRef]
  6. Mienye, I.D.; Swart, T.G.; Obaido, G. Recurrent Neural Networks: A Comprehensive Review of Architectures, Variants, and Applications. Information 2024, 15, 517. [Google Scholar] [CrossRef] [Scilit]
  7. Soo, W.M.W. Recurrent Neural Networks in Cognitive and Vision Neuroscience. Ph.D. Thesis, Apollo—University of Cambridge Repository, Cambridge, UK, 2024. [Google Scholar] [CrossRef]
  8. Sherstinsky, A. Fundamentals of recurrent neural network (RNN) and long short-term memory (LSTM) network. Phys. D Nonlinear Phenom. 2020, 404, 132306. [Google Scholar] [CrossRef] [Scilit]
  9. Mastrogiuseppe, F.; Ostojic, S. Linking connectivity, dynamics, and computations in low-rank recurrent neural networks. Neuron 2018, 99, 609–623. [Google Scholar] [CrossRef] [Scilit]
  10. Driscoll, L.N.; Shenoy, K.; Sussillo, D. Flexible multitask computation in recurrent networks utilizes shared dynamical motifs. Nat. Neurosci. 2024, 27, 1349–1363. [Google Scholar] [CrossRef] [Scilit]
  11. Sussillo, D. Neural circuits as computational dynamical systems. Curr. Opin. Neurobiol. 2014, 25, 156–163. [Google Scholar] [CrossRef] [Scilit]
  12. Sun, Y.; Wang, H. Learning Temporal Structures of Random Patterns by Generating Functions. Am. Stat. 2021, 75, 300–309. [Google Scholar] [CrossRef] [Scilit]
  13. Liao, H.; Dong, M.; Sun, Y. Bio-Inspired Micro-RNNs Reveal the Learning Mechanism of Alternation Preference. In Proceedings of the 2025 10th International Conference on Computational Intelligence and Applications (ICCIA), Haikou, China, 15–17 August 2025; pp. 18–23. [Google Scholar]
  14. Cho, K.; Van Merriënboer, B.; Gulcehre, C.; Bahdanau, D.; Bougares, F.; Schwenk, H.; Bengio, Y. Learning phrase representations using RNN encoder-decoder for statistical machine translation. arXiv 2014, arXiv:1406.1078. [Google Scholar] [CrossRef] [Scilit]
  15. Singh, S.K.; Rawat, N.; Singh, S.; Kaur, S. Re-exploring the Penney-Ante Game. Am. Stat. 2022, 76, 177–183. [Google Scholar] [CrossRef] [Scilit]
  16. Grimmett, G.R. Alice and Bob on X: Reversal, Coupling, Renewal. Am. Math. Mon. 2025, 133, 439–451. [Google Scholar] [CrossRef] [Scilit]
  17. Basdevant, A.-L.; Hénard, O.; Maurel-Segala, É.; Singh, A. On cases where Litt’s game is fair. Comptes Rendus. Math. 2025, 363, 977–984. [Google Scholar] [CrossRef] [Scilit]
  18. Ekhad, S.B.; Zeilberger, D. How to answer questions of the type: If you toss a coin n times, how likely is HH to show up more than HT? arXiv 2024, arXiv:2405.13561. [Google Scholar] [CrossRef] [Scilit]
  19. Janson, S.; Nica, M.; Segert, S. The generalized Alice HH vs Bob HT problem. J. Theor. Probab. 2025, 38, 83. [Google Scholar] [CrossRef] [Scilit]
  20. Penney, W. Problem 95: Penney-Ante. J. Recreat. Math. 1969, 2, 241. [Google Scholar]
  21. Gardner, M. On the paradoxical situations that arise from nontransitive relations. Sci. Am. 1974, 231, 120–125. [Google Scholar] [CrossRef] [Scilit]
  22. Gardner, M. Time Travel and Other Mathematical Bewilderments; Freeman: New York, NY, USA, 1988. [Google Scholar]
  23. Li, S.; Khovanova, T. The Penney’s Game with Group Action. Ann. Comb. 2022, 26, 145–170. [Google Scholar] [CrossRef] [Scilit]
  24. Guibas, L.J.; Odlyzko, A.M. String overlaps, pattern matching, and nontransitive games. J. Comb. Theory Ser. A 1981, 30, 183–208. [Google Scholar] [CrossRef] [Scilit]
  25. Conneau, A.; Kiela, D.; Schwenk, H.; Barrault, L.; Bordes, A. Supervised Learning of Universal Sentence Representations from Natural Language Inference Data. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing; Association for Computational Linguistics: Stroudsburg, PA, USA, 2017; pp. 670–680. [Google Scholar]
  26. Reimers, N.; Gurevych, I. Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP); Association for Computational Linguistics: Stroudsburg, PA, USA, 2019; pp. 3982–3992. [Google Scholar]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.