Blackjack strategy: Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: minor tidy, duplicate {{trans|Go}} removed)
m (syntax highlighting fixup automation)
Line 42: Line 42:


Finally, I've done 10 years of simulations as the basic statistics can vary quite a bit from year to year. However, it will be seen that % loss varies over a narrower range - between about 0.3 and 1.8% for this particular run - which seems reasonable given the casino's edge even after basic strategy is utilized.
Finally, I've done 10 years of simulations as the basic statistics can vary quite a bit from year to year. However, it will be seen that % loss varies over a narrower range - between about 0.3 and 1.8% for this particular run - which seems reasonable given the casino's edge even after basic strategy is utilized.
<lang go>package main
<syntaxhighlight lang=go>package main


import (
import (
Line 950: Line 950:
simulate(50, 365)
simulate(50, 365)
}
}
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 1,321: Line 1,321:
=={{header|Nim}}==
=={{header|Nim}}==
{{trans|Go}}
{{trans|Go}}
<lang Nim>import random, sequtils, strformat, strutils
<syntaxhighlight lang=Nim>import random, sequtils, strformat, strutils


type
type
Line 2,149: Line 2,149:
simulate(50, 365)
simulate(50, 365)


main()</lang>
main()</syntaxhighlight>


{{out}}
{{out}}
Line 2,517: Line 2,517:
=={{header|Phix}}==
=={{header|Phix}}==
{{trans|Go}}
{{trans|Go}}
<!--<lang Phix>-->
<!--<syntaxhighlight lang=Phix>-->
<span style="color: #000080;font-style:italic;">-- demo/rosetta/blackjack.exw</span>
<span style="color: #000080;font-style:italic;">-- demo/rosetta/blackjack.exw</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
Line 3,448: Line 3,448:
<span style="color: #0000FF;">?</span><span style="color: #008000;">"done"</span>
<span style="color: #0000FF;">?</span><span style="color: #008000;">"done"</span>
<span style="color: #0000FF;">{}</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">wait_key</span><span style="color: #0000FF;">()</span>
<span style="color: #0000FF;">{}</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">wait_key</span><span style="color: #0000FF;">()</span>
<!--</lang>-->
<!--</syntaxhighlight>-->
{{out}}
{{out}}
<pre>
<pre>
Line 3,829: Line 3,829:


So interpreted languages such as Wren are probably stuck with slow times for this task.
So interpreted languages such as Wren are probably stuck with slow times for this task.
<lang ecmascript>import "random" for Random
<syntaxhighlight lang=ecmascript>import "random" for Random
import "./array" for Array, ArrayType
import "./array" for Array, ArrayType
import "./dynamic" for Struct
import "./dynamic" for Struct
Line 4,753: Line 4,753:
}
}


Blackjack.main()</lang>
Blackjack.main()</syntaxhighlight>


{{out}}
{{out}}