ernest-rudnicki / chess-3d

A simple chess game in Three.js
https://chess-3d-mja9.vercel.app/
MIT License
16 stars 2 forks source link

Game State management and AI response time update. #1

Closed JoeMacibi closed 1 year ago

JoeMacibi commented 1 year ago

Hello there Ernest, I have been using your project for a personal project I have an would like to ask afew questions regarding your game. Firstly I would like appreciate your and a good game you have built here, really gave me a good insight into game development. First Question: How can I make the game faster when AI is responding to moves. Q2: How do I change the game mode to be click to move pieces as opposed to drag to move.

Your feedback will be appreciated. Thank you.

ernest-rudnicki commented 1 year ago

Hey @Joe-88-droid, glad you like it!. I am a beginner like you in game dev but I will try to answer your questions.

  1. First thing I would do is rewriting the minimax algorithm to some more performant language than JavaScript. You could either use server-side implementation or maybe it would be better to use Rust or C++ with WebAssembly? My implementation of minimax has also alpha-beta pruning to optimize it, but for some of the moves it still may have a lot of possible routes to process. I would also recommend you to check this article https://levelup.gitconnected.com/improving-minimax-performance-fc82bc337dfd

  2. You would have to change a click handling logic a bit. To do so you would have to save the piece that you clicked, and after the second click you would have to detect the what position you clicked. You can start in the ChessScene.ts file, because it contains all of the logic regarding the mouse interactions. You would have to remove mousedown, mouseup and pointermove listeners and create your own implementation based on click events

JoeMacibi commented 1 year ago

Thanks mate this will be helpful and much appreciated. In the days since writing to you I have been able to improve the response time once I launched the game and hosted on servers, my laptop running locally was abit slow. Thank You.

I will certainly look look to implement the click handling logic in the coming days and also implement it in my 2D game also.

Transitioning from software development to game dev has kicked my ass on this project. I will send you a link of the complete game upon launch for you check it out. Again thanks mate.