Monday, December 17, 2007

Better Screen Handling in C++

When I was posting the Sudoku code, I noticed that I had my conBuffer routines in that directory. These routines, treat the screen as an object and have some predefined operators and manipulators to make moving, coloring and clearing the screen easier.

Find the enclosed screen buffer routines:
I'm also including as a free bonus, a program that uses the routines to play "pong". My students were supposed to modify it so that it really could. I only provided the bouncing balls.

Labels: , , ,

Sudoku C++ Source Code

This code generates a Sudoku puzzle in C++ and then gives the user a chance to solve it in a Windows Console Terminal.

If you want have suggestions or questions about how the code works, I would love to hear from you. The code is basically a stupid backtracking program without any heuristics to speed it up.

There are three basic object types in the system:
  1. a vector which is an indirect link to a group of nine in the puzzle: sudokuVector.cpp sudokuVector.h
  2. the puzzle itself which contains the 9x9 array and the vectors: sudokuPuzzle.cpp sudokuPuzzle.h
  3. the screen which was my second pass at screen handling: conWindow.cpp conWindow.h
There is the main instantiation of a sudokuPuzzle in sudoku.cpp.
The program runs in a Windows command window and has compiled under VS 2005. The program was made as an example for a student, and I did not have time to clean it up completely. So, the mysterious question of the level of difficulty represents how deep in backtracking is required before giving up. Theoretically, the higher numbers represent a more complicated puzzle



An executable version of the program is on this blog page.


Jack

Labels: , ,