diff --git a/.gitignore b/.gitignore
index cf485c6..ac291c5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,5 +20,5 @@ games/*.pgn
games/archive/*.pgn
.env
dist/*
-configs/chesspal.dev.yaml
+configs/chesspal.*.yaml
github_token
\ No newline at end of file
diff --git a/README.md b/README.md
index ed2723a..88e8aae 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
# Chesspal
-Chesspal is a responsive web server for [USB DGT e-Boards](https://digitalgametechnology.com/products/home-use-e-boards). Its core features are to record chess games and play against configurable AIs.
+Chesspal is a responsive webserver for [USB DGT e-Boards](https://digitalgametechnology.com/products/home-use-e-boards). Its core features are to record chess games and play against configurable AIs.
Special thanks to:
- @notnil ([https://github.com/notnil/chess](https://github.com/notnil/chess)) for an amazing golang based chess package that is used as a basis
@@ -53,7 +53,7 @@ make release
## Raspberry pi setup
The makefile ships with targets to easily setup a fresh Raspian installation. However, the arm binaries can be used for manual installation as well.
-To setup a fresh Raspberry pi using makefile targets, add a `.env` based on `.env.example`. A working `golang` and `npm` setup is required. Then you can run the following commands:
+To setup a fresh Raspberry pi using makefile targets, add a `.env` based on `.env.example`. Further, create a config file `configs/chesspal.raspi.yaml`. A working `golang` and `npm` setup is required. Then you can run the following commands:
```bash
make release # to generate a new release bundle locally
diff --git a/cmd/chesspal/main.go b/cmd/chesspal/main.go
index 39f6f23..ab3bce2 100644
--- a/cmd/chesspal/main.go
+++ b/cmd/chesspal/main.go
@@ -52,8 +52,8 @@ type StartOptions struct {
}
type Player struct {
- Name string `json:"name"`
- Type int `json:"type"`
+ IsHuman bool `json:"isHuman"`
+ Type int `json:"type"`
}
type Config struct {
@@ -64,10 +64,14 @@ type Config struct {
DgtPort string `yaml:"dgtPort"`
Engines map[string]string `yaml:"engines"`
Bots []player.BotOptions `yaml:"bots"`
+ Humans []Human `yaml:"humans"`
Eval Eval `yaml:"eval"`
RClone Rclone `yaml:"rclone"`
}
+type Human struct {
+ Name string `yaml:"name" json:"name"`
+}
type Rclone struct {
Remote string `yaml:"remote"`
Games bool `yaml:"games"`
@@ -88,7 +92,8 @@ var engine *player.DGTEngine
var currentBoard chess.Board
type WSResponse struct {
- Bots []player.BotOptions `json:"bots"`
+ Bots []player.BotOptions `json:"bots"`
+ Humans []Human `json:"humans"`
}
type GameHistory struct {
@@ -237,7 +242,7 @@ func main() {
}
defer ws.Close()
- if err := ws.WriteJSON(WSResponse{Bots: config.Bots}); !errors.Is(err, nil) {
+ if err := ws.WriteJSON(WSResponse{Bots: config.Bots, Humans: config.Humans}); !errors.Is(err, nil) {
log.Printf("error occurred: %v", err)
}
@@ -355,19 +360,25 @@ func startGame(msg *Message, ui *ui.WSUI, cfg Config, ws *websocket.Conn) {
engine.Reset()
engine.SetUpsideDown(msg.Options.UpsideDown)
+ log.Printf("Black: %+v, White: %+v", msg.Options.Black, msg.Options.White)
+
var white, black game.Player
- if msg.Options.Black.Type == 0 {
- black = player.NewDGTPlayer(msg.Options.Black.Name, engine)
+ if msg.Options.Black.IsHuman {
+ i := msg.Options.Black.Type
+ human := cfg.Humans[i]
+ black = player.NewDGTPlayer(human.Name, engine)
} else {
- i := msg.Options.Black.Type - 1
+ i := msg.Options.Black.Type
options := cfg.Bots[i]
options.Path = cfg.Engines[options.Engine]
black = player.NewUCIPlayer(options)
}
- if msg.Options.White.Type == 0 {
- white = player.NewDGTPlayer(msg.Options.White.Name, engine)
+ if msg.Options.White.IsHuman {
+ i := msg.Options.White.Type
+ human := cfg.Humans[i]
+ white = player.NewDGTPlayer(human.Name, engine)
} else {
- i := msg.Options.White.Type - 1
+ i := msg.Options.White.Type
options := cfg.Bots[i]
options.Path = cfg.Engines[options.Engine]
white = player.NewUCIPlayer(options)
diff --git a/configs/chesspal.yaml b/configs/chesspal.yaml
index 829aaf1..5212cfa 100644
--- a/configs/chesspal.yaml
+++ b/configs/chesspal.yaml
@@ -8,6 +8,9 @@ rclone:
engines:
stockfish_12: /usr/games/stockfish
fairy_stockfish: usr/local/bin/stockfish
+humans:
+ - name: White
+ - name: Black
bots:
- name: Adrian (fairy 400)
engine: fairy_stockfish
diff --git a/makefile b/makefile
index c918890..498f1b7 100644
--- a/makefile
+++ b/makefile
@@ -35,15 +35,16 @@ raspi-install-chesspal:
&& mkdir ~/chesspal \
&& mkdir -p ~/games/archive \
&& tar -xf /tmp/$(ARM_RELEASE) -C ~/chesspal \
- && sudo update-rc.d $(INIT_SCRIPT) defaults \
- && sudo shutdown -r 0")
+ && sudo update-rc.d $(INIT_SCRIPT) defaults")
+ $(call ssh-copy,configs/chesspal.raspi.yaml,/home/pi/chesspal/configs/chesspal.yaml)
+ $(call ssh-cmd,"sudo shutdown -r 0")
raspi-restart-chesspal:
$(call ssh-cmd,"sudo service $(INIT_SCRIPT) stop")
$(call ssh-cmd,"sudo service $(INIT_SCRIPT) start")
raspi-apply-config:
- $(call ssh-copy,configs/chesspal.yaml,/home/pi/chesspal/configs/chesspal.yaml)
+ $(call ssh-copy,configs/chesspal.raspi.yaml,/home/pi/chesspal/configs/chesspal.yaml)
$(call ssh-cmd,"sudo shutdown -r 0")
raspi-logs-follow:
diff --git a/web/vue-frontend/src/App.vue b/web/vue-frontend/src/App.vue
index bc42788..a0ede10 100644
--- a/web/vue-frontend/src/App.vue
+++ b/web/vue-frontend/src/App.vue
@@ -51,6 +51,8 @@
:fen="fen"
:outcome="outcome"
:pgn="pgn"
+ :black="black.name"
+ :white="white.name"
class="my-4"
/>
@@ -82,7 +84,6 @@
>
+ {{ black }} +
+ {{ white }} +