Solving Your First Puzzle - alcapwny/CodinGameCppFramework GitHub Wiki

First Time Setup

  1. There are a few options...
    • Fork this repo. This repo already contains sample solutions for two CodinGame puzzles to help you get familiar with the way to work with CGF. If desired, making your repo private will keep the your solution code to yourself.
      • You should pull the submodules as well as this will allow you to easily use ImGui to visualize your algorithms and debug your Sharpmake script changes.
    • Not recommended, but another option is to simply grab a zip of this repo and extract it somewhere. This repo has been setup so that it can work without needing to get the Sharpmake submodule.
      • You'll want to also download a copy the of Dear ImGui repo at the appropriate commit and move it to the dependencies folder to use Dear ImGui. Otherwise you'll have to comment out the line from the Sharpmake scripts that adds the dependency to CGFImGuiProject.
  2. Run bootstrap.bat.
    • This will compile the tools needed by this framework and generate the codingame solution so that you can start working on puzzles.
  3. Optional: Setup Sharpmake.
    1. To help debug changes to the sharpmake scripts you can get the Sharpmake submodule and run dependencies\Sharpmake\bootstrap.bat. This will generate Sharpmake.sln.
    2. Add tools\Sharpmake.CGF\Sharpmake.CGF.csproj as an existing project to Sharpmake.sln.
    3. Add the following command line option to the Sharpmake.Application debug arguments: /sources(@"..\..\..\..\..\..\tools\Sharpmake.CGF\main.sharpmake.cs") /verbose
  4. Optional: Open tools\CGFCodeGenerator\CGFCodeGenerator.sln and add the following command line option to your debug arguments: ..\..\build\generated\codingamecodegen.sln. If you make any changes to the code generator this will allow you to test your changes on your .cs files.

Setup Per Puzzle

  1. Run tools\generate_PuzzleFromTemplate.bat PUZZLE_NAME
  2. Run tools\generate_ProjectsAndCode.bat. This will generate a Visual Studio solution in build\generated\codingame.sln as well as run the code generator.
  3. Open the solution, set the startup project to PUZZLE_NAME
  4. Open the PUZZLE_NAMEInputData.cs file and add members that need to be serialized with the appropriate attributes
  5. Run tools\generate_Code.bat. This will run the code generator. While you can run tools\generate_ProjectsAndCode.bat it is only necessary when new files are added. If no new files are added tools\generate_Code.bat will be a bit faster.
  6. Write the solution to the PUZZLE_NAME puzzle starting from skeleton in PUZZLE_NAME.cpp.
  7. Compile to make sure everything is fine.
  8. Run tools\generate_CodeForCodingame.bat.
  9. Find the preprocessed file in temp\intermediate\PUZZLE_NAME_win32_retail\PUZZLE_NAME.i and copy its contents to the CodinGame IDE.
  10. Run the CodinGame test cases.
  11. If some test cases fail copy paste the contents of the output window into the data\PUZZLE_NAMELog.txt file and run the data\PUZZLE_NAMELogParser.bat. This will generate the data\PUZZLE_NAME.txt file which will be read when running your solution local.
    1. Note: If there is too much output per frame it will be truncated. As far as I know there is no workaround for this except reducing the amount of logs generated when possible, or trying to debug the code using other test cases.
  12. Iterate on your solution until all test cases pass, repeating steps 6-11 as often as necessary.
  13. Submit your code to CodinGame and rejoyce!