mataqipan

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Feasible

func Feasible(x, y int) bool

Feasible 该点是不是可以走,超出棋盘界限或者已经走过,都不能走.

func InitWeight

func InitWeight()

InitWeight 初始化每个点的权值 初始为0; 对每个点进行探索,若方向可以行,则weight[i][j]++

func NextDirection

func NextDirection(c Spot) int

NextDirection 每次走下一步,选择下一步最少的权值,进行贪心算法

func SetWeight

func SetWeight(x, y int)

SetWeight 当(x,y)点被占用的时候,当前节点权值设置为9,位置(x,y)周围所有的可行点权值减1

func Solution

func Solution(x, y int) int

func UnsetWeight

func UnsetWeight(x, y int)

UnsetWeight 回退操作,需要重新计算weight[i][j]的权值, 依次探测周围,若可行,则weight[i][j]++; 其周围可行点的权值+1

Types

type Spot

type Spot struct {
	// contains filtered or unexported fields
}

Spot 保存当前点的位置及可行走方向是否走过

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL