Chess Low Level Design Code | Software Interview Question | System Design

  Рет қаралды 38,511

Soumyajit Bhattacharyay

Soumyajit Bhattacharyay

Күн бұрын

Пікірлер: 106
@rajeevpillay6213
@rajeevpillay6213 3 жыл бұрын
At 4:30 AM you are making this content.I can't thank you enough for your excellent content.You deserve way more subscribers than you currently have as these are the best Low level design videos I have come across on KZbin. THANK YOU!
@lakshaysharma8144
@lakshaysharma8144 2 жыл бұрын
In short video you explained exactly what is needed love your content.
@tusharkuwar4
@tusharkuwar4 2 жыл бұрын
I am chess player. And there was high chance this question could come in interview. Thanks a lot !! 😅
@rajugaurav5052
@rajugaurav5052 4 жыл бұрын
Such an awesome content, I wish KZbin has recommended this a few months back. Kudos @Soumyajit 😅😀👍🤘✌️🙏💯👌👏
@ayushjindal4981
@ayushjindal4981 4 жыл бұрын
I have never seen a video this much crisp and clear. Thanks.
@SoumyajitBhattacharyay
@SoumyajitBhattacharyay 4 жыл бұрын
Thanks for the feedback. Please do share amaong your friends!!
@rahulsharma5030
@rahulsharma5030 4 жыл бұрын
1. The piece should have status to tell whether is alive or dead. 2. The move function in piece, will just be able to check whether it is a valid move.But we also need to make sure that in moving piece from one location to another, it should actually be checking whether there is no another piece in that move.So piece needs a board also as input
@SoumyajitBhattacharyay
@SoumyajitBhattacharyay 4 жыл бұрын
1) yes it is a good point. Piece can have a status Enum that will tell us the status of that particular piece. 2) No not at all. Whether or not another piece is there can be directly validated inside the Chess class itself as it is where the playermove function will be called. I contains the chess board and can deduce from here, Piece should not t all hold any information of the chess board as it is not the responsibility of a single piece to know about the entire board.
@rahulsharma5030
@rahulsharma5030 4 жыл бұрын
@@SoumyajitBhattacharyay I am saying, let us say that i am a player and i want to move some piece ,say queen from location a to location b, the canMove in piece will just check whether i am allowed to move or not.Now let us say that the destination location is valid.But while moving from source to destination,in path path,their is some other piece also.In chess we cannot cross other pieces.How will canMove verify this without knowing the board configuration?The chess game cannot verify this as it does not know what path the piece follows from source to destination.
@SoumyajitBhattacharyay
@SoumyajitBhattacharyay 4 жыл бұрын
The chess game can verify this as the move request will be originating from there it self and it will contain both the src and destination location along with the board information.
@rahulsharma5030
@rahulsharma5030 4 жыл бұрын
@@SoumyajitBhattacharyay yes but each piece can have its own way of path from source to destination.Like knight will go its own way, king its own,bishop its own, only piece can tell what is the path from source to destination.going from a to b will differ piece by piece.I think i am not able to explain you:(
@SoumyajitBhattacharyay
@SoumyajitBhattacharyay 4 жыл бұрын
All the path move in straight lines between source and destination, except for knight which can hop over pieces. So for knight only destination validation is ok. So the chess game can decide on the same. How i am envisioning is, the possible path will tell us the possivle moves from the source. It will return the list to chess. Chess will validate the same using board and return on the viable options on screen. User will only be able to move uptil the viable options that are present on screen for the selected piece.
@Rakeshkumar-po2yg
@Rakeshkumar-po2yg 2 жыл бұрын
Thanjyou Soumyajit. you made it easy for us..
@Adi-jr4xf
@Adi-jr4xf 2 жыл бұрын
brilliant this is the best lld content out there!!!!!
@RajatBhardwajBEE
@RajatBhardwajBEE 4 жыл бұрын
Thank you so much! Please keep making more of such LLD videos. One I wanted was to design backend of Snake game that was there in the Nokia phone and Parking lot. Thanks again.
@SoumyajitBhattacharyay
@SoumyajitBhattacharyay 4 жыл бұрын
Sure i will definitely make such videos! Duly noted.
@SoumyajitBhattacharyay
@SoumyajitBhattacharyay 4 жыл бұрын
Hi the parking lot video is out!!
@RajatBhardwajBEE
@RajatBhardwajBEE 4 жыл бұрын
@@SoumyajitBhattacharyay Thank you so much for your time. A much needed video.
@pankajsaini2376
@pankajsaini2376 6 ай бұрын
@@SoumyajitBhattacharyay You are amazing, love your content. Can you make a video on Google Doc and Car Rental System
@kaushikg1996
@kaushikg1996 3 жыл бұрын
Underrated channel, awesome content❤
@ayushchoudhury1700
@ayushchoudhury1700 2 жыл бұрын
Got asked this in interview a few days back. Couldn't elaborate a good design and got rejected. Wish I had seen this video before 😦
@tsjoshi
@tsjoshi 3 жыл бұрын
Awesome video !!! One thing, How are we handling checks ? In case of check, how can the game enforce other player to play limited moves only ?
@techshala8929
@techshala8929 4 жыл бұрын
It was an awesome video dude!! keep uploading more such content!!
@user-xo3mi4jx5g
@user-xo3mi4jx5g 2 жыл бұрын
Thank you so much. This was extremely helpful!
@SoumyajitBhattacharyay
@SoumyajitBhattacharyay 2 жыл бұрын
No problem at all 😊
@gopikrishnaks9664
@gopikrishnaks9664 5 ай бұрын
Thank you so much for the efforts. Had a doubt, could you please check? This solution is very impressive but I couldn't find any direct application of design patterns. Interviewers don't always expect that and it needs to be applied only if it's needed right?
@AamEngineer
@AamEngineer 4 жыл бұрын
Fantastic video it was... Thanks for making and explaining the low-level designing in a very neat and clear way... (Y)
@SoumyajitBhattacharyay
@SoumyajitBhattacharyay 4 жыл бұрын
Thanks for the feedback!!
@HimanshuKumar-xz5tk
@HimanshuKumar-xz5tk Жыл бұрын
Really appreciate the content Request you to include UML diagram before coding
@indrakumarreddy6679
@indrakumarreddy6679 3 жыл бұрын
Very clear Explanation, Thanks for the video. Could you please upload low level design for Snake&LadderGame
@creatingwaves
@creatingwaves 4 жыл бұрын
Amazing video. Thanks a lot!! Please make a video on parking lot problem and car rental like uber.
@SoumyajitBhattacharyay
@SoumyajitBhattacharyay 4 жыл бұрын
Sure i will make them. Thanks for the input!!
@SoumyajitBhattacharyay
@SoumyajitBhattacharyay 4 жыл бұрын
Hey the parking lot video is up!!
@princekm5902
@princekm5902 3 жыл бұрын
Very nice design.One doubt is how you update cell list,ie, when a player moves a piece. meaning while creating a move, We have to find the particular cell by cell position by performing a linear search right?
@msingla135
@msingla135 2 жыл бұрын
why can't you use the index directly on the List to get the cell?
@abhirupacharya010
@abhirupacharya010 Жыл бұрын
Beautiful explanation.
@ujeshnada5141
@ujeshnada5141 2 жыл бұрын
Is it enough for the Chess board LLD question? Don't we have to define the move methods of all the pieces ?
@RaunakShrivastava
@RaunakShrivastava 3 жыл бұрын
Why do we need a separate class 'Move'?
@rahulsharma5030
@rahulsharma5030 4 жыл бұрын
hey,i already mentioned is below long thread one doubt regarding how will we check whether the movement of piece from one location to another should not cross any chess piece in its way.the u have written it, you will have to do lot of ifelse in playerMove fxn in chess class which is not a good thing.so u should pass board instance to the piece, because it makes more sense, instead of asking board to give me you move,we will ask,given this configuration what are your moves as moves are defined with respect to board configuration.
@mohammadkaif8143
@mohammadkaif8143 3 жыл бұрын
How will i get to know whether the piece is rook or queen or king etc?? It has only color and api defined.
@rahulsharma5030
@rahulsharma5030 3 жыл бұрын
@@mohammadkaif8143 why do you want to know that?
@AkshayKumar-fj9hd
@AkshayKumar-fj9hd 3 жыл бұрын
We need to know type of piece only to identify if the move we are trying to make is valid or not, or to identify the next possible moves. If you see piece is an abstract class, and all the individual piece classes are defining validate and possibleMoves methods in their implementation. And we always pass the specific implementation of abstract class/interface. So e.g. in case of Move class it will have the specific peace object (e.g. rook, king etc). So only specific validate method will get called. I hope I didn't make it more complicated for you :)
@pawandeepchor89
@pawandeepchor89 3 жыл бұрын
You are really awesome, please continue sharing the knowledge 👍👍
@aianaverma4025
@aianaverma4025 2 жыл бұрын
Awesome explanation
@sibendusankardas3532
@sibendusankardas3532 2 жыл бұрын
How would we catch the checkmate scenario ? Or the king swap position with rook scenario.
@rahulsharma5030
@rahulsharma5030 4 жыл бұрын
Nice. I think Piece should have only canMove method to valiadate whether it can move or not.But the actual move should be done by chessGame. Game should be able to check Piece.canMove(), and if yes, game should be responsible for moving piece. What will piece do with move method?If you put Move in piece in Piece ,it will eventually call chess to move which is not a good flow.Let me know your thoughts?
@SoumyajitBhattacharyay
@SoumyajitBhattacharyay 4 жыл бұрын
No. Here the move method will actually contain the move defination for the piece. Move is piece dependent and chess does not have move a piece has a move and player plays the chess game by using the pieces move. Hence, chess should not have move. Individual piece should have it.
@SoumyajitBhattacharyay
@SoumyajitBhattacharyay 4 жыл бұрын
The best way to understand is to know the has a relationship between the methods and the corresponding classes.
@rahulsharma5030
@rahulsharma5030 4 жыл бұрын
@@SoumyajitBhattacharyay, then piece needs to know board information also.Will it be a parameter in Piece.move method?As of now i cannot see it?Board update should be done by chess i guess and not piece.If we maintain board information with piece or pass as a parameter,it does not look correct.Let me know you thoughts?
@SoumyajitBhattacharyay
@SoumyajitBhattacharyay 4 жыл бұрын
No that is not the case. See the move method in piece has a boolean return type. After the player tries to move a piece, the update board method in the ChessBoard is called. It will internally call the piece.move method that will return either true or false. Based on the return, the board will be updated. The piece should not know board information. That should never happen. As board has pieces and not the other way round. The best way is to understand these relationships between different class and then try and formulate what should be under which class.
@rahulsharma5030
@rahulsharma5030 4 жыл бұрын
Thats what i said.But in your code we have both validate and move method,which looks like validate method will do validation whether this move is allowed is not and move method will actually move the piece.But if move method will return boolean and based on that board will be updated,then what is difference between move and validate method?Arent they do same stuff?
@carpediem9407
@carpediem9407 4 жыл бұрын
i am a chess player ... just loved the way you made low level design of chess .. 💯💯
@SoumyajitBhattacharyay
@SoumyajitBhattacharyay 4 жыл бұрын
Thanks for the feedback! Really apprciate it 😄
@abhishekkapoor7955
@abhishekkapoor7955 Жыл бұрын
why we have move function inside piece, what will be the logic of this function. Piece is not maintaining its current position then Chess class has move() already
@AnandKumar-nx1ke
@AnandKumar-nx1ke 3 жыл бұрын
The question i would like to ask. Are LLD interviews of different kinds too : Like in some only Class Diagram is asked. In Some only skeleton(Like your video ) is asked. In Some complete running code is asked. Is my assumption correct. or only the 3rd one is asked at every LLD ?
@shubhampal7877
@shubhampal7877 2 жыл бұрын
3rd one is called machine coding
@harenderbhardwaj6357
@harenderbhardwaj6357 2 жыл бұрын
Hi brother, I am starting with LDL now. Can you please guide me. How should i proceed?
@shubhampal7877
@shubhampal7877 2 жыл бұрын
First check what you are going to learn, it's LLD not LDL
@vimalvestron8684
@vimalvestron8684 3 жыл бұрын
Bro if we make Piece interface instead of Abstract class that would also fit in , any particular reason you went with abstract class in this case ?
@princivershwal
@princivershwal 3 жыл бұрын
I also need answer for this.
@niteshnikhare1562
@niteshnikhare1562 3 жыл бұрын
There may be certain methods that may have common implementation irrespective of Piece for e.g. Say Move(Location a, Location b, Piece), this method can be kept common and I know there should be some validation in the method checking if the move is valid or not for that we can create an abstract method and implement it in all the pieces which will give you all the possible moves for a particular piece from that particular cell location. Once validated, you can just move the piece to the target location. The move is common irrespective of piece type so can be implemented in the main abstract piece class itself, it will save a lot of code duplicacy.
@rahatsaini1189
@rahatsaini1189 2 жыл бұрын
Hey What if we want to change the colors of the chessboard to something else or may be user-defined.
@SaurabhGupta-iu4sy
@SaurabhGupta-iu4sy 3 жыл бұрын
Hi @Soumyajit Bhattacharyay, why there are no Identifiers for the Game, Player, Board and Pieces classes? Are you assuming that this is a desktop application supporting only one game at a given time? If it had been an online application, with multiple games being played at a time, we will have to keep the unique identifiers in these classes, right? Can we implement the online chess app somehow with no datastore/database behind it?
@SoumyajitBhattacharyay
@SoumyajitBhattacharyay 3 жыл бұрын
Again, in all of the lld it is given from an interviewing perspective, where it is expected to do everything in memory be it lld round or machine coding round. For most actual use cases, you would require some form of data store. Yes this is from a perspective of an actual chess game. If you complete the video, I have discussed that as a task we should extend this design for an online chess playing service like chess.com etc.
@SaurabhGupta-iu4sy
@SaurabhGupta-iu4sy 3 жыл бұрын
@@SoumyajitBhattacharyay Thanks, say if we had to do this for online application with multiple games being played, how would we maintain the data corresponding to a particular game in the RAM (which datastructure or in-memory data modelling to use?), so when request comes we can know the state of pieces, players, currentTurn and board? Any insights would be helpful, as this was a real question asked in interview.
@msingla135
@msingla135 2 жыл бұрын
@@SaurabhGupta-iu4sy Each game must be represented by a game id. So we can store the state of the relevant objects (like board, players(IDs should be enough), current turn, etc) in a KV store (E.g. MongoDB) in form of key=game id, value=JSON object which has serialised board object and other mentioned fields. So next time if the same gameid is loaded, we'll get the exact status of the game where the game was abandoned. Hope that makes sense.
@poojagoyal3574
@poojagoyal3574 3 жыл бұрын
hi Soumyajit. would like to appreciate you for the content that you upload. could you please suggest any site/link which can help me to improve my skills on LLD.
@sakshambadaya4574
@sakshambadaya4574 Жыл бұрын
Can u also provide the information of database table and schema to be used while designing as this is also asked most of the time
@hemantagrawal25
@hemantagrawal25 3 жыл бұрын
Tell us about the design pattern in each LLD video. so we can understand which design pattern use in LLD
@helperclass
@helperclass 2 жыл бұрын
very nice. thanks
@gautammalhotra654
@gautammalhotra654 3 жыл бұрын
How will you implement move method in Piece extensions?
@anirbansaha7987
@anirbansaha7987 3 жыл бұрын
@Soumyajit : Why do we need the move class ?
@AkshayKumar-fj9hd
@AkshayKumar-fj9hd 3 жыл бұрын
In my opinion because a move has some information associated with it. E.g. when a player will make a move, then Chess classes's playerMove API will be called, that will internally call ChessBoard classes's updateBoard method. Now updateBoard method will require some information regarding the move e.g. startPosition, endPosition, Player etc. One way is to pass all this in diff variables or pass everything in a single object i.e. Move class in this case.
@HarshalDev
@HarshalDev 9 ай бұрын
why dont you make class attributes private, public or protected?
@DeepanshuGabba
@DeepanshuGabba 3 жыл бұрын
Can you please tell if multiple players (for example 3 players A, B and C) are trying to enter in a chess game at a same time , then how will we decide that which 2 players should our game select and which one of them will be left out?
@msingla135
@msingla135 2 жыл бұрын
Use synchonized to "write" players to the players array and decide on FCFS basis.
@lal_1404
@lal_1404 6 ай бұрын
excellent
@manishdadheech8440
@manishdadheech8440 4 жыл бұрын
Hi Soumyajit very nice explanation but I have a small doubt. Can interviewer ask the candidate to write code for any method in LLD or full coding? Should we ready for that also?
@SoumyajitBhattacharyay
@SoumyajitBhattacharyay 4 жыл бұрын
Yes it can be. In my media .net interview i was asked to write entire working code for the LLD and then run the code on a compiler and every requirement should be working there. It was an amazing experience. You can find the video here along with the question kzbin.info/www/bejne/a4KXhaiFra-Ya5Y But mostly it will be class level and api / db design. Sometimes depending on the company they might ask you to implement all or some part of it.
@SonGoku-lc1sb
@SonGoku-lc1sb 3 жыл бұрын
Hey Soumyajit , can we use python for LLDs ? I see most of the types people use java. But at amazon is it ok if folks do it in python ?
@HimanshuKumar-xz5tk
@HimanshuKumar-xz5tk Жыл бұрын
yeah bro, it does not matter Use any OOPs language unless its for a specific role (eg: go developer)
@shasha6538
@shasha6538 4 жыл бұрын
How will you implement makeMove
@gautammalhotra654
@gautammalhotra654 3 жыл бұрын
+1
@inkclusiveDesign
@inkclusiveDesign 3 жыл бұрын
Game_Status class can have another status that's "Stalemate".
@abhid15
@abhid15 3 жыл бұрын
I'm sorry but I do not see the source code link. Can you please share it? Great video.
@SoumyajitBhattacharyay
@SoumyajitBhattacharyay 3 жыл бұрын
It is present in the description. Does that link not work?
@abhid15
@abhid15 3 жыл бұрын
@@SoumyajitBhattacharyay found it. Thank you
@ramsaxena2671
@ramsaxena2671 3 жыл бұрын
Nice content.
@SoumyajitBhattacharyay
@SoumyajitBhattacharyay 3 жыл бұрын
Glad you liked it! ❤️
ATM LOW LEVEL DESIGN | FACEBOOK INTERVIEW QUESTION | SOFTWARE DEVELOPER INTERVIEWS
19:24
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
18. Design CHESS GAME, LLD Mock Interview | Low Level Design Coding Interview Question
1:07:24
Concept && Coding - by Shrayansh
Рет қаралды 44 М.
System Design Interview: Design LeetCode w/ a Google Engineer
12:11
System Design School
Рет қаралды 6 М.
LOW LEVEL DESIGN CODE || AMAZON SHOPPING WEBSITE || AMAZON INTERVIEW QUESTION SOLVED
17:10
Google system design interview: Design Spotify (with ex-Google EM)
42:13
IGotAnOffer: Engineering
Рет қаралды 1,2 МЛН
Book My Show || Low Level Design Code || Amazon Interview Question Solved!!
15:26
Soumyajit Bhattacharyay
Рет қаралды 82 М.
What does larger scale software development look like?
24:15
Web Dev Cody
Рет қаралды 1,5 МЛН
10 Signs Your Software Project Is Heading For FAILURE
17:59
Continuous Delivery
Рет қаралды 34 М.
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН