]> Cypherpunks.ru repositories - gostls13.git/blobdiff - test/solitaire.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / solitaire.go
index c789bf24a0fc40f887412dc40dcf15f00a38dfa6..ac54cec0ac74442309535200457f5b00b0a6e71f 100644 (file)
@@ -1,9 +1,13 @@
-// $G $F.go && $L $F.$A  # don't run it - produces too much output
+// build
 
 // Copyright 2010 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// Test general operation by solving a peg solitaire game.
+// A version of this is in the Go playground.
+// Don't run it - produces too much output.
+
 // This program solves the (English) peg solitaire board game.
 // See also: http://en.wikipedia.org/wiki/Peg_solitaire
 
@@ -14,7 +18,7 @@ const N = 11 + 1 // length of a board row (+1 for newline)
 // The board must be surrounded by 2 illegal fields in each direction
 // so that move() doesn't need to check the board boundaries. Periods
 // represent illegal fields, ● are pegs, and ○ are holes.
-var board = []int(
+var board = []rune(
        `...........
 ...........
 ....●●●....
@@ -28,7 +32,6 @@ var board = []int(
 ...........
 `)
 
-
 // center is the position of the center hole if there is a single one;
 // otherwise it is -1.
 var center int
@@ -46,7 +49,6 @@ func init() {
        }
 }
 
-
 var moves int // number of times move is called
 
 // move tests if there is a peg at position pos that can jump over another peg
@@ -63,7 +65,6 @@ func move(pos, dir int) bool {
        return false
 }
 
-
 // unmove reverts a previously executed valid move.
 func unmove(pos, dir int) {
        board[pos] = '●'
@@ -71,7 +72,6 @@ func unmove(pos, dir int) {
        board[pos+2*dir] = '○'
 }
 
-
 // solve tries to find a sequence of moves such that there is only one peg left
 // at the end; if center is >= 0, that last peg must be in the center position.
 // If a solution is found, solve prints the board after each move in a backward
@@ -110,7 +110,6 @@ func solve() bool {
        return false
 }
 
-
 func main() {
        if !solve() {
                println("no solution found")