Files
nd-wfc/demos/sudoku/sudoku_wfc.cpp
2025-08-29 15:59:56 +09:00

28 lines
855 B
C++

#include <nd-wfc/wfc.hpp>
#include "sudoku.h"
#include <iostream>
int main()
{
std::cout << "Running Sudoku WFC" << std::endl;
Sudoku sudokuWorld;
sudokuWorld.setValue(0, 5);
sudokuWorld.setValue(80, 1);
bool success = SudokuSolver::Run(sudokuWorld, true);
if (success) {
std::cout << "Sudoku solved successfully!" << std::endl;
// Print the solved sudoku
for (size_t y = 0; y < 9; ++y) {
for (size_t x = 0; x < 9; ++x) {
std::cout << static_cast<int>(sudokuWorld.getValue(x + y * 9)) << " ";
if (x == 2 || x == 5) std::cout << "| ";
}
std::cout << std::endl;
if (y == 2 || y == 5) std::cout << "------+-------+------" << std::endl;
}
} else {
std::cout << "Failed to solve sudoku!" << std::endl;
}
}