Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 66 additions & 26 deletions src/variety/kurotto.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,60 @@
if (!this.puzzle.execConfig("autocmp")) {
return false;
}
return this.checkComplete();
return this.checkComplete() && this.checkUnambiguous();
}
},
"Board@island": {
addExtraInfo: function() {
this.islandgraph = this.addInfoList(this.klass.AreaIslandGraph);
}
},

"Cell@mines": {
maxnum: 8,

checkComplete: function() {
if (!this.isValidNum()) {
return true;
}

var cnt = 0;
var cells = [
this.relcell(-2, -2),
this.relcell(0, -2),
this.relcell(2, -2),
this.relcell(-2, 0),
this.relcell(2, 0),
this.relcell(-2, 2),
this.relcell(0, 2),
this.relcell(2, 2)
];
for (var i = 0; i < 8; i++) {
if (
cells[i].group === "cell" &&
!cells[i].isnull &&
cells[i].isShade()
) {
cnt++;
}
}
return this.qnum === cnt;
},

checkUnambiguous: function() {
return true;
}
},

"Cell@kurotto,island": {
allowShade: function() {
return !(this.isValidNum() || this.qnum === -2);
},

allowUnshade: function() {
return !(this.isValidNum() || this.qnum === -2);
},

maxnum: function() {
var max = this.board.cell.length - 1;
return max <= 999 ? max : 999;
Expand Down Expand Up @@ -118,37 +163,32 @@
}
}
return this.qnum === cnt;
}
},
"Cell@mines": {
maxnum: 8,
},

checkComplete: function() {
checkUnambiguous: function() {
if (!this.isValidNum()) {
return true;
}

var cnt = 0;
var cells = [
this.relcell(-2, -2),
this.relcell(0, -2),
this.relcell(2, -2),
this.relcell(-2, 0),
this.relcell(2, 0),
this.relcell(-2, 2),
this.relcell(0, 2),
this.relcell(2, 2)
];
for (var i = 0; i < 8; i++) {
if (
cells[i].group === "cell" &&
!cells[i].isnull &&
cells[i].isShade()
) {
cnt++;
var cellsAndAdjacent = new Set();
var list = this.getdir4clist();
for (var i = 0; i < list.length; i++) {
var area = list[i][0].sblk;
if (area !== null) {
for (var j = 0; j < area.clist.length; j++) {
var sublist = area.clist[j].getdir4clist();
for (var k = 0; k < sublist.length; k++) {
cellsAndAdjacent.add(sublist[k][0]);
}
}
}
}
return this.qnum === cnt;
var satisfied = true;
cellsAndAdjacent.forEach(function(cell) {
if (!cell.isShadeDecided()) {
satisfied = false;
}
});
return satisfied;
}
},

Expand Down
36 changes: 35 additions & 1 deletion src/variety/tasquare.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,15 @@
if (!this.puzzle.execConfig("autocmp")) {
return false;
}
return this.checkComplete();
return this.checkComplete() && this.checkUnambiguous();
},

allowShade: function() {
return !this.isNum();
},

allowUnshade: function() {
return !this.isNum();
},

checkComplete: function() {
Expand All @@ -87,6 +95,32 @@
}

return this.isValidNum() ? this.qnum === cnt : cnt > 0;
},

checkUnambiguous: function() {
if (!this.isValidNum()) {
return true;
}
var cellsAndAdjacent = new Set();
var list = this.getdir4clist();
for (var i = 0; i < list.length; i++) {
var area = list[i][0].sblk;
if (area !== null) {
for (var j = 0; j < area.clist.length; j++) {
var sublist = area.clist[j].getdir4clist();
for (var k = 0; k < sublist.length; k++) {
cellsAndAdjacent.add(sublist[k][0]);
}
}
}
}
var satisfied = true;
cellsAndAdjacent.forEach(function(cell) {
if (!cell.isShadeDecided()) {
satisfied = false;
}
});
return satisfied;
}
},

Expand Down