_giuraemanuel
❔ What data structure to use?
Hello! I'm working on a chess game, in particular to a method that gets me the valid moves for that particular piece. I need to return a list of valid moves for that piece, but the problem is, i don't know what data structure to use to return those moves. The method takes in a row and a column, which in fact represent the position the piece is found at. I've been thinking about tuple but im not sure. I also thought about an array, however, i need to initialize to a size, but i can't know ahead of time how many valid moves a piece can have at a given time. Could anyone suggest something? Thanks a lot!
28 replies