Please sign in to access this page

Online chess game via the terminal.

Online chess game via the terminal.

17 devlogs
47h 21m
Created by Henrique

An online terminal chess game, written in go. You can connect with another player and play a game of chess. Why am I building this? I like chess and using the terminal.

Timeline

Well, I decided to rewrite the entire project. Why? Reviewing it, I noticed many points I didn't understand and some workarounds. I felt like chatgpt had done almost all the work, which bothered me. So, I decided to rewrite the project from scratch, changing a few things without chatgpt's help, using ideas from the old version as a base and also new ones.

https://github.com/jhenriquem/chess-game/tree/rebuilding

Update attachment

I changed the way the board was rendered. I added colors and a table-like rendering. I also built the logic for player names. It took me a while to figure out how the lipgloss and bubbles packages worked.

Update attachment

I implemented the timing logic for each player. I'm focusing more on the server side, developing most of the features and creating a simple client implementation. However, I'll focus on improving the client UI later.

Update attachment

I fixed some errors related to naming and logic. I also created the handler package to handle messages and actions corresponding to each message type. At the same time, I separated some functions and organized them, such as logic.Moves.

I took the opportunity to start working on the timing logic.

Update attachment

I fixed numerous bugs, mainly when closing the connection when the client disconnects. The channel closing logic was confusing and incorrect. I also improved some logic, such as GetPlayer.

I made changes to the project structure; something like pkg and model are located at the root of the project.

I expanded the message the server sends to the client, a prelude to what comes next.

I also created some unit tests for the functions in the logic package; I will follow this principle from now on.

Update attachment

Fixed the error that was occurring when rendering the board for the black pieces. I also started the logic to check the resulting actions of the moves (check, checkmate).

Update attachment

As I expected, the bug occurred due to the notation used. Fix this. It also improves the structure of messages between the server and client and the screen rendering on the client. However, there is a bug in the connection, as the server sometimes claims a timeout on the client.

Update attachment

I separated the logic for sending and reading messages and created the net package to handle all functionality related to the game's connection.

I also created the basic game logic, allowing for the sending of moves and updating each player's board as the game progresses. However, I have a bug in the move validation, something related to the notation used in the game. I'll take a deeper look at the package documentation later.

Update attachment

I'm rewriting some things, creating new packages, improving the game's logic, separating code blocks and logic.

Update attachment

Fix the timeout bug between client and server. The client returns to the server timeout, which ended the connection. The error was in the if IsGame of ./client/core that defined the PingHandler several times, generating mismatch between teams. It took me a while to realize, good thing I also improved some things besides that.

Update attachment

I tried to create a logic for client communication with the server. However, it is a bit broken, there is some error in the client that generates a timeout. I will look into this later.

Update attachment

I separated the Game struct from the game package. Create a models package. It helped with the project's structure and readability. I had to adapt the rest of the code to this change.

I also made a small improvement to the rendering of the board in the client part.

Update attachment

💡 I went back to keeping the client and server in the same project. I decided this because of some details related to the hackclub. Also, there are many packages that would be repeated between the two.

📌 I improved and fixed the ping/pong logic. There was an error in this system that I hadn't noticed. It took a while to fix. And guess what? It was all because I was using a snippet generated by chatgpt, which was wrong 😭. Well, I looked at the websocket documentation and fixed it myself. Do it yourself 💪🏼

Update attachment

I decided to improve the disconnection logic between players and the server. When a player is disconnected, the other is notified and the game is closed.

Update attachment

I remade the general structure of the project. I separated the client from the server and created two different projects. For now, I will develop the server

Update attachment

I slightly restructured the project. I changed the concept of rooms for games, I believe it is better both for understanding the code and for the development of the project itself. I corrected some bad points in the , such as the creation of rooms (games) and the boad. I redid some sections. I also added the functionality that if the player disconnects, the other is notified.

Update attachment

Initial concepts.
Basic server structure and rudimentary logic of rooms and players. Also a simple client for testing. I'll probably rewrite some things. Some points of the project, for me, are botched, so I'll take a look at them later and rebuild them.

Update attachment