Coder Social home page Coder Social logo

lichess-bot's People

Contributors

ddugovic avatar dolegi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lichess-bot's Issues

Capture Lichess error message

Sometimes Lichess produces HTTP 400, although the second example refers to an unfinished game where Lichess rejected a legal move. It would be good to output the error message produced by Lichess:

Nov 30 14:43:51 vps178028 lichess-bot[25071]: Accepting challenge {mGriu2II created {leelapi LeelaPi BOT 1872 false true 4} {godelescherbot GodelEscherBot BOT 2077 false true 0} {standard} false rapid random}
Nov 30 14:45:05 vps178028 lichess-bot[25071]: REQUEST bot/game/mGriu2II/move/c7c5
Nov 30 14:45:05 vps178028 lichess-bot[25071]: Response 400 POST bot/game/mGriu2II/move/c7c5
Nov 30 14:55:36 vps178028 lichess-bot[25071]: Accepting challenge {hVOzc2Xr created {leelapi LeelaPi BOT 1872 false true 4} {godelescherbot GodelEscherBot BOT 2077 false true 0} {standard} false rapid random}
Nov 30 14:55:41 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/e2e4
Nov 30 14:55:52 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/g1f3
Nov 30 14:56:05 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/f1b5
Nov 30 14:57:10 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/d2d3
Nov 30 14:57:19 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/b5c6
Nov 30 14:57:41 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/e1g1
Nov 30 14:58:21 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/b1d2
Nov 30 14:58:32 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/d2c4
Nov 30 15:00:07 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/h2h3
Nov 30 15:00:51 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/f3h4
Nov 30 15:02:36 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/a2a4
Nov 30 15:03:10 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/c1e3
Nov 30 15:04:01 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/h4f5
Nov 30 15:05:44 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/b2b3
Nov 30 15:06:47 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/g1h2
Nov 30 15:07:55 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/h3h4
Nov 30 15:08:55 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/g2g4
Nov 30 15:09:48 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/f1g1
Nov 30 15:10:26 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/h4h5
Nov 30 15:11:06 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/c4d2
Nov 30 15:11:47 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/f5h4
Nov 30 15:11:47 vps178028 lichess-bot[25071]: Response 400 POST bot/game/hVOzc2Xr/move/f5h4

error happen when trying to use go get

PS G:\project\lichess> go version
go version go1.17.3 windows/amd64
PS G:\project\lichess> go get github.com/dolegi/lichess-bot
go get: installing executables with 'go get' in module mode is deprecated.
        Use 'go install pkg@version' instead.
        For more information, see https://golang.org/doc/go-get-install-deprecation
        or run 'go help get' or 'go help install'.
# github.com/dolegi/lichess-bot
C:\Users\ZerQAQ\go\pkg\mod\github.com\dolegi\[email protected]\stream_game.go:47:30: unknown field 'Type' in struct literal of type uci.NewGameOpts

go install does not work too

dial udp 127.0.0.53:53: socket: too many open files

It appears a segmentation fault occurred... I didn't know that was possible in Go https://lichess.org/Gig0kNFp/black#17 :

