Skip to content

Commit

Permalink
删除无用函数
Browse files Browse the repository at this point in the history
  • Loading branch information
obgnail committed Nov 13, 2022
1 parent e1c024a commit 5d12c32
Showing 1 changed file with 7 additions and 30 deletions.
37 changes: 7 additions & 30 deletions game.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const (
CellTypeMine CellType = 8 // 猜测是雷
CellTypeSafe CellType = 9 // 猜测不是雷
// 用于优化
CellTypeSafe2 CellType = 10
CellTypeDone CellType = 10 // 标记已处理,避免重复处理
)

func Play() {
Expand Down Expand Up @@ -248,38 +248,14 @@ func handleAlwaysCell(cells []*Cell) {
case CellTypeSafe:
//Logger.Debug("Strategy3(FlagSafe):")
FlagSafe(cell.row, cell.col)
setTableCell(cell.row, cell.col, CellTypeSafe2)
setTableCell(cell.row, cell.col, CellTypeDone)
case CellTypeMine:
//Logger.Debug("Strategy4(FlagMine):")
FlagMine(cell.row, cell.col)
}
}
}

func handlePassSituation333(passSituation *Situation) {
passSituation.RangeCell(func(idx int, cell *Cell) (stop bool) {
switch cell.CellType {
case CellTypeSafe:
//Logger.Debug("Strategy3(FlagSafe):")
FlagSafe(cell.row, cell.col)
setTableCell(cell.row, cell.col, CellTypeSafe2)
case CellTypeMine:
//Logger.Debug("Strategy4(FlagMine):")
FlagMine(cell.row, cell.col)
}
return false
})
}

func resolveSituation2(cell *Cell, neighbors map[CellType][]*Cell) (safe []*Cell, mine []*Cell) {
if len(neighbors[CellTypeMine])+len(neighbors[CellTypeFlag]) != int(cell.CellType) {
return nil, nil
}
safe = neighbors[CellTypeSafe]
mine = neighbors[CellTypeMine]
return safe, mine
}

// 根据situation,解出所有的Unknown
func resolveSituation(cell *Cell, situation *Situation) ([]*Cell, []*Cell) {
neighbors := GetNeighborList(cell.row, cell.col)
Expand Down Expand Up @@ -407,10 +383,10 @@ func IsSituationPass(cell *Cell, situation *Situation) bool {

value := int(cell.CellType)
m := GetNeighborMap(cell.row, cell.col)
flag := len(m[CellTypeFlag])
unknown := len(m[CellTypeUnknown])
_flag := len(m[CellTypeFlag])
_unknown := len(m[CellTypeUnknown])

if isMine+flag > value || unknown+flag < value {
if isMine+_flag > value || _unknown+_flag < value {
return false
}
return true
Expand Down Expand Up @@ -566,8 +542,9 @@ func ClearCell(row, col int, unknownCell []*Cell) {
FlagSafe(cell.row, cell.col)
}
}

for _, cell := range unknownCell {
setTableCell(cell.row, cell.col, CellTypeSafe2)
setTableCell(cell.row, cell.col, CellTypeDone)
}
SetFinish(row, col)
}
Expand Down

0 comments on commit 5d12c32

Please sign in to comment.