Comments (21)
Its open!
from chess-web-api.
@pi0neerpat I have an implementation which generates a standard PGN by running the decoded moveList
through the chess.js engine (tracks state of the game, which pieces took what, when check occurs, etc), and it works great for simple games. However when a pawn is promoted, there is no data provided from the current endpoint which indicates the type of piece it becomes (the moveList
only contains an underscore character for that slot). As such, there is not enough data to generate the subsequent PGN terms. You can take a look at my progress here:
https://github.com/CoeJoder/chess-web-api
There is one passing test for a simple game, and a failing test for a game which has a pawn promotion. You can run the tests with:
npm test -- games.test.js
We could simply omit the PGN when there is not enough data to generate it, or try to make additional API calls when necessary. Let me know how you'd like to proceed. EDIT: we could also reach out to the chess.com team and ask them to add that information to the endpoint, though I'm not sure they would be too enthusiastic in the first place about the use of this endpoint.
from chess-web-api.
Thanks to @andyruwruw and @CoeJoder user's can now pull games from chess.com!
https://niftychess.com/games/0x7697bb95a58bd1f5f819ca37dec0626a60e0475aa007abc4feb9d2efdbaea7ec
from chess-web-api.
I would either include as much of the information available or at the least include all the properties of Chess.com's official game endpoint (that can be parsed).
Chess.com API Game Object
{
"white": "string", // URL of the white player's profile
"black": "string", // URL of the black player's profile
"url": "string", // URL of this game
"fen": "string", // current FEN
"pgn": "string", // current PGN
"turn": "black", // player to move
"move_by": 1501765498, // timestamp of when the next move must be made
// this is "0" if the player-to-move is on vacation
"draw_offer": "black", // (optional) player who has made a draw offer
"last_activity": 1509810789, // timestamp of the last activity on the game
"start_time": 1254438881, // timestamp of the game start (Daily Chess only)
"time_control": "string", // PGN-compliant time control
"time_class": "string", // time-per-move grouping, used for ratings
"rules": "string", // game variant information (e.g., "chess960")
"tournament": "string", //URL pointing to tournament (if available),
"match": "string" //URL pointing to team match (if available)
}
from chess-web-api.
Issue Status: 1. Open 2. Started 3. Submitted 4. Done
This issue now has a funding of 300.0 DAI (300.0 USD @ $1.0/DAI) attached to it.
- If you would like to work on this issue you can 'start work' on the Gitcoin Issue Details page.
- Want to chip in? Add your own contribution here.
- Questions? Checkout Gitcoin Help or the Gitcoin's Discord
- $1,022,082.04 more funded OSS Work available on the Gitcoin Issue Explorer
from chess-web-api.
Hello, I've begun work on this one. I just want to clarify a few things about the data available at this endpoint. A lot of the fields you are asking for are not available here, probably due to the fact that this endpoint does not work for in-progress games (I have verified this). There are other game-related endpoints available, which a user can get to with subsequent queries to obtain more info about the games. However they do not allow lookup by game ID; it seems one would have to pull a list of archived games and search them based on the URL field and a simple regex to find the matching game ID. However if that is the approach you want, you could just get the PGN that way.
Anyways, see screenshot for the fields I will be returning for this ticket (plus the PGN as parsed from the moveList
). Let me know if this is acceptable. Thanks
from chess-web-api.
@jschiarizzi Nice hunch! Indeed, the encoded character is specific to the promotion. However it seems that there are multiple possible characters per promotion type, and changes if you capture a unit on the same turn. These are what I've observed so far (will update as I continue testing):
Promotion | No Capture | Capture Left | Capture Right |
---|---|---|---|
Queen | ~ |
{ |
} |
Knight | ^ |
( |
) |
Rook | _ |
[ |
] |
Bishop | # |
@ |
$ |
EDIT: OK looks like it's 3 encodings per promotion type: no capture, capture left, capture right. This gives us the destination square of the pawn too! So we should be able to feed that into the chess.js engine and get the full PGN. I will implement that and add a few more test cases. If anybody can think of other edge cases, let me know.
Regarding the test output: rest assured that this is still just one failing test case as reflected in the output line:
Tests: 1 failed, 1 passed, 2 total
It prints out two error messages because we use the expect.assertions
method. The purpose of this method is to ensure that assertions are made in code which uses callback functions. The usage here is redundant as our test code uses the await
syntax sugar instead of promise callbacks. However I included it anyways, because all other tests in the project use this convention. In fact, any existing tests in this project which throw errors will similarly output two error messages.
from chess-web-api.
@andyruwruw @jschiarizzi Let's work here to spec this out, post any comments. Once we are ready I will submit on Gitcoin
from chess-web-api.
Yeah maybe we don't need the string version, and can just do JSON. wdyt @jschiarizzi ?
- Will
start_time
always be available? We need the date YYYY.MM.DD so we can populateplayedAt
- Is
tournament
the one we want for theevent
field? It would be nice if we also hadtournamentName
instead of the URL. - I don't see a winner property?
from chess-web-api.
answer to above:
- The last activity time stamp should be good since thats unix and you can convert to date very very easily
- tournament is like little tournaments that they have on chess .com (or lichess for that matter) every few hours, so most games probably wont even have that field filled out. I would say for most online games, if you're saving it somewhere it doesnt really need that field
- winner can get pulled from the end of the PGN or FEN, like you mentioned 1-0 = white won, etc.
My question is, is there no "ID" for an individual game there? I guess technically the timestamp might be good enough but... there doesnt seem to be something that is actually unique?
ps. pretty cool it stores the draw offers. would be a fun side project to see how many games i have offered or accepted draws when engine though I was winning haha
from chess-web-api.
There is an ID. See the first comment here.
Everything looks good. I will clean up the initial bounty with the comments here and post on gitcoin.
from chess-web-api.
Issue Status: 1. Open 2. Started 3. Submitted 4. Done
Work has been started.
These users each claimed they can complete the work by 265 years, 9 months from now.
Please review their action plans below:
1) derryace has started work.
I have experience in REST Api development in javascript and everything looks straightforward in this bounty. So i'm confident i'll get it done in 2 days or less. Thanks 🙂
Learn more on the Gitcoin Issue Details page.
from chess-web-api.
@pi0neerpat Sorry just to confirm, is this an open bounty or was it mean't for a specific person? Thanks.
from chess-web-api.
looks like is an open Bounty, I was thinking the same as you
from chess-web-api.
@CoeJoder Looks acceptable to me! Parsing through the archives is exactly what I wanted to avoid, so if we end up with less data, I am ok with that.
from chess-web-api.
@pi0neerpat Great, thanks for the quick reply.
from chess-web-api.
Just did an initial skim of the code and it looks beautiful!!!
Thank you very much for finding and documenting the pawn promotion issue. A quick web search showed that this could affect ~5% of games, which is a bit of a bummer.
Let me talk with Joseph and see what we want to do. Will get back to you shortly
from chess-web-api.
Thanks for the additions, @CoeJoder, and for writing good tests, that's great. I just ran the tests script and it looks like there are 2 errors. The first related to the _
you mentioned in promotions. I'm wondering if @andyruwruw knows if anyone at chess.com has some secret info on how that is encoded? Could it be something like a _
is a queen promotion by default, and if its something else that is noted somewhere? Would you be able to add a game with a knight promotion or something to the tests?
the second test fail is the number of assertions being called? I'm not really sure what that means, I haven't seen that before. Could you check that out please? Ideally we dont merge anything with new failing tests. Thanks!!
It looks like this is mostly there, with functionality. Just need to make sure its behaving as expected. If the promotion error is truly due to not enough information than I would say that is beyond the scope of the bounty and we can pay out when we figure that out for sure.
from chess-web-api.
@CoeJoder fantastic job figuring out the characters related to the promotion. I guess Chess.com's system for encoding moves just requires testing to figure out what random characters they decided to use.
from chess-web-api.
Issue Status: 1. Open 2. Started 3. Submitted 4. Done
Work for 300.0 DAI (300.00 USD @ $1.0/DAI) has been submitted by:
- Learn more on the Gitcoin Issue Details page
- Want to chip in? Add your own contribution here.
- Questions? Checkout Gitcoin Help or the Gitcoin's Discord
- $1,117,266.16 more funded OSS Work available on the Gitcoin Issue Explorer
from chess-web-api.
Issue Status: 1. Open 2. Started 3. Submitted 4. Done
The funding of 300.0 DAI (300.0 USD @ $1.0/DAI) attached to this issue has been approved & issued to @CoeJoder.
- Learn more on the Gitcoin Issue Details page
- Questions? Checkout Gitcoin Help or the Gitcoin's Discord
- $974,021.35 more funded OSS Work available on the Gitcoin Issue Explorer
from chess-web-api.
Related Issues (11)
- Hitting exception "request.callbackParameters is not iterable"
- Spelling Error in Readme "Priority Queue" Section HOT 3
- [Feature Request] - getGameByID HOT 12
- TypeError: Chess is not a constructor HOT 2
- Types(cript) support HOT 2
- getGameByID only works with live games HOT 4
- Setting callbackParameters in dispatch function throws error HOT 1
- Breaking Change: User-Agent Contact Info Required HOT 5
- Support Import Usage for Vite
- Missing rounds from tournaments
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chess-web-api.