May 31 04:49:45 vps178028 lichess-bot[16040]: Accepting challenge {HRGAQ7S6 created {chijss Chijss  2061 false true 2} {godelescherbot GodelEscherBot BOT 2474 false true 0} {atomic} true blitz white}
May 31 04:49:48 vps178028 lichess-bot[16040]: {gameFull Gig0kNFp true {atomic} {180000 2000} blitz startpos {gameState  180000 180000 2000 2000} {chijss} {godelescherbot}  0 0 0 0}
May 31 04:49:52 vps178028 lichess-bot[16040]: {gameState  false {} {0 0}   {  0 0 0 0} {} {} g1f3 180000 180000 2000 2000}
May 31 04:50:01 vps178028 lichess-bot[16040]: REQUEST bot/game/Gig0kNFp/move/f7f6
May 31 04:50:01 vps178028 lichess-bot[16040]: {gameState  false {} {0 0}   {  0 0 0 0} {} {} g1f3 f7f6 180000 180000 2000 2000}
May 31 04:50:05 vps178028 lichess-bot[16040]: {gameState  false {} {0 0}   {  0 0 0 0} {} {} g1f3 f7f6 e2e3 178190 180000 2000 2000}
May 31 04:50:07 vps178028 lichess-bot[16040]: REQUEST bot/game/Gig0kNFp/move/e7e6
May 31 04:50:07 vps178028 lichess-bot[16040]: {gameState  false {} {0 0}   {  0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 178190 179480 2000 2000}
May 31 04:50:27 vps178028 lichess-bot[16040]: {gameState  false {} {0 0}   {  0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 160270 179480 2000 2000}
May 31 04:50:31 vps178028 lichess-bot[16040]: REQUEST bot/game/Gig0kNFp/move/c7c6
May 31 04:50:32 vps178028 lichess-bot[16040]: {gameState  false {} {0 0}   {  0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 160260 177340 2000 2000}
May 31 04:50:39 vps178028 lichess-bot[16040]: {gameState  false {} {0 0}   {  0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 155060 177340 2000 2000}
May 31 04:50:42 vps178028 lichess-bot[16040]: REQUEST bot/game/Gig0kNFp/move/c6b5
May 31 04:50:42 vps178028 lichess-bot[16040]: {gameState  false {} {0 0}   {  0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 155060 176020 2000 2000}
May 31 04:50:45 vps178028 lichess-bot[16040]: {gameState  false {} {0 0}   {  0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 d1h5 154480 176020 2000 2000}
May 31 04:50:47 vps178028 lichess-bot[16040]: REQUEST bot/game/Gig0kNFp/move/g7g6
May 31 04:50:48 vps178028 lichess-bot[16040]: {gameState  false {} {0 0}   {  0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 d1h5 g7g6 154470 175130 2000 2000}
May 31 04:50:48 vps178028 lichess-bot[16040]: {gameState  false {} {0 0}   {  0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 d1h5 g7g6 h5b5 156480 175120 2000 2000}
May 31 04:50:56 vps178028 lichess-bot[16040]: REQUEST bot/game/Gig0kNFp/move/b8c6
May 31 04:50:57 vps178028 lichess-bot[16040]: {gameState  false {} {0 0}   {  0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 d1h5 g7g6 h5b5 b8c6 156470 168570 2000 2000}
May 31 04:50:57 vps178028 lichess-bot[16040]: {gameState  false {} {0 0}   {  0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 d1h5 g7g6 h5b5 b8c6 b5b6 158480 168560 2000 2000}
May 31 04:50:59 vps178028 lichess-bot[16040]: REQUEST bot/game/Gig0kNFp/move/a7b6
May 31 04:50:59 vps178028 lichess-bot[16040]: {gameState  false {} {0 0}   {  0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 d1h5 g7g6 h5b5 b8c6 b5b6 a7b6 158470 168100 2000 2000}
May 31 04:51:01 vps178028 lichess-bot[16040]: {gameState  false {} {0 0}   {  0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 d1h5 g7g6 h5b5 b8c6 b5b6 a7b6 f1b5 159170 168090 2000 2000}
May 31 04:51:04 vps178028 lichess-bot[16040]: REQUEST bot/game/Gig0kNFp/move/e8f7
May 31 04:51:04 vps178028 lichess-bot[16040]: {gameState  false {} {0 0}   {  0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 d1h5 g7g6 h5b5 b8c6 b5b6 a7b6 f1b5 e8f7 159160 166410 2000 2000}
May 31 04:51:06 vps178028 lichess-bot[16040]: {gameState  false {} {0 0}   {  0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 d1h5 g7g6 h5b5 b8c6 b5b6 a7b6 f1b5 e8f7 b5d7 159710 166400 2000 2000}
May 31 04:51:15 vps178028 lichess-bot[16040]: REQUEST bot/game/Gig0kNFp/move/a8a2
May 31 04:51:15 vps178028 lichess-bot[16040]: Failed request POST bot/game/Gig0kNFp/move/a8a2 Post https://lichess.org/api/bot/game/Gig0kNFp/move/a8a2: dial tcp: lookup lichess.org on 127.0.0.53:53: dial udp 127.0.0.53:53: socket: too many open files
May 31 04:54:03 vps178028 lichess-bot[16040]: Accepting challenge {Gig0kNFp created {chijss Chijss  2072 false true 4} {godelescherbot GodelEscherBot BOT 2474 false true 0} {atomic} true blitz black}
May 31 04:54:06 vps178028 lichess-bot[16040]: Failed request GET bot/game/stream/DfI0p9kT Get https://lichess.org/api/bot/game/stream/DfI0p9kT: dial tcp: lookup lichess.org on 127.0.0.53:53: dial udp 127.0.0.53:53: socket: too many open files
May 31 04:54:06 vps178028 lichess-bot[16040]: panic: runtime error: invalid memory address or nil pointer dereference
May 31 04:54:06 vps178028 lichess-bot[16040]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x48 pc=0x68a7b0]
May 31 04:54:06 vps178028 lichess-bot[16040]: goroutine 1 [running]:
May 31 04:54:06 vps178028 lichess-bot[16040]: main.streamGame(0xc0032c5210, 0x8, 0xc0000523c0)
May 31 04:54:06 vps178028 lichess-bot[16040]:         /home/turing/lichess-bot/stream_game.go:46 +0xa0
May 31 04:54:06 vps178028 lichess-bot[16040]: main.handleEvent(0xc00352c000, 0xc0000523c0)
May 31 04:54:06 vps178028 lichess-bot[16040]:         /home/turing/lichess-bot/stream_event.go:75 +0x103
May 31 04:54:06 vps178028 lichess-bot[16040]: main.streamEvent(0xc0000523c0)
May 31 04:54:06 vps178028 lichess-bot[16040]:         /home/turing/lichess-bot/stream_event.go:59 +0x18c
May 31 04:54:06 vps178028 lichess-bot[16040]: main.main()
May 31 04:54:06 vps178028 lichess-bot[16040]:         /home/turing/lichess-bot/main.go:106 +0x591

Log?

I attempted to play a chess960 game against my bot (Stockfish supports every Lichess variant), and I don't know what went wrong:
https://lichess.org/Bg5bUFlW

Do not decline challenge after accepting it

Apparently if an opponent's lag or online status changes, there are two challenge events. This wrapper doesn't care about the opponent's lag or online status.

Aug 04 06:21:27 vps178028 lichess-bot[16108]: Accepting challenge {DVKEO0nx created {szachowy_kox Szachowy_Kox  1943 false true 3} {godelescherbot GodelEscherBot BOT 2456 false true 0} {racingKings} false bullet black}
Aug 04 06:21:33 vps178028 lichess-bot[16108]: Declining challenge {DVKEO0nx created {szachowy_kox Szachowy_Kox  1943 false true 4} {godelescherbot GodelEscherBot BOT 2456 false true 0} {racingKings} false bullet black}

Perhaps the first step of this function should be to check whether lichess-bot thinks it has a game in progress whose ID is the same as the challenge ID:

func handleEvent(e *event, eng *uci.Engine) {
switch e.Type {
case "challenge":
if validChallenge(&e.Challenge) && !gameInProgress() {
log.Println("Accepting challenge", e.Challenge)
acceptChallenge(e.Challenge.Id)
} else {
log.Println("Declining challenge", e.Challenge)
declineChallenge(e.Challenge.Id)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.