| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
The Atari Go program with a terminal-based interface.
Disclaimer: this program was written directly on an Android smartphone with the AnGoIde IDE.
$ go get github.com/thewizardplusplus/go-atari-cli/...
$ go-atari-cli -h | -help | --help $ go-atari-cli [options]
Options:
ascii.DecodeColor():
package main
import (
"fmt"
"github.com/thewizardplusplus/go-atari-cli/encoding/ascii"
)
func main() {
color, _ := ascii.DecodeColor("white")
fmt.Printf("%v\n", color)
// Output: 1
}ascii.EncodeColor():
package main
import (
"fmt"
"github.com/thewizardplusplus/go-atari-cli/encoding/ascii"
models "github.com/thewizardplusplus/go-atari-models"
)
func main() {
color := ascii.EncodeColor(models.White)
fmt.Printf("%v\n", color)
// Output: white
}ascii.StoneStorageEncoder.EncodeStoneStorage():
package main
import (
"fmt"
"github.com/thewizardplusplus/go-atari-cli/encoding/ascii"
models "github.com/thewizardplusplus/go-atari-models"
"github.com/thewizardplusplus/go-atari-models/encoding/sgf"
)
func main() {
stoneEncoder := func(color models.Color) string {
return string(sgf.EncodeColor(color))
}
placeholders := ascii.Placeholders{
Crosshairs: "+",
}
// +-+-+-+-+-+
// | | | | | |
// +-+-+-+-+-+
// | |B|W| | |
// +-+-+-+-+-+
// |B|W| |W| |
// +-+-+-+-+-+
// | |B|W| | |
// +-+-+-+-+-+
// | | | | | |
// +-+-+-+-+-+
board := models.NewBoard(models.Size{Width: 5, Height: 5})
for _, move := range []models.Move{
{Color: models.Black, Point: models.Point{Column: 1, Row: 1}},
{Color: models.White, Point: models.Point{Column: 2, Row: 1}},
{Color: models.Black, Point: models.Point{Column: 0, Row: 2}},
{Color: models.White, Point: models.Point{Column: 1, Row: 2}},
{Color: models.White, Point: models.Point{Column: 3, Row: 2}},
{Color: models.Black, Point: models.Point{Column: 1, Row: 3}},
{Color: models.White, Point: models.Point{Column: 2, Row: 3}},
} {
board = board.ApplyMove(move)
}
boardEncoder :=
ascii.NewStoneStorageEncoder(stoneEncoder, placeholders, ascii.Margins{}, 1)
fmt.Printf("%v\n", boardEncoder.EncodeStoneStorage(board))
// Output:
// e+++++
// d+BW++
// cBW+W+
// b+BW++
// a+++++
// abcde
}ascii.StoneStorageEncoder.EncodeStoneStorage() with margins:
package main
import (
"fmt"
"github.com/thewizardplusplus/go-atari-cli/encoding/ascii"
models "github.com/thewizardplusplus/go-atari-models"
"github.com/thewizardplusplus/go-atari-models/encoding/sgf"
)
func main() {
stoneEncoder := func(color models.Color) string {
return string(sgf.EncodeColor(color))
}
placeholders := ascii.Placeholders{
HorizontalLine: " ",
Crosshairs: "+",
}
margins := ascii.Margins{
Stone: ascii.StoneMargins{
HorizontalMargins: ascii.HorizontalMargins{
Left: 1,
},
},
Legend: ascii.LegendMargins{
Row: ascii.HorizontalMargins{
Right: 1,
},
},
}
// +-+-+-+-+-+
// | | | | | |
// +-+-+-+-+-+
// | |B|W| | |
// +-+-+-+-+-+
// |B|W| |W| |
// +-+-+-+-+-+
// | |B|W| | |
// +-+-+-+-+-+
// | | | | | |
// +-+-+-+-+-+
board := models.NewBoard(models.Size{Width: 5, Height: 5})
for _, move := range []models.Move{
{Color: models.Black, Point: models.Point{Column: 1, Row: 1}},
{Color: models.White, Point: models.Point{Column: 2, Row: 1}},
{Color: models.Black, Point: models.Point{Column: 0, Row: 2}},
{Color: models.White, Point: models.Point{Column: 1, Row: 2}},
{Color: models.White, Point: models.Point{Column: 3, Row: 2}},
{Color: models.Black, Point: models.Point{Column: 1, Row: 3}},
{Color: models.White, Point: models.Point{Column: 2, Row: 3}},
} {
board = board.ApplyMove(move)
}
boardEncoder :=
ascii.NewStoneStorageEncoder(stoneEncoder, placeholders, margins, 1)
fmt.Printf("%v\n", boardEncoder.EncodeStoneStorage(board))
// Output:
// e + + + + +
// d + B W + +
// c B W + W +
// b + B W + +
// a + + + + +
// a b c d e
}ascii.StoneStorageEncoder.EncodeStoneStorage() with a grid:
package main
import (
"fmt"
"github.com/thewizardplusplus/go-atari-cli/encoding/ascii"
models "github.com/thewizardplusplus/go-atari-models"
"github.com/thewizardplusplus/go-atari-models/encoding/sgf"
)
func main() {
stoneEncoder := func(color models.Color) string {
return string(sgf.EncodeColor(color))
}
placeholders := ascii.Placeholders{
HorizontalLine: "-",
VerticalLine: "|",
Crosshairs: "+",
}
margins := ascii.Margins{
Stone: ascii.StoneMargins{
HorizontalMargins: ascii.HorizontalMargins{
Left: 1,
},
VerticalMargins: ascii.VerticalMargins{
Bottom: 1,
},
},
Legend: ascii.LegendMargins{
Row: ascii.HorizontalMargins{
Right: 1,
},
},
}
// +-+-+-+-+-+
// | | | | | |
// +-+-+-+-+-+
// | |B|W| | |
// +-+-+-+-+-+
// |B|W| |W| |
// +-+-+-+-+-+
// | |B|W| | |
// +-+-+-+-+-+
// | | | | | |
// +-+-+-+-+-+
board := models.NewBoard(models.Size{Width: 5, Height: 5})
for _, move := range []models.Move{
{Color: models.Black, Point: models.Point{Column: 1, Row: 1}},
{Color: models.White, Point: models.Point{Column: 2, Row: 1}},
{Color: models.Black, Point: models.Point{Column: 0, Row: 2}},
{Color: models.White, Point: models.Point{Column: 1, Row: 2}},
{Color: models.White, Point: models.Point{Column: 3, Row: 2}},
{Color: models.Black, Point: models.Point{Column: 1, Row: 3}},
{Color: models.White, Point: models.Point{Column: 2, Row: 3}},
} {
board = board.ApplyMove(move)
}
boardEncoder :=
ascii.NewStoneStorageEncoder(stoneEncoder, placeholders, margins, 1)
fmt.Printf("%v\n", boardEncoder.EncodeStoneStorage(board))
// Output:
// e -+-+-+-+-+
// | | | | |
// d -+-B-W-+-+
// | | | | |
// c -B-W-+-W-+
// | | | | |
// b -+-B-W-+-+
// | | | | |
// a -+-+-+-+-+
// | | | | |
// a b c d e
}unicode.EncodeStone():
package main
import (
"fmt"
"github.com/thewizardplusplus/go-atari-cli/encoding/unicode"
models "github.com/thewizardplusplus/go-atari-models"
)
func main() {
stone := unicode.EncodeStone(models.White)
fmt.Printf("%v\n", stone)
// Output: ○
}The MIT License (MIT)
Copyright © 2020 thewizardplusplus
| Back | FazBrowse Home | New Git URL |