示例#1
0
文件: plan.go 项目: umisama/procon26
func (plan *Plan) isDuplicateStone(stone *materials.Stone) bool {
	for _, pos := range plan.positions {
		if pos.stone.Number() == stone.Number() {
			return true
		}
	}
	return false
}
示例#2
0
文件: plan.go 项目: umisama/procon26
func (plan *Plan) Put(x, y int, stone *materials.Stone) bool {
	if !plan.puttable(x, y, stone) {
		return false
	}
	// put stone
	plan.positions = append(plan.positions, &Position{
		x:     x,
		y:     y,
		stone: stone,
	})
	plan.refreshBuffer(buffer.Rect{x, y, stone.Height(), stone.Width()})
	return true
}
示例#3
0
文件: plan.go 项目: umisama/procon26
func (plan *Plan) canPutStone(x, y int, stone *materials.Stone) bool {
	for stoneX := 0; stoneX < stone.Width(); stoneX++ {
		for stoneY := 0; stoneY < stone.Height(); stoneY++ {
			if !stone.Get(stoneX, stoneY) {
				continue
			}
			if plan.Get(x+stoneX, y+stoneY) {
				return false
			}
		}
	}
	return true
}
示例#4
0
文件: plan.go 项目: umisama/procon26
func (plan *Plan) isExistRelatedStone(x, y int, stone *materials.Stone) bool {
	for stoneX := 0; stoneX < stone.Width(); stoneX++ {
		for stoneY := 0; stoneY < stone.Height(); stoneY++ {
			if !stone.Get(stoneX, stoneY) {
				continue
			}
			if plan.GetStoneDot(stoneX+x-1, stoneY+y) ||
				plan.GetStoneDot(stoneX+x, stoneY+y-1) ||
				plan.GetStoneDot(stoneX+x+1, stoneY+y) ||
				plan.GetStoneDot(stoneX+x, stoneY+y+1) {
				return true
			}
		}
	}
	return false
}