Sudoku - MetaTrader 5 Expert | MT5 EA Download - MetaTrader 5 Resources



Have you ever wanted to kill time or stretch your brain while waiting for important news events or monitoring open positions? Meta trader? This is easy sudoku puzzle . This non-trading expert can do a lot for Sudoku: generate boards, load existing boards, check the difficulty, let you play and solve Sudoku right in the MetaTrader chart. This is the classic 9x9 Sudoku, with 9 blocks and empty cells filled with numbers from 1 to 9.
When the program starts, a dialog box with a puzzle appears. If the input parameters are left at their default values, this is a special introduction where the source code is provided (you can find some details below).

You can adjust the input parameters to get random Sudoku with different characteristics. Please note that the new board is not generated after startup, but after clicking the "New" button in the dialog box. Other buttons are also available in the dialog: Hint displays automatically calculating candidates for empty cells (usually a fair player should deduce the candidates themselves, but this option can help you learn Sudoku if you are a newbie); Undo undoes the moves/changes performed on the board.

Here is an example of the log when generating a new Sudoku:
Shuffle... Arrangement completed: 137 of 200 are generating combinations... Completed at the nested level of guessing/guessing: 1 / Backtrack count: 0 Clue: 53 / Points difficulty: 1.08067 is not the only solution Completed at the nested level of guessing/guessing: 1 / Backtracking count: 0 Clue: 50 / Points difficulty: 1.14551 is not the only solution... Done in the nested level of guess/guess: 13 / Backtrack count: 0 clues: 21 / Points difficulty: 7.21605 is not the only solution Done in the nested level of guess/guess: 21 / Backtrack count: 0 clues: 21 / Points difficulty: 9.0458 Not the only solution completed in the nested level of guess/guess: 13 / Backtrack count: 0 Clue: 21 / Points Difficulty: 7.21605 Nested Levels Done in Guess/Guess: 17 / Backtrack Count: 0 Clue: 20 / Points Difficulty: 8.59135 Not the only solution is ready, Number of clues: 21 ……… . Chapter 742 ... 3 . 8 ... Chapter 749 . 8.1 ... 25 5 ………… ..7 … 3 . 5 ………… ..1 ... 24.5 . 8 ... The generated Sudoku is saved in the file rnd25473.txt
The last line mentions the file name of the new board. You can use it in input parameter sudoku to continue the same puzzle next time (in the next MetaTrader session). For each puzzle, the program remembers the current position in a special file (same as Sudoku, but with the additional extension ".log"). Additionally, all edits on the board are recorded in global variables and can be restored via the Undo button.
The number of clues and estimated difficulty are also shown in the chart's annotations. There is no standard scale for Sudoku difficulty, so after a while you will get used to the suggested ratings. Values below 2 represent easy level, 2 and a little above represent medium level, above 3 - difficult, requiring multiple guesses/guesses and backtracking (encountering a collision) if the guess is wrong. Unfortunately, it is not possible to generate a Sudoku of a specific difficulty on request. If you encounter a puzzle where the difficulty is not ideal, try generating another random difficulty.
You can enter a single number into a cell (to populate the edit field), or mark it with multiple numbers - so-called candidates, possible values. Candidates are shown in smaller green font. During the game you have to eliminate the candidates one by one, leaving only one number (shown in blue).
Please be careful: clicking the Prompt button will overwrite your manually entered candidates, if any. Clicking the prompt button a second time will completely hide the candidate. In other words, the prompt button acts as a switch for automatic help.
The program checks whether the puzzle has been solved only when all cells are filled with a single number. Of course, the board is also considered solved if it complies with the Sudoku rules.

The introductory Sudoku that comes with the program and displays by default is interesting in many ways.
Here's how the puzzle appears in the text file:
000700000 100000000 000430200 000000006 000509000 000000418 000081000 002000050 040000300
It can also be like this
000700000100000000000430200000000006000509000000000418000081000002000050040000300or
... 7 ... 1 ......... ... 43.2 .. ………… 6 … 5.9 … ...... Chapter 418 .... 81 ... .. 2 .... 5 . . 4 .... 3 ..
.
To build the program, unzip the attached res.zip using bmp-resources (it should create the MQL5\Include\Sudoku\Layouts\res\ folder (containing the bmp files)) and comment out the line #define CODEBASE_CHECKUP in the source code SudokuUI.mq5. Without this, some button images will not be available. This is a workaround for a strange limitation in the codebase that does not allow the use of BMP file, which is mainly used for graphic resources in MQL.
Attachment download
📎 rubbarray.mqh (3.94 KB)
📎 converter.mqh (0.7 KB)
📎 autoptr.mqh (0.78 KB)
📎 sudoku.mqh (46.2 KB)
📎 box.mqh (12.52 KB)
📎 grid.mqh (4.72 KB)
📎 gridtk.mqh (5.29 KB)
📎 maximizableappdialog.mqh (11.24 KB)
📎dialog.mqh (38.28 KB)
📎 intro17.txt (0.09 KB)
📎 sudokuui.mqh (22.28 KB)
📎 sudokuui.mq5 (2.1 KB)
Source: MQL5 #26624
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •