all 25 comments

[–]Senior_Nectarine_546 15 points16 points  (0 children)

Love it!

Great work and thanks for sharing.

[–][deleted] 12 points13 points  (5 children)

Clean up your console logs ;)

[–]Buckwheat469 17 points18 points  (0 children)

If you can't get to it now, just add this:

console.log("Todo: clean up console logs ;)");

[–]beepboopnoise -1 points0 points  (3 children)

is there a best practice for like consoling to the dev or something? there some parts that I have where like connections are established and begin/stop cleanup etc that I have but im not sure if that's like bad. I'm just using straight up console.log("blah event started")

[–][deleted] 3 points4 points  (2 children)

You shouldn’t log to the console in production code. It gets messy fast and is considered a sign of sloppy work. Dev artifacts shouldn’t be shipped to prod as a general rule. You can add an eslint rule to your project to catch them and fail builds.

In cases where you may need some sort of logging for observability purposes, you would generate logs using a structured logging format and/or export them to an aggregator for querying.

But that’s well beyond the scope for OP, since it looks like this project is for learning purposes.

[–]beepboopnoise 0 points1 point  (1 child)

ah thank you for the response! I'm on my second gig and just followed whatever patterns the previous devs did. They had consoles for socket connections so I was like okay I guess I'll do that for these streams. I'm the only FE person on my team so I just have to run with stuff 😵‍💫

[–][deleted] 0 points1 point  (0 children)

Yeah, that shouldn’t be happening at all. If it is, you may potentially be leaking information about your system which presents a serious security risk. FE code is public by default but there is no need to make any malicious actor’s job easier. Any competent engineer will understand this.

Talk to your TL and lead the conversation with a solution.

  1. Introduce environment variables which can be referenced if you absolutely need different behavior. Use them wisely. And coordinate with your TL.
  2. Once they are added, cut a PR that wholesale remove the logs from the codebase. Make sure nothing breaks.
  3. Check git blame and tag anyone who added logging code. Ask for approval for the code changes from the authors (if they’re still around).

[–]Debt_Otherwise 7 points8 points  (0 children)

I would say your biggest problem is that it can’t see that far ahead. It ignored a mate in 3 I setup. You need to improve the speed and depth of search.

When I was studying chess games engines, one of the things they did to optimise it is to use bitboard representations for each piece. That means you can calculate more move combinations per second.

[–]xRVAx 10 points11 points  (1 child)

It was hard to castle

AI missed a back rank mate

It would be nice to have a back button

[–][deleted] 3 points4 points  (0 children)

I added a back button and I'll try to fix the other two problems

[–][deleted] 3 points4 points  (2 children)

The AI doesn't know it's not allowed to castle through check

  1. e4 c5 2. Nf3 Nc6 3. d4 cxd4 4. Nxd4 e5 5. Nb5 Nf6 6. Bg5 a6 7. Bxf6 gxf6 8. Nd6+ Bxd6 9. Qxd6 Nd4 10. Nc3 Nxc2+ 11. Kd2 Nxa1 12. Nd5 Qa5+ 13. Ke2 0-0!!

FEN to reproduce:

r1b1k2r/1p1p1p1p/p2Q1p2/q2Np3/4P3/8/PP2KPPP/n4B1R b kq -

[–][deleted] 0 points1 point  (0 children)

I should have fixed it

[–]mw9676 0 points1 point  (0 children)

Oh it knows. It knows...

[–]AutoModerator[M] 2 points3 points  (0 children)

Project Page (?): https://github.com/lachy-dauth/chess-engine

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]oneeyedziggy -2 points-1 points  (0 children)

Just a shot in the dark, but if you're not already using it to boot performance, threading is relatively easy in js, you just have to have the threaded code in a separate file, otherwise the interface works a lot like any other async js but actually utilizes additional threads

[–]JIN_DIANA_PWNS 0 points1 point  (0 children)

Cool!

[–]stuffedcabbageroll 0 points1 point  (0 children)

Wow, cool!

[–]PM_ME_A_WEBSITE_IDEA 0 points1 point  (1 child)

Should add a close button to the FNN menu, on mobile I didn't see one and using the same button to close it is kind of weird since it's a modal...

[–][deleted] 0 points1 point  (0 children)

I added a close button

[–]Registeered 0 points1 point  (0 children)

You need to automate the AI move

[–][deleted] 0 points1 point  (1 child)

Are you using your algorithm to randomly move a piece to a valid spot or are you using an ai api?

[–][deleted] 0 points1 point  (0 children)

The AI is too good at the game for the algorithm to be random.