Some help for a newbie with a simple game code?

Everything about Sudoku that doesn't fit in one of the other sections

Some help for a newbie with a simple game code?

Postby rusllrd » Wed Apr 05, 2023 10:03 am

Hello, it's my first time here and I'm having some problems with Processing.
I need to write a sketch to create a Sudoku game with a 4x4 grid. I'm just not so sure where to start, I'm only at the very beginning of learning the processing language but understand it when I read it.

My question is: how would you start a sketch for creating a game of sudoku in processing?

Any help would be really appreciated.

Thanks!
rusllrd
 
Posts: 1
Joined: 26 September 2020

Re: Some help for a newbie with a simple game code?

Postby Hajime » Wed Apr 05, 2023 3:46 pm

A valid 4x4 grid is:
Code: Select all
1234
3412
4123
2341
Each row,column and 2x2-box has 1234.
All you have to do is:
  • swap stacks
  • swap bands
  • swap rows within a band
  • swap columns within a stack
A stack is 2 left or 2 right columns.
A band is 2 upper or lower rows.
Right? Or is that not a "sketch"?
User avatar
Hajime
 
Posts: 1385
Joined: 20 April 2018
Location: Fryslân

Re: Some help for a newbie with a simple game code?

Postby gulshan212 » Tue Jul 18, 2023 2:13 pm

Well, i can give you a basic outline for what you are looking for.

Code: Select all
int[][] sudokuGrid = new int[4][4]; // 4x4 Sudoku grid

void setup() {
  size(400, 400); // Set the canvas size
  initializeSudoku(); // Initialize the Sudoku grid
}

void draw() {
  drawSudokuGrid(); // Draw the Sudoku grid
}

void initializeSudoku() {
  // Implement the logic to initialize the Sudoku grid (generate the puzzle)
}

void drawSudokuGrid() {
  // Implement the logic to draw the Sudoku grid
}

void mousePressed() {
  // Implement the logic to handle mouse clicks (if needed)
}

void keyPressed() {
  // Implement the logic to handle keyboard input (if needed)
}



Thanks
gulshan212
 
Posts: 12
Joined: 27 January 2023
Location: Haldwani, Uttarakhand


Return to General