Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

another confusing merge

  • Loading branch information...
commit f8f7ee250618d37dacbcda1b479bb6cf4340b896 2 parents b0f7cc3 + 8449dab
@rspeer authored
View
1  .gitignore
@@ -4,6 +4,7 @@
cards.js
gameState.js
heuristics.js
+grapher.js
geronimoo
.idea
web/grapher.js
View
13 cards.coffee
@@ -382,7 +382,7 @@ makeCard 'Nobles', c.Estate, {
{actions: 2},
{cards: 3}
])
- applyBenefit(state, benefit)
+ applyBenefit(state, benefit)
}
makeCard 'Vineyard', c.Estate, {
@@ -1624,17 +1624,6 @@ makeCard 'Tournament', action, {
state.current.drawCards(1)
}
-makeCard 'Torturer', action, {
- cost: 5
- cards: +3
- playEffect: (state) ->
- state.attackOpponents (opp) ->
- if opp.ai.choose('torturer', state, ['curse', 'discard']) == 'curse'
- state.gainCard(opp, c.Curse, 'hand')
- else
- state.requireDiscard(opp, 2)
-}
-
makeCard "Trade Route", action, {
cost: 3
buys: 1
View
2  docs/basicAI.html
@@ -197,6 +197,7 @@
<span class="s2">&quot;Library&quot;</span> <span class="k">if</span> <span class="nx">my</span><span class="p">.</span><span class="nx">hand</span><span class="p">.</span><span class="nx">length</span> <span class="o">&lt;=</span> <span class="mi">3</span>
<span class="s2">&quot;Expand&quot;</span>
<span class="s2">&quot;Remodel&quot;</span>
+ <span class="s2">&quot;Jester&quot;</span>
<span class="s2">&quot;Militia&quot;</span>
<span class="s2">&quot;Cutpurse&quot;</span>
<span class="s2">&quot;Bridge&quot;</span>
@@ -244,6 +245,7 @@
<span class="s2">&quot;Workshop&quot;</span>
<span class="s2">&quot;Smugglers&quot;</span> <span class="k">if</span> <span class="nx">state</span><span class="p">.</span><span class="nx">smugglerChoices</span><span class="p">().</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">1</span>
<span class="s2">&quot;Coppersmith&quot;</span>
+ <span class="s2">&quot;Saboteur&quot;</span>
<span class="s2">&quot;Library&quot;</span> <span class="k">if</span> <span class="nx">my</span><span class="p">.</span><span class="nx">hand</span><span class="p">.</span><span class="nx">length</span> <span class="o">&lt;=</span> <span class="mi">7</span></pre></div> </td> </tr> <tr id="section-29"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-29">&#182;</a> </div> <p>Eighth priority: cards that have become useless. Maybe they'll decrease
the cost of Peddler, trigger Conspirator, or something.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="s2">&quot;Treasure Map&quot;</span> <span class="k">if</span> <span class="nx">my</span><span class="p">.</span><span class="nx">countInDeck</span><span class="p">(</span><span class="s2">&quot;Gold&quot;</span><span class="p">)</span> <span class="o">&gt;=</span> <span class="mi">4</span> <span class="o">and</span> <span class="nx">state</span><span class="p">.</span><span class="nx">current</span><span class="p">.</span><span class="nx">countInDeck</span><span class="p">(</span><span class="s2">&quot;Treasure Map&quot;</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span>
<span class="s2">&quot;Shanty Town&quot;</span>
View
69 docs/cards.html
@@ -446,6 +446,7 @@
<span class="nx">makeCard</span> <span class="s1">&#39;Ambassador&#39;</span><span class="p">,</span> <span class="nx">action</span><span class="p">,</span> <span class="p">{</span>
<span class="nv">cost: </span><span class="mi">3</span>
+ <span class="nv">isAttack: </span><span class="kc">true</span>
<span class="nv">playEffect: </span><span class="nf">(state) -&gt;</span></pre></div> </td> </tr> <tr id="section-45"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-45">&#182;</a> </div> <p>Determine the cards and quantities that can be ambassadored</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">counts = </span><span class="p">{}</span>
<span class="k">for</span> <span class="nx">card</span> <span class="k">in</span> <span class="nx">state</span><span class="p">.</span><span class="nx">current</span><span class="p">.</span><span class="nx">hand</span>
@@ -877,6 +878,23 @@
<span class="nx">state</span><span class="p">.</span><span class="nx">current</span><span class="p">.</span><span class="nx">drawCards</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="p">}</span>
+<span class="nx">makeCard</span> <span class="s1">&#39;Jester&#39;</span><span class="p">,</span> <span class="nx">action</span><span class="p">,</span> <span class="p">{</span>
+ <span class="nv">cost: </span><span class="mi">5</span>
+ <span class="nv">coins: </span><span class="o">+</span><span class="mi">2</span>
+ <span class="nv">isAttack: </span><span class="kc">true</span>
+
+ <span class="nv">playEffect: </span><span class="nf">(state) -&gt;</span>
+ <span class="nx">state</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;#{state.current.ai} gets +$2&quot;</span><span class="p">)</span>
+ <span class="nx">state</span><span class="p">.</span><span class="nx">attackOpponents</span> <span class="nf">(opp) -&gt;</span>
+ <span class="nv">card = </span><span class="nx">state</span><span class="p">.</span><span class="nx">discardFromDeck</span><span class="p">(</span><span class="nx">opp</span><span class="p">,</span> <span class="mi">1</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
+ <span class="k">if</span> <span class="nx">card</span><span class="p">.</span><span class="nx">isVictory</span>
+ <span class="nx">state</span><span class="p">.</span><span class="nx">gainCard</span><span class="p">(</span><span class="nx">opp</span><span class="p">,</span> <span class="nx">c</span><span class="p">.</span><span class="nx">Curse</span><span class="p">)</span>
+ <span class="k">else</span> <span class="k">if</span> <span class="nx">state</span><span class="p">.</span><span class="nx">current</span><span class="p">.</span><span class="nx">ai</span><span class="p">.</span><span class="nx">chooseGain</span><span class="p">(</span><span class="nx">state</span><span class="p">,</span> <span class="p">[</span><span class="nx">card</span><span class="p">,</span> <span class="kc">null</span><span class="p">])</span>
+ <span class="nx">state</span><span class="p">.</span><span class="nx">gainCard</span><span class="p">(</span><span class="nx">state</span><span class="p">.</span><span class="nx">current</span><span class="p">,</span> <span class="nx">card</span><span class="p">)</span>
+ <span class="k">else</span>
+ <span class="nx">state</span><span class="p">.</span><span class="nx">gainCard</span><span class="p">(</span><span class="nx">opp</span><span class="p">,</span> <span class="nx">card</span><span class="p">)</span>
+<span class="p">}</span>
+
<span class="nx">makeCard</span> <span class="s1">&#39;Library&#39;</span><span class="p">,</span> <span class="nx">action</span><span class="p">,</span> <span class="p">{</span>
<span class="nv">cost: </span><span class="mi">5</span>
@@ -960,6 +978,7 @@
<span class="nx">makeCard</span> <span class="s2">&quot;Mint&quot;</span><span class="p">,</span> <span class="nx">action</span><span class="p">,</span> <span class="p">{</span>
<span class="nv">cost: </span><span class="mi">5</span>
<span class="nv">buyEffect: </span><span class="nf">(state) -&gt;</span>
+ <span class="nv">state.quarries = </span><span class="mi">0</span>
<span class="nv">inPlay = </span><span class="nx">state</span><span class="p">.</span><span class="nx">current</span><span class="p">.</span><span class="nx">inPlay</span>
<span class="k">for</span> <span class="nx">i</span> <span class="k">in</span> <span class="p">[</span><span class="nx">inPlay</span><span class="p">.</span><span class="nx">length</span><span class="o">-</span><span class="mi">1</span><span class="p">...</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
<span class="k">if</span> <span class="nx">inPlay</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">isTreasure</span>
@@ -1100,7 +1119,7 @@
<span class="nv">attackSuccess = </span><span class="kc">true</span>
<span class="nx">drawn</span><span class="p">.</span><span class="nx">remove</span><span class="p">(</span><span class="nx">treasureToTrash</span><span class="p">)</span>
<span class="nx">state</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;...#{state.current.ai} trashes #{opp.ai}&#39;s #{treasureToTrash}.&quot;</span><span class="p">)</span>
- <span class="nx">state</span><span class="p">.</span><span class="nx">current</span><span class="p">.</span><span class="nx">discard</span><span class="p">.</span><span class="nx">concat</span> <span class="p">(</span><span class="nx">drawn</span><span class="p">)</span>
+ <span class="nv">state.current.discard = </span><span class="nx">state</span><span class="p">.</span><span class="nx">current</span><span class="p">.</span><span class="nx">discard</span><span class="p">.</span><span class="nx">concat</span><span class="p">(</span><span class="nx">drawn</span><span class="p">)</span>
<span class="nx">state</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;...#{opp.ai} discards #{drawn}.&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="nx">attackSuccess</span>
@@ -1160,6 +1179,49 @@
<span class="nx">transferCardToTop</span><span class="p">(</span><span class="nx">card</span><span class="p">,</span> <span class="nx">source</span><span class="p">,</span> <span class="nx">player</span><span class="p">.</span><span class="nx">draw</span><span class="p">)</span>
<span class="p">}</span>
+<span class="nx">makeCard</span> <span class="s1">&#39;Saboteur&#39;</span><span class="p">,</span> <span class="nx">action</span><span class="p">,</span> <span class="p">{</span>
+ <span class="nv">cost: </span><span class="mi">5</span>
+ <span class="nv">isAttack: </span><span class="kc">true</span>
+
+ <span class="nv">upgradeFilter: </span><span class="nf">(state, oldCard, newCard) -&gt;</span>
+ <span class="p">[</span><span class="nx">coins1</span><span class="p">,</span> <span class="nx">potions1</span><span class="p">]</span> <span class="o">=</span> <span class="nx">oldCard</span><span class="p">.</span><span class="nx">getCost</span><span class="p">(</span><span class="nx">state</span><span class="p">)</span>
+ <span class="p">[</span><span class="nx">coins2</span><span class="p">,</span> <span class="nx">potions2</span><span class="p">]</span> <span class="o">=</span> <span class="nx">newCard</span><span class="p">.</span><span class="nx">getCost</span><span class="p">(</span><span class="nx">state</span><span class="p">)</span>
+ <span class="k">return</span> <span class="p">(</span><span class="nx">potions1</span> <span class="o">&gt;=</span> <span class="nx">potions2</span><span class="p">)</span> <span class="o">and</span> <span class="p">(</span><span class="nx">coins1</span><span class="o">-</span><span class="mi">2</span> <span class="o">&gt;=</span> <span class="nx">coins2</span><span class="p">)</span>
+
+ <span class="nv">playEffect: </span><span class="nf">(state) -&gt;</span>
+ <span class="nx">state</span><span class="p">.</span><span class="nx">attackOpponents</span> <span class="nf">(opp) -&gt;</span>
+ <span class="nv">cardsDrawn = </span><span class="mi">0</span><span class="p">;</span>
+ <span class="k">while</span> <span class="nx">cardsDrawn</span> <span class="o">&lt;</span> <span class="mi">1</span>
+ <span class="nv">drawn = </span><span class="nx">opp</span><span class="p">.</span><span class="nx">getCardsFromDeck</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
+ <span class="k">if</span> <span class="nx">drawn</span><span class="p">.</span><span class="nx">length</span> <span class="o">==</span> <span class="mi">0</span>
+ <span class="k">if</span> <span class="nx">opp</span><span class="p">.</span><span class="nx">setAside</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">0</span>
+ <span class="nx">state</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;#{opp.ai} reveals #{opp.setAside}, but has no cards costing $3 or more in the deck.&quot;</span><span class="p">)</span>
+ <span class="k">else</span>
+ <span class="nx">state</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;#{opp.ai} has no more cards in the deck.&quot;</span><span class="p">)</span>
+ <span class="k">break</span>
+ <span class="nv">card = </span><span class="nx">drawn</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
+ <span class="nv">cardCoinCost = </span><span class="nx">card</span><span class="p">.</span><span class="nx">getCost</span><span class="p">(</span><span class="nx">state</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
+ <span class="k">if</span> <span class="nx">cardCoinCost</span> <span class="o">&gt;=</span> <span class="mi">3</span>
+ <span class="nx">state</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;...#{opp.ai} reveals #{opp.setAside}, and #{card}.&quot;</span><span class="p">)</span>
+ <span class="nx">cardsDrawn</span><span class="o">++</span>
+ <span class="nv">choices = </span><span class="nx">upgradeChoices</span><span class="p">(</span><span class="nx">state</span><span class="p">,</span> <span class="nx">drawn</span><span class="p">,</span> <span class="nx">c</span><span class="p">.</span><span class="nx">Saboteur</span><span class="p">.</span><span class="nx">upgradeFilter</span><span class="p">)</span>
+ <span class="nx">choices</span><span class="p">.</span><span class="nx">push</span><span class="p">([</span><span class="nx">card</span><span class="p">,</span><span class="kc">null</span><span class="p">])</span>
+ <span class="nv">choice = </span><span class="nx">opp</span><span class="p">.</span><span class="nx">ai</span><span class="p">.</span><span class="nx">choose</span><span class="p">(</span><span class="s1">&#39;upgrade&#39;</span><span class="p">,</span> <span class="nx">state</span><span class="p">,</span> <span class="nx">choices</span><span class="p">)</span>
+ <span class="nx">drawn</span><span class="p">.</span><span class="nx">remove</span><span class="p">(</span><span class="nx">card</span><span class="p">)</span>
+ <span class="nx">state</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;...#{state.current.ai} trashes #{opp.ai}&#39;s #{card}.&quot;</span><span class="p">)</span>
+ <span class="k">if</span> <span class="nx">choice</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">isnt</span> <span class="kc">null</span>
+ <span class="p">[</span><span class="nx">oldCard</span><span class="p">,</span> <span class="nx">newCard</span><span class="p">]</span> <span class="o">=</span> <span class="nx">choice</span>
+ <span class="nx">state</span><span class="p">.</span><span class="nx">gainCard</span><span class="p">(</span><span class="nx">opp</span><span class="p">,</span> <span class="nx">newCard</span><span class="p">,</span> <span class="s1">&#39;discard&#39;</span><span class="p">,</span> <span class="kc">true</span><span class="p">)</span>
+ <span class="nx">state</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;...#{opp.ai} gains #{newCard}.&quot;</span><span class="p">)</span>
+ <span class="k">else</span>
+ <span class="nx">state</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;...#{opp.ai} gains nothing.&quot;</span><span class="p">)</span>
+ <span class="k">else</span>
+ <span class="nx">opp</span><span class="p">.</span><span class="nx">setAside</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">card</span><span class="p">)</span>
+ <span class="nx">state</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;...#{opp.ai} discards #{opp.setAside}&quot;</span><span class="p">)</span>
+ <span class="nv">opp.discard = </span><span class="nx">opp</span><span class="p">.</span><span class="nx">discard</span><span class="p">.</span><span class="nx">concat</span><span class="p">(</span><span class="nx">opp</span><span class="p">.</span><span class="nx">setAside</span><span class="p">)</span>
+ <span class="nv">opp.setAside = </span><span class="p">[]</span>
+<span class="p">}</span>
+
<span class="nx">makeCard</span> <span class="s1">&#39;Scout&#39;</span><span class="p">,</span> <span class="nx">action</span><span class="p">,</span> <span class="p">{</span>
<span class="nv">cost: </span><span class="mi">4</span>
<span class="nv">actions: </span><span class="o">+</span><span class="mi">1</span>
@@ -1237,7 +1299,7 @@
<span class="k">if</span> <span class="nx">cardToGain</span>
<span class="nx">state</span><span class="p">.</span><span class="nx">gainCard</span><span class="p">(</span><span class="nx">state</span><span class="p">.</span><span class="nx">current</span><span class="p">,</span> <span class="nx">cardToGain</span><span class="p">,</span> <span class="s1">&#39;discard&#39;</span><span class="p">,</span> <span class="kc">true</span><span class="p">)</span>
<span class="nx">state</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;...#{state.current.ai} gains the trashed #{treasureToTrash}.&quot;</span><span class="p">)</span>
- <span class="nx">state</span><span class="p">.</span><span class="nx">current</span><span class="p">.</span><span class="nx">discard</span><span class="p">.</span><span class="nx">concat</span> <span class="p">(</span><span class="nx">drawn</span><span class="p">)</span>
+ <span class="nv">state.current.discard = </span><span class="nx">state</span><span class="p">.</span><span class="nx">current</span><span class="p">.</span><span class="nx">discard</span><span class="p">.</span><span class="nx">concat</span><span class="p">(</span><span class="nx">drawn</span><span class="p">)</span>
<span class="nx">state</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;...#{opp.ai} discards #{drawn}.&quot;</span><span class="p">)</span>
<span class="p">}</span>
@@ -1563,7 +1625,8 @@
<span class="k">for</span> <span class="nx">cardname2</span> <span class="k">of</span> <span class="nx">state</span><span class="p">.</span><span class="nx">supply</span>
<span class="nv">card2 = </span><span class="nx">c</span><span class="p">[</span><span class="nx">cardname2</span><span class="p">]</span>
<span class="k">if</span> <span class="nx">filter</span><span class="p">(</span><span class="nx">state</span><span class="p">,</span> <span class="nx">card</span><span class="p">,</span> <span class="nx">card2</span><span class="p">)</span> <span class="o">and</span> <span class="nx">state</span><span class="p">.</span><span class="nx">supply</span><span class="p">[</span><span class="nx">card2</span><span class="p">]</span> <span class="o">&gt;</span> <span class="mi">0</span>
- <span class="nx">choices</span><span class="p">.</span><span class="nx">push</span><span class="p">([</span><span class="nx">card</span><span class="p">,</span> <span class="nx">card2</span><span class="p">])</span>
+ <span class="k">if</span> <span class="o">not</span> <span class="nx">card2</span><span class="p">.</span><span class="nx">isPrize</span>
+ <span class="nx">choices</span><span class="p">.</span><span class="nx">push</span><span class="p">([</span><span class="nx">card</span><span class="p">,</span> <span class="nx">card2</span><span class="p">])</span>
<span class="k">return</span> <span class="nx">choices</span></pre></div> </td> </tr> <tr id="section-79"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-79">&#182;</a> </div> <p>Export functions that are needed elsewhere.</p> </td> <td class="code"> <div class="highlight"><pre><span class="k">this</span><span class="p">.</span><span class="nv">transferCard = </span><span class="nx">transferCard</span>
<span class="k">this</span><span class="p">.</span><span class="nv">transferCardToTop = </span><span class="nx">transferCardToTop</span>
View
9 docs/gameState.html
@@ -1,6 +1,5 @@
<!DOCTYPE html> <html> <head> <title>gameState.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="basicAI.html"> basicAI.coffee </a> <a class="source" href="cards.html"> cards.coffee </a> <a class="source" href="compileStrategies.html"> compileStrategies.coffee </a> <a class="source" href="gameState.html"> gameState.coffee </a> <a class="source" href="heuristics.html"> heuristics.coffee </a> <a class="source" href="play.html"> play.coffee </a> <a class="source" href="playWeb.html"> playWeb.coffee </a> <a class="source" href="testSimulation.html"> testSimulation.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> gameState.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> <p>This "indecisive import" pattern is messy but it gets the job done, and it's
-explained at the bottom of this documentation.</p> </td> <td class="code"> <div class="highlight"><pre><span class="p">{</span><span class="nx">c</span><span class="p">,</span><span class="nx">transferCard</span><span class="p">,</span><span class="nx">transferCardToTop</span><span class="p">}</span> <span class="o">=</span> <span class="nx">require</span> <span class="s1">&#39;./cards&#39;</span> <span class="k">if</span> <span class="nx">exports</span><span class="o">?</span>
-<span class="p">{</span><span class="nx">BasicAI</span><span class="p">}</span> <span class="o">=</span> <span class="nx">require</span> <span class="s1">&#39;./basicAI&#39;</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h2>The PlayerState class</h2>
+explained at the bottom of this documentation.</p> </td> <td class="code"> <div class="highlight"><pre><span class="p">{</span><span class="nx">c</span><span class="p">,</span><span class="nx">transferCard</span><span class="p">,</span><span class="nx">transferCardToTop</span><span class="p">}</span> <span class="o">=</span> <span class="nx">require</span> <span class="s1">&#39;./cards&#39;</span> <span class="k">if</span> <span class="nx">exports</span><span class="o">?</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h2>The PlayerState class</h2>
<p>A PlayerState stores the part of the game state
that is specific to each player, plus what AI is making the decisions.</p> </td> <td class="code"> <div class="highlight"><pre><span class="k">class</span> <span class="nx">PlayerState</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>At the start of the game, the State should
@@ -758,10 +757,8 @@
<span class="nv">state.depth = </span><span class="k">this</span><span class="p">.</span><span class="nx">depth</span> <span class="o">+</span> <span class="mi">1</span>
<span class="nv">my = </span><span class="kc">null</span>
<span class="k">for</span> <span class="nx">player</span> <span class="k">in</span> <span class="nx">state</span><span class="p">.</span><span class="nx">players</span>
- <span class="k">if</span> <span class="nx">player</span><span class="p">.</span><span class="nx">ai</span> <span class="o">isnt</span> <span class="nx">ai</span></pre></div> </td> </tr> <tr id="section-116"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-116">&#182;</a> </div> <p>Leave the AI alone for now; something goes weirdly wrong otherwise.
-Yes, this means we're technically reading their strategy.</p>
-
-<p>We don't know what's in their hand or their deck, so shuffle them
+ <span class="k">if</span> <span class="nx">player</span><span class="p">.</span><span class="nx">ai</span> <span class="o">isnt</span> <span class="nx">ai</span>
+ <span class="nv">player.ai = </span><span class="nx">ai</span><span class="p">.</span><span class="nx">copy</span><span class="p">()</span></pre></div> </td> </tr> <tr id="section-116"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-116">&#182;</a> </div> <p>We don't know what's in their hand or their deck, so shuffle them
together randomly, preserving the number of cards.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">handSize = </span><span class="nx">player</span><span class="p">.</span><span class="nx">hand</span><span class="p">.</span><span class="nx">length</span>
<span class="nv">combined = </span><span class="nx">player</span><span class="p">.</span><span class="nx">hand</span><span class="p">.</span><span class="nx">concat</span><span class="p">(</span><span class="nx">player</span><span class="p">.</span><span class="nx">draw</span><span class="p">)</span>
<span class="nx">shuffle</span><span class="p">(</span><span class="nx">combined</span><span class="p">)</span>
View
7 docs/playWeb.html
@@ -25,7 +25,8 @@
<span class="nv">playGame = </span><span class="nf">(strategies, options, ret) -&gt;</span>
<span class="nv">ais = </span><span class="p">(</span><span class="nx">makeStrategy</span><span class="p">(</span><span class="nx">item</span><span class="p">)</span> <span class="k">for</span> <span class="nx">item</span> <span class="k">in</span> <span class="nx">strategies</span><span class="p">)</span>
</pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>Take note of the player names, in order, while they're
-still in this order.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nb">window</span><span class="p">.</span><span class="nx">tracker</span><span class="p">.</span><span class="nx">setPlayers</span><span class="p">(</span><span class="nx">ai</span><span class="p">.</span><span class="nx">name</span> <span class="k">for</span> <span class="nx">ai</span> <span class="k">in</span> <span class="nx">ais</span><span class="p">)</span>
+still in this order.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">options</span><span class="p">.</span><span class="nx">tracker</span><span class="p">.</span><span class="nx">setPlayers</span><span class="p">(</span><span class="nx">ai</span><span class="p">.</span><span class="nx">name</span> <span class="k">for</span> <span class="nx">ai</span> <span class="k">in</span> <span class="nx">ais</span><span class="p">)</span>
+ <span class="nx">options</span><span class="p">.</span><span class="nx">grapher</span><span class="p">.</span><span class="nx">setPlayers</span><span class="p">(</span><span class="nx">ai</span><span class="p">.</span><span class="nx">name</span> <span class="k">for</span> <span class="nx">ai</span> <span class="k">in</span> <span class="nx">ais</span><span class="p">)</span>
</pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Handle options from the checkboxes on the page.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">colonies</span>
<span class="nv">tableau = </span><span class="nx">tableaux</span><span class="p">.</span><span class="nx">all</span>
<span class="k">else</span>
@@ -43,6 +44,10 @@
<span class="k">else</span>
<span class="k">try</span>
<span class="nx">state</span><span class="p">.</span><span class="nx">doPlay</span><span class="p">()</span>
+ <span class="k">if</span> <span class="nx">state</span><span class="p">.</span><span class="nx">phase</span> <span class="o">==</span> <span class="s1">&#39;buy&#39;</span> <span class="o">and</span> <span class="p">(</span><span class="o">not</span> <span class="nx">state</span><span class="p">.</span><span class="nx">extraturn</span><span class="p">)</span> <span class="o">and</span> <span class="nx">options</span><span class="p">.</span><span class="nx">grapher</span><span class="o">?</span>
+ <span class="nx">options</span><span class="p">.</span><span class="nx">grapher</span><span class="p">.</span><span class="nx">recordMoney</span><span class="p">(</span><span class="nx">state</span><span class="p">.</span><span class="nx">current</span><span class="p">.</span><span class="nx">ai</span><span class="p">.</span><span class="nx">name</span><span class="p">,</span> <span class="nx">state</span><span class="p">.</span><span class="nx">current</span><span class="p">.</span><span class="nx">turnsTaken</span><span class="p">,</span> <span class="nx">state</span><span class="p">.</span><span class="nx">current</span><span class="p">.</span><span class="nx">coins</span><span class="p">)</span>
+ <span class="k">if</span> <span class="nx">state</span><span class="p">.</span><span class="nx">phase</span> <span class="o">==</span> <span class="s1">&#39;cleanup&#39;</span> <span class="o">and</span> <span class="p">(</span><span class="o">not</span> <span class="nx">state</span><span class="p">.</span><span class="nx">extraturn</span><span class="p">)</span> <span class="o">and</span> <span class="nx">options</span><span class="p">.</span><span class="nx">grapher</span><span class="o">?</span>
+ <span class="nx">options</span><span class="p">.</span><span class="nx">grapher</span><span class="p">.</span><span class="nx">recordVP</span><span class="p">(</span><span class="nx">state</span><span class="p">.</span><span class="nx">current</span><span class="p">.</span><span class="nx">ai</span><span class="p">.</span><span class="nx">name</span><span class="p">,</span> <span class="nx">state</span><span class="p">.</span><span class="nx">current</span><span class="p">.</span><span class="nx">turnsTaken</span><span class="p">,</span> <span class="nx">state</span><span class="p">.</span><span class="nx">current</span><span class="p">.</span><span class="nx">getVP</span><span class="p">(</span><span class="nx">state</span><span class="p">))</span>
<span class="nb">window</span><span class="p">.</span><span class="nx">setZeroTimeout</span> <span class="o">-&gt;</span> <span class="nx">playStep</span><span class="p">(</span><span class="nx">state</span><span class="p">,</span> <span class="nx">options</span><span class="p">,</span> <span class="nx">ret</span><span class="p">)</span>
<span class="k">catch</span> <span class="nx">err</span>
<span class="nv">errorHandler = </span><span class="nx">options</span><span class="p">.</span><span class="nx">errorHandler</span> <span class="o">?</span> <span class="p">(</span><span class="nx">alert</span> <span class="o">?</span> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">)</span>
Please sign in to comment.
Something went wrong with that request. Please try again.