Java: How to Make a Sudoku Game without Graphical User Interface (GUI)

What's sudoku?

Sudoku is a logic-based number-placement puzzle. The objective is to fill an n×n grid with n distinct digits from 1 to n, so that each column, each row, and each of the subgrids that compose the grid contains all of the digits from 1 to n without repetition.

Usually, when we talk about sudoku, we refer to the common case n=9, which is an 9x9 sudoku. In fact, sudoku is closely related to mathematics, and there is a complicated mathematical principle behind it.

Here I would like to share my Java assignment. The task is to create a simple sudoku game without a graphical user interface (GUI).

In fact, Java is not my main language, so I'm not very proficient in it. I took Java as an elective course just because I was curious about Java programming.

When I started learning Java, sometimes I got confused about the syntax of Java, because it is similar to both C++ and Python.

To me, Java syntax seems like a combination of Python and C++. Sometimes, I get confused about whether I'm using C++ or Python. Also, Java code is usually longer than C++ code.

In this assignment, I used the simplest mathematical algorithm. There are other better algorithms, and here I only introduced the simplest one. The algorithm is easy, but it was a bit hard for me to write it in Java. Sometimes, mathematical algorithms seem easy, but they are hard to code.

I also translated the Java code to C++ and Python for other language users to understand it. I have uploaded my code to my GitHub. If you are interested, you can check it out: Sudoku

You can also create a simple sudoku game application without GUI that can run on any computer without any programming language installed. The easiest way is to use PyInstaller. The tutorial is in my GitHub repository description.

Lastly, I would like to share a trivia fact about sudoku: the number of possible 9x9 sudoku is 6670903752021072936960, which is incredibly large, right?


Here is an example of terminal output:


Note: If you convert the code file into an .exe file, the game application will open a console window automatically to run the game, because the game itself has no graphical user interface (GUI).

Comments

Popular posts from this blog

How to Predict Stock Prices with a Multilayer Perceptron (MLP) Neural Network

AI Explained: The Most Common Questions and Answers for Newbies

The Role of Mathematics in Artificial Intelligence