Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/270 Documented the /randomizer command #293

Conversation

KartikWatts
Copy link
Member

Closes #270

This PR provides documentation for the /randomizer command

@@ -0,0 +1,61 @@
# /randomizer

Provide FEN data based on requested parameters to start a random position.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note: As per my understanding I found, this command originally only provides the FEN data for position to start a new game contrary to the Controller description: "Starts a random position.", as actually, we require to make an additional call to start the game: ws.send('/start classical stockfish <options>')
So I wrote the document description accordingly, kindly provide me suggestions for improvement. And if so, do we need any update for the RandomizerCommand description @programarivm

@programarivm
Copy link
Member

programarivm commented Jun 30, 2024

Hi @KartikWatts,

Thanks for sending this PR!

The description is the same one used in the src/Command folder.

Starts a random position.

Thus, the commands are also described when starting the WebSocket server:

php cli/workerman/wss.php start
Welcome to PHP Chess Server
Commands available:
/accept {"jwt":"<string>"} Accepts an invitation to play online with an opponent.
/draw {"action":["accept","decline","propose"]} Allows to offer a draw.
/leave {"action":["accept"]} Allows to leave a game.
/legal {"position":"<string>"} Returns the legal FEN positions of a piece.
/online_games Returns the online games waiting to be accepted.
/play_lan {"color":"<string>","lan":"<string>"} Plays a chess move in long algebraic notation.
/randomizer {"turn":"<string>","items":"<string>"} Starts a random position.
/rematch {"action":["accept","decline","propose"]} Allows to offer a rematch.
/resign {"action":["accept"]} Allows to resign a game.
/restart {"hash":"<string>"} Restarts a game.
/start {"variant":["960","classical"],"mode":["fen","san","play","stockfish"],"settings":{"color":["w","b"],"fen":"<string>","movetext":"<string>","settings":"<string>","startPos":"<string>"}} Starts a new game.
/stockfish {"options":{"Skill Level":"int"},"params":{"depth":"int"}} Returns Stockfish's response to the current position.
/takeback {"action":["accept","decline","propose"]} Allows to takeback a move.
/undo Undoes the last move.

Listening to commands...
Workerman[cli/workerman/wss.php] start in DEBUG mode
-------------------------------------------------------------- WORKERMAN --------------------------------------------------------------
Workerman version:4.1.15          PHP version:8.3.2-1+0~20240120.16+debian11~1.gbpb43448           Event-Loop:\Workerman\Events\Select
--------------------------------------------------------------- WORKERS ---------------------------------------------------------------
proto   user            worker          listen                      processes    status           
ssl     standard        none            websocket://0.0.0.0:8443    1             [OK]            
---------------------------------------------------------------------------------------------------------------------------------------
Press Ctrl+C to stop. Start success.

The JavaScript code snippet to be used as an example can be written as per the docs at Getting Started.

Probably the easiest way to get familiar with the chess commands is by reading the WebSocket messages sent back and forth between the web browser and the chess server as you interact with a web app. To do this, you may want to use the website as shown in the example below.

example

Figure 1. Click on Training > Checkmate and select King and bishop and knight vs. king

Data:

/randomizer b "{\"b\":\"BN\"}"
{"\/randomizer":{"turn":"b","fen":"1b4k1\/8\/8\/2K5\/7n\/8\/8\/8 b - -"}}
/start classical stockfish "{\"color\":\"b\",\"fen\":\"1b4k1/8/8/2K5/7n/8/8/8 b - -\"}"
{"\/start":{"variant":"classical","mode":"stockfish","color":"b","fen":"1b4k1\/8\/8\/2K5\/7n\/8\/8\/8 b - -"}}

The thing is, in order to interact with the web app, a ChesslaBlab platform needs to be up and running locally on your computer, which might not be obvious without previous practical experiments with Public Key Infrastructure (PKI).

The first thing you need to understand about setting up a ChesslaBlab website is that you have to create an SSL certificate to secure four different domain names at once.

See:

I hope this helps.

Keep it up, and happy learning!

@@ -0,0 +1,61 @@
# /randomizer

Provide FEN data based on requested parameters to start a random position.
Copy link
Member

@programarivm programarivm Jun 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description is the same one used in the src/Command folder: "Starts a random position."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, so for the sake of simplicity, I'll keep the description as: "Starts a random position.", kindly let me know if there are any other content updates required.
I have documented the API after going through the usage and code implementation myself, so I believe I have documented the command without missing any details.
However, it would be great to receive your thoughts. Regards.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @KartikWatts for the help on documentation!

I checked out the PR and made some changes before merging.

See:

Keep it up,

@programarivm programarivm merged commit b8709aa into chesslablab:main Jul 2, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document the /randomizer command
2 participants