# A Rule-Based AI Method for an Agent Playing Big Two
## 3 Proposed Method
### Rules for the Agent, If Not in Control
1: class-D valid combinations \(\mathbf{CO_{\textit{DV}}}\leftarrow\left\lvert\mathbf{x}\right\rvert\) for all \(\mathbf{x}\in\mathbf{CO_{D}}\) if \(\mathbf{x}\in\mathbf{CO_{\textit{pm}}}\)
2: class-C valid combinations \(\mathbf{CO_{\textit{cv}}}\leftarrow\left\lvert\mathbf{x}\right\rvert\) for all \(\mathbf{x}\in\mathbf{CO_{\textit{cv}}}\) if \(\mathbf{CO_{\textit{pm}}}\)
3: class-B valid combinations \(\mathbf{CO_{\textit{cv}}}\leftarrow\left\lvert\mathbf{x}\right\rvert\) for all \(\mathbf{x}\in\mathbf{CO_{\textit{cv}}}\) if \(\mathbf{CO_{\textit{pm}}}\)
4: class-A valid combinations \(\mathbf{CO_{\textit{AV}}}\leftarrow\left\lvert\mathbf{x}\right\rvert\) for all \(\mathbf{x}\in\mathbf{CO_{\textit{AV}}}\)
5:if\(\mathbf{CO_{\textit{vc}}}\) is not empty:
6: for all \(\mathbf{CO_{\textit{vc}}}\) in \(\mathbf{CO_{\textit{DV}}}\):
7: if not hold-back (\(\mathbf{C_{\textit{ac}}}\), \(\mathbf{CO_{\textit{f}}}\), \(\mathbf{CO_{\textit{A}}}\), \(\mathbf{CO_{\textit{B}}}\), \(\mathbf{CO_{\textit{C}}}\), \(\mathbf{CO_{\textit{D}}}\), \(t\), \(\mathbf{O_{\textit{1}}}\), \(\mathbf{O_{\textit{2}}}\), \(\mathbf{O_{3}}\), \(\mathbf{CO_{\textit{sv}}}\)): return \(\mathbf{CO_{\textit{sc}}}\)
8:if\(\mathbf{CO_{\textit{vc}}}\) is not empty:
9: for all \(\mathbf{CO_{\textit{vc}}}\) in \(\mathbf{CO_{\textit{BV}}}\):
10: if not hold-back (\(\mathbf{C_{\textit{ac}}}\), \(\mathbf{CO_{\textit{f}}}\), \(\mathbf{CO_{\textit{A}}}\), \(\mathbf{CO_{\textit{B}}}\), \(\mathbf{CO_{\textit{C}}}\), \(\mathbf{CO_{\textit{D}}}\), \(t\), \(\mathbf{O_{\textit{1}}}\), \(\mathbf{O_{\textit{2}}}\), \(\mathbf{O_{\textit{3}}}\), \(\mathbf{CO_{\textit{sv}}}\)): return \(\mathbf{CO_{\textit{sc}}}\)
11:if\(\mathbf{CO_{\textit{vc}}}\) is not empty:
12: for all \(\mathbf{CO_{\textit{vc}}}\) in \(\mathbf{CO_{\textit{BV}}}\):
13: if not hold-back (\(\mathbf{C_{\textit{ac}}}\), \(\mathbf{CO_{\textit{f}}}\), \(\mathbf{CO_{\textit{A}}}\), \(\mathbf{CO_{\textit{B}}}\), \(\mathbf{CO_{\textit{C}}}\), \(\mathbf{CO_{\textit{D}}}\), \(t\), \(\mathbf{O_{\textit{1}}}\), \(\mathbf{O_{\textit{2}}}\), \(\mathbf{O_{\textit{3}}}\), \(\mathbf{CO_{\textit{sv}}}\)): return \(\mathbf{CO_{\textit{sc}}}\)
14:if\(\mathbf{CO_{\textit{vc}}}\) is not empty:
15:for all \(\mathbf{CO_{\textit{vc}}}\) in \(\mathbf{CO_{\textit{AV}}}\):
16: if not hold-back (\(\mathbf{C_{\textit{ac}}}\), \(\mathbf{CO_{\textit{f}}}\), \(\mathbf{CO_{\textit{A}}}\), \(\mathbf{CO_{\textit{B}}}\), \(\mathbf{CO_{\textit{C}}}\), \(\mathbf{CO_{\textit{D}}}\), \(t\), \(\mathbf{O_{\textit{1}}}\), \(\mathbf{O_{\textit{2}}}\), \(\mathbf{O_{\textit{3}}}\), \(\mathbf{CO_{\textit{sv}}}\)): return \(\mathbf{CO_{\textit{sc}}}\)
17:if length (opponent's card) == 1:
18: return split-card (\(\mathbf{C_{\textit{ac}}}\), \(\mathbf{CO_{\textit{pm}}}\), single, pair, five-card, \(\mathbf{O_{\textit{1}}}\), \(\mathbf{O_{\textit{2}}}\), \(\mathbf{O_{\textit{3}}}\))
19:else: return [\"Pass\"]
```  
**Output:** a selected card combination (\(\mathbf{CO_{\textit{av}}}\)) that the agent will discard or Pass. **Algorithm 7** Rules for the agent, if not in control  
The hold-back function (Algorithm 8) consists of three possible combinations based on the type of combination just played: a single card (lines 1-6), a pair (lines 8-12), and a five-card combination (lines 13-19). When the selected combination is a single card, lines 1-6 determine whether to hold based on the following conditions: (1) if the agent's hand contains two cards at most, then the agent discards the selected card; (2) if an opponent has fewer than three cards left, then the agent discards the selected card; (3) if class-A combination has fewer card combinations than all other classes combined or if all opponents have at least six cards, the highest single card (card index \(-1\)) will be held to retain value in the agent's hand. In most cases, discarding the highest single during the early game, especially a non-class-A card, has no purpose, because opponents can easily discard a higher single.