⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cantbeelsewhere.java

📁 一个Java写的数独游戏
💻 JAVA
字号:
/* * This file is part of MUSoSu. * * MUSoSu is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License. * * MUSoSu is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MUSoSu.  If not, see <http://www.gnu.org/licenses/>. */package sudokuSolver;import sudoku.Convert;import sudoku.Sudoku;/** * <p><code>CantBeElsewhere</code> is a simple Solving method which places a * value in a square, if there is no other possible square where it could * be put.</p> * @author Visvardis Marios * @since version 0.8.4 */public class CantBeElsewhere extends SolveMethod{	public CantBeElsewhere(Sudoku game){		super("Can't be elsewhere", SolveMethod.MODERATE, game);	}		public int passOnce(){		int count; int contrib = 0;		int index, mode;		int position = -1;				for(int i = 0; i < 9; i++){			for(mode = 0; mode < 3; mode++){				for(int num = 1; num < 10; num++){					count = 0;					for(int j = 0; j < 9; j++){						index = Convert.translateToIndex(mode, i, j);						if(game.getPossibles(index).contains(num)){							count++;							position = index;						}					}					if(count == 1){						add(position, num);						contrib++;					}				}			}		}		contribution += contrib;		return contrib;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -