Hexapawn: Difference between revisions

m
m (→‎{{header|Wren}}: Minor tidy)
 
(One intermediate revision by one other user not shown)
Line 21:
However, unlike the paper this does ''not'' handle mirror games as the same.
I.e. this implementation will need to learn how to respond to white's opening "3 6" move independently from the mirror white opening move of "1 4".
<langsyntaxhighlight lang="go">package main
 
import (
Line 269:
}
return black
}</langsyntaxhighlight>
{{out|Sample Output}}
<pre>
Line 301:
=={{header|JavaScript}}==
You can try it [http://paulo-jorente.de/tests/hexapawn/ here].
<langsyntaxhighlight lang="javascript">
var board, playBtn, turn, memory = [], lastMove = {brd: "", mvi: 0},
clicks = {first: null, second: null}, win = {c: 0, p: 0}, score;
Line 504:
restart();
}
</syntaxhighlight>
</lang>
HTML (testing)
<pre><!DOCTYPE html>
Line 528:
Graphical versions, using Gtk. Unicode has chess symbols! See https://www.compart.com/en/unicode/block/U+2600.
===Learning Version===
<langsyntaxhighlight lang="julia">using Gtk, Base
 
const whitepawn = UInt8('w')
Line 747:
 
hexapawnapp()
</syntaxhighlight>
</lang>
===Pretaught Version===
Unlike full chess, the play here is simple enough to specify perfectly played games with just a 17 move table and one-move lookahead.
<langsyntaxhighlight lang="julia">using Gtk, Base
 
const whitepawn = UInt8('w')
Line 972:
 
hexapawnapp()
</syntaxhighlight>
</lang>
 
=={{header|Pascal}}==
Line 985:
One reason for writing this programme was to support an essay I had planned on the difference between thinking and computation. For instance, for some board shapes it is apparent (via thinking) that the forced winner is known, even obvious, without playing any game. But, via computation, the programme attains this only via slogging through the computation.
===Source===
<syntaxhighlight lang="pascal">
<lang Pascal>
{$N- No serious use of floating-point stuff.}
{$B- Early and safe resolution of If x <> 0 and 1/x...}
Line 3,727:
end;
END.
</syntaxhighlight>
</lang>
===Some results===
It is called Pawnplex because it is not for just a three by three board. Invoke from the command line with <code>Pawnplex.exe ?</code> to obtain a description or <code>Pawnplex.exe 3</code> to run for the original 3×3 problem. A windows interface may allow the specification of parameters to a run (say via a "shortcut") but otherwise, ... open a DOS window... As for one player or the other having a winning strategy, some partial results are shown in the following:
Line 3,765:
=={{header|Perl}}==
Plays in a Tk GUI. Has both trainer capability and variable size boards.
<langsyntaxhighlight lang="perl">#!/usr/bin/perl
 
use strict; # https://rosettacode.org/wiki/Hexapawn
Line 3,936:
}
}
}</langsyntaxhighlight>
 
=={{header|Phix}}==
Line 3,945:
Displays full training data (for black and white), and last game history.
Mouse-operated: Hover on an appropriate sector of one of your pieces until an arrow shows, and click.
<langsyntaxhighlight Phixlang="phix">-- demo\rosetta\hexapawn.exw
include pGUI.e
 
Line 4,453:
end procedure
main()</langsyntaxhighlight>
There is also a straightforward translation of Go in demo\rosetta\heaxpawn_go.exw if anyone is interested...
 
Line 4,459:
El código es de Matt Hughes - https://github.com/mch/hexapawn
Yo solo lo transcribo.
<langsyntaxhighlight lang="python">
#!/usr/bin/env python3
import sys
Line 4,625:
 
play_game(get_human_move, get_human_move)
</syntaxhighlight>
</lang>
 
=={{header|Wren}}==
Line 4,632:
{{libheader|Wren-str}}
Tweaked a little - allows input in either lower or upper case and always draws final board position.
<langsyntaxhighlight ecmascriptlang="wren">import "./ioutil" for Input, Output
import "./str" for Str
 
var blackPawn = " \u265f "
Line 4,792:
}
 
playGame.call(getHumanMove, getHumanMove)</langsyntaxhighlight>
 
{{out}}
9,479

edits