如何生成简易/中/硬数独谜题? [英] How to generate easy/medium/hard sudoku puzzles?

查看:108
本文介绍了如何生成简易/中/硬数独谜题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个制作桌子的数独游戏,但我不知道如何知道哪个是简单/中等/硬。



我是什么尝试过:



我从网站上玩一个数独游戏,然后将其洗牌而不会使它无效...如果我从一个简单的开始它仍然很容易?并且很难坚持?

I have a Sudoku game that makes tables, but I can't know how to know which is easy/medium/hard.

What I have tried:

I take a Sudoku game from websites, and shuffle it without making it not valid... if I start with an easy one does it remain easy? and hard remains hard?

推荐答案

正如F-ES Sitecore所说:这不是一个编程问题。

说实话吧听起来很像你不知道自己在做什么。如果你采取数独谜题并洗牌,最可能的结果不是更容易或更难 - 它是无效的。记住拼图的规则:每组9个中有9个不同的数字,每个水平上有9个不同的数字,每个垂直方向有9个不同的数字。如果您将您提供给用户的信息洗牌,则不太可能符合这些规则,因此根本无法解决。这是很多,更难以洗牌,并确保结果是有效的,而不是首先生成有效的拼图!



和F-ES一样Sitecore说:硬度并非来自拼图中数字的任何内在组织,而是来自您在开始时向用户显示的值的数量和位置。除了使它成为一种非独特的解决方案之外,改组拼图并不会影响它。例如,混乱拼图可以揭示所有9值,而不是其他。这并没有给出一个独特的解决方案,它提供了大量可能的解决方案,这些解决方案可能很容易从中产生 - 但不能以任何方式匹配您的解决方案!



我没有尝试随机化这些值,而是开始研究代码是如何工作的 - 除非你打算在商店里出售这个代码,因为你之前的问题意味着要记住你是否会在诉讼中留下自己的权利。您正在使用您的应用程序中以任何方式违反该软件许可的任何代码。如果我是你,我会非常非常仔细地检查......
As F-ES Sitecore says: this isn't a programming question.
And to be honest it sounds a lot like you don't know what you are doing. If you take a Sudoku puzzle and "shuffle it" the most likely result is not "easier" or "harder" - it is invalid. Remember the rules for a puzzle: 9 different digits in each of the groups of nine, nine different on each horizontal, and nine different of each vertical. If you "shuffle" the information you present to the user, it is very unlikely to conform to these rules, and thus can't be solved at all. It's a lot, lot harder to shuffle it and ensure that the result is valid than it is to generate a valid puzzle in the first place!

And as F-ES Sitecore said: the "hardness" doesn't come from any intrinsic organisation of the numbers in the puzzle, it comes from the number and location of the values you reveal to the user at the start. Shuffling the puzzle doesn't affect that except to make it a non-unique solution. For example, a "shuffled" puzzle could reveal all the "9" values, and no other. That doesn't give a unique solution, it gives a huge range of possible solutions which may well be trivial to generate from that - but not match your "solution" in any way!

Instead of trying to randomise the values, I'd start looking at how the code works - except if you are planning on selling this in the store as your previous question implies remember that you are leaving yourself wide open for litigation if you are using any code in your app that breaches in any way the licence for that software. I'd check very, very carefully if I was you...


这篇关于如何生成简易/中/硬数独谜题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