Part 3 - Scala solution source code (and interim encoder/decoder implementations)
The Scala code (dropbox public folder share - I SO love this) defining the infrastructure for experimenting with different encoder/decoder pairs. Included the first two coder implementations; SquareBits4 (constant 256 bits) and PieceExistsBitMapPlusSquareBits4 (max of 192 and reduces by four bits for each piece captured)
Details:
Honestly, I don't have time to go into much detail this evening. So, below is the 1,000 foot view. The root folder contains two folders; DataSets and eclipse_workspace. The DataSets folder contains a text file containing the "test" boards. It ought to be mostly self-explanitory. The eclipse_workspace folder contains the Eclipse .project. I'll reference that a bit later. All of the Scala files all stored in a single package; org.public_domain.chess_coding_challenge:
- WorkSheet1.sc: This is a fantastic mechanism for "forming" code dynamically. The code you see there is recompiled and run every time you save the file. All the text in the columns to the right are the output from each of the lines. This way of developing is beyond awesome.
- Main.scala: This is the root class that is run. It is the Scala analog to any Java class containing a public static main method.
- Definitions.scala: All interface definitions. Everything can be understood in terms of the interfaces.
- Implementations.scala: All the factories which instantiate implementations of the interfaces in Definitions.scala.
- ConvertBits.scala: A helper class to facilitate twiddling bits.
- Coders.scala: This is where the actual encoder/decoder pairs are implemented. And this is where the SquareBits4 and PieceExistsBitMapPlusSquareBits4 implementations are defined.
Once you have Eclipse installed and have started it...:
- Eclipse will want to be pointed at an Eclipse Workspace - select the eclipse_workspace folder (using "Browse" to navigate to it if needed)
- Once Eclipse comes up, it will be blank - using the main menu, select File/Import
- On that dialog, open the General item which will show a list of items
- Select the item "Existing Projects into Workspace" and click "Next"
- Next to the "Select root directory", select "Browse" and immediately hit "Okay"
- Click "Finish" and the project will be loaded and ready to explore
Have fun! And please let me know if you end up experimenting with writing some encoder/decoder pairs yourself. I am hoping to find more time this weekend to post at least the initial Huffman encoding that launched me onto this tangent/fixation/whatever on Super Bowl Sunday!
No comments:
Post a Comment