JavaFX – Chess Remake
My senior year Common Assessment assignment was to recreate a board game, which I have decided to do, Chess. I had to do this in JavaFX by creating a working application that runs with Maven and combines Java and CSS3. I created different Controller classes for each FXML file, which control the UI and connect to Java code, allowing me to separate the logic from the UI. I also made an abstract piece class, which sets up the basic parts per piece. Each actual Chess piece has its own class, which directly inherits from the piece: King, Knight, Pawn, etc. Each “BoardCell” is the name of the class that holds the data for each cell on the UI, which connects to each Piece by x and y coordinates. I then made each piece have its own creation of a MovementPattern class to handle how they move, so that each piece can be used with polymorphism to dynamically move the pieces in one algorithm.
Creating this assignment took a lot of out-of-the-box thinking and planning. Chess, from the outside, looks really simple. Pieces move, and if the king is in danger, you could lose. I had to use a lot of abstraction to build the pieces, which were the hardest part. I think I would describe myself at a level of three because I haven’t exactly mastered this skill. I don’t fully look outside and abstract as soon as possible, and it usually takes a couple of iterations to get the design I want.
When I began designing my pieces, a difficult challenge was the movement of all the pieces and how to store them. Each piece moves similarly but differently, and I wanted one method to execute that movement. I was stuck on this for more than three hours, and didn’t know what to do. But fortunately, after a 5-minute rest away from computers, I came up with an amazing idea. Each piece will store a 2D, 3×3 array of objects from the MovementPattern class. This class stores two things: a special movement boolean and a length. The indices of the position in the 2D array determine direction on the board, and the length is how far the piece can move. The only problem I came up with for this was the knight, for which I had to add a special condition. Inside my method, I looped through the 2D array of the piece the user selected, and based on that pattern’s rules, would highlight squares the user can move to. This generates potential movement, which is later used for check and checkmate detection, for whatever piece is inputting. I wish I started off by creating how I would move each piece before getting into the logic and working sideways and backwards as I did. I would have benefitted on planning beforehand, which is a skill I struggle with. My favorite part, however, was the movement creation. It was something brand new I thought of on the spot, and I’m really proud of my idea for this. I learned how to use unique datatypes for storing what I thought wouldn’t be stored inside of them, and using every piece of data I can, the indices as directions, to my advantage.
To contact me, come check out my resume!


