Update go version and linting.
This commit is contained in:
parent
1940f03d40
commit
a1bf6ec0ff
4 changed files with 29 additions and 25 deletions
8
.github/workflows/test.yml
vendored
8
.github/workflows/test.yml
vendored
|
|
@ -3,7 +3,7 @@ name: Test
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GO_VERSION: 1.18.1
|
GO_VERSION: 1.20
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
|
|
@ -15,6 +15,7 @@ jobs:
|
||||||
- uses: actions/setup-go@main
|
- uses: actions/setup-go@main
|
||||||
with:
|
with:
|
||||||
go-version: '${{ env.GO_VERSION }}'
|
go-version: '${{ env.GO_VERSION }}'
|
||||||
|
check-latest: true
|
||||||
- name: Run gofmt
|
- name: Run gofmt
|
||||||
run: test -z $(gofmt -l .) || (gofmt -d . && exit 1)
|
run: test -z $(gofmt -l .) || (gofmt -d . && exit 1)
|
||||||
|
|
||||||
|
|
@ -27,9 +28,10 @@ jobs:
|
||||||
- uses: actions/setup-go@main
|
- uses: actions/setup-go@main
|
||||||
with:
|
with:
|
||||||
go-version: '${{ env.GO_VERSION }}'
|
go-version: '${{ env.GO_VERSION }}'
|
||||||
|
check-latest: true
|
||||||
- name: Run golangci-lint
|
- name: Run golangci-lint
|
||||||
run: |
|
run: |
|
||||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.45.2
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.1
|
||||||
golangci-lint run -v ./...
|
golangci-lint run -v ./...
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
|
@ -41,6 +43,7 @@ jobs:
|
||||||
- uses: actions/setup-go@main
|
- uses: actions/setup-go@main
|
||||||
with:
|
with:
|
||||||
go-version: '${{ env.GO_VERSION }}'
|
go-version: '${{ env.GO_VERSION }}'
|
||||||
|
check-latest: true
|
||||||
- name: Run go test
|
- name: Run go test
|
||||||
run: go test -race ./...
|
run: go test -race ./...
|
||||||
|
|
||||||
|
|
@ -53,6 +56,7 @@ jobs:
|
||||||
- uses: actions/setup-go@main
|
- uses: actions/setup-go@main
|
||||||
with:
|
with:
|
||||||
go-version: '${{ env.GO_VERSION }}'
|
go-version: '${{ env.GO_VERSION }}'
|
||||||
|
check-latest: true
|
||||||
- name: Run go build
|
- name: Run go build
|
||||||
run: |
|
run: |
|
||||||
go build ./cli/battlesnake
|
go build ./cli/battlesnake
|
||||||
|
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,5 +1,4 @@
|
||||||
# Editors
|
# Editors
|
||||||
.cmd
|
|
||||||
.devcontainer
|
.devcontainer
|
||||||
.vscode
|
.vscode
|
||||||
.idea
|
.idea
|
||||||
|
|
|
||||||
5
.golangci.yaml
Normal file
5
.golangci.yaml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
issues:
|
||||||
|
exclude-rules:
|
||||||
|
- linters:
|
||||||
|
- staticcheck
|
||||||
|
text: "SA1019:"
|
||||||
|
|
@ -216,9 +216,9 @@ func (m SoloMazeMap) SubdivideRoom(tempBoardState *rules.BoardState, rand rules.
|
||||||
|
|
||||||
if DEBUG_MAZE_GENERATION {
|
if DEBUG_MAZE_GENERATION {
|
||||||
log.Print("\n\n\n")
|
log.Print("\n\n\n")
|
||||||
log.Print(fmt.Sprintf("Subdividing room from %v to %v", lowPoint, highPoint))
|
log.Printf("Subdividing room from %v to %v", lowPoint, highPoint)
|
||||||
log.Print(fmt.Sprintf("disAllowedVertical %v", disAllowedVertical))
|
log.Printf("disAllowedVertical %v", disAllowedVertical)
|
||||||
log.Print(fmt.Sprintf("disAllowedHorizontal %v", disAllowedHorizontal))
|
log.Printf("disAllowedHorizontal %v", disAllowedHorizontal)
|
||||||
printMap(tempBoardState)
|
printMap(tempBoardState)
|
||||||
fmt.Print("Press 'Enter' to continue...")
|
fmt.Print("Press 'Enter' to continue...")
|
||||||
_, e := bufio.NewReader(os.Stdin).ReadBytes('\n')
|
_, e := bufio.NewReader(os.Stdin).ReadBytes('\n')
|
||||||
|
|
@ -245,7 +245,7 @@ func (m SoloMazeMap) SubdivideRoom(tempBoardState *rules.BoardState, rand rules.
|
||||||
if len(verticalChoices) > 0 {
|
if len(verticalChoices) > 0 {
|
||||||
verticalWallPosition = verticalChoices[rand.Intn(len(verticalChoices))]
|
verticalWallPosition = verticalChoices[rand.Intn(len(verticalChoices))]
|
||||||
if DEBUG_MAZE_GENERATION {
|
if DEBUG_MAZE_GENERATION {
|
||||||
log.Print(fmt.Sprintf("drawing Vertical Wall at %v", verticalWallPosition))
|
log.Printf("drawing Vertical Wall at %v\n", verticalWallPosition)
|
||||||
}
|
}
|
||||||
|
|
||||||
for y := lowPoint.Y; y <= highPoint.Y; y++ {
|
for y := lowPoint.Y; y <= highPoint.Y; y++ {
|
||||||
|
|
@ -265,7 +265,7 @@ func (m SoloMazeMap) SubdivideRoom(tempBoardState *rules.BoardState, rand rules.
|
||||||
if len(horizontalChoices) > 0 {
|
if len(horizontalChoices) > 0 {
|
||||||
horizontalWallPosition = horizontalChoices[rand.Intn(len(horizontalChoices))]
|
horizontalWallPosition = horizontalChoices[rand.Intn(len(horizontalChoices))]
|
||||||
if DEBUG_MAZE_GENERATION {
|
if DEBUG_MAZE_GENERATION {
|
||||||
log.Print(fmt.Sprintf("drawing horizontal Wall at %v", horizontalWallPosition))
|
log.Printf("drawing horizontal Wall at %v\n", horizontalWallPosition)
|
||||||
}
|
}
|
||||||
|
|
||||||
for x := lowPoint.X; x <= highPoint.X; x++ {
|
for x := lowPoint.X; x <= highPoint.X; x++ {
|
||||||
|
|
@ -289,7 +289,7 @@ func (m SoloMazeMap) SubdivideRoom(tempBoardState *rules.BoardState, rand rules.
|
||||||
disAllowedHorizontal = append(disAllowedHorizontal, hole.Y)
|
disAllowedHorizontal = append(disAllowedHorizontal, hole.Y)
|
||||||
}
|
}
|
||||||
if DEBUG_MAZE_GENERATION {
|
if DEBUG_MAZE_GENERATION {
|
||||||
log.Print(fmt.Sprintf("Vertical Cuts are at %v", verticalHoles))
|
log.Printf("Vertical Cuts are at %v\n", verticalHoles)
|
||||||
}
|
}
|
||||||
|
|
||||||
newNewHorizontalWall, horizontalHoles := cutHoleSingle(newHorizontalWall, intersectionPoint, rand)
|
newNewHorizontalWall, horizontalHoles := cutHoleSingle(newHorizontalWall, intersectionPoint, rand)
|
||||||
|
|
@ -298,7 +298,7 @@ func (m SoloMazeMap) SubdivideRoom(tempBoardState *rules.BoardState, rand rules.
|
||||||
disAllowedVertical = append(disAllowedVertical, hole.X)
|
disAllowedVertical = append(disAllowedVertical, hole.X)
|
||||||
}
|
}
|
||||||
if DEBUG_MAZE_GENERATION {
|
if DEBUG_MAZE_GENERATION {
|
||||||
log.Print(fmt.Sprintf("Horizontal Cuts are at %v", horizontalHoles))
|
log.Printf("Horizontal Cuts are at %v\n", horizontalHoles)
|
||||||
}
|
}
|
||||||
} else if len(newVerticalWall) > 1 {
|
} else if len(newVerticalWall) > 1 {
|
||||||
if DEBUG_MAZE_GENERATION {
|
if DEBUG_MAZE_GENERATION {
|
||||||
|
|
@ -310,7 +310,7 @@ func (m SoloMazeMap) SubdivideRoom(tempBoardState *rules.BoardState, rand rules.
|
||||||
|
|
||||||
disAllowedHorizontal = append(disAllowedHorizontal, hole.Y)
|
disAllowedHorizontal = append(disAllowedHorizontal, hole.Y)
|
||||||
if DEBUG_MAZE_GENERATION {
|
if DEBUG_MAZE_GENERATION {
|
||||||
log.Print(fmt.Sprintf("Cuts are at %v from index %v", hole, segmentToRemove))
|
log.Printf("Cuts are at %v from index %v", hole, segmentToRemove)
|
||||||
}
|
}
|
||||||
} else if len(newHorizontalWall) > 1 {
|
} else if len(newHorizontalWall) > 1 {
|
||||||
if DEBUG_MAZE_GENERATION {
|
if DEBUG_MAZE_GENERATION {
|
||||||
|
|
@ -322,16 +322,12 @@ func (m SoloMazeMap) SubdivideRoom(tempBoardState *rules.BoardState, rand rules.
|
||||||
|
|
||||||
disAllowedVertical = append(disAllowedVertical, hole.X)
|
disAllowedVertical = append(disAllowedVertical, hole.X)
|
||||||
if DEBUG_MAZE_GENERATION {
|
if DEBUG_MAZE_GENERATION {
|
||||||
log.Print(fmt.Sprintf("Cuts are at %v from index %v", hole, segmentToRemove))
|
log.Printf("Cuts are at %v from index %v", hole, segmentToRemove)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, point := range newVerticalWall {
|
tempBoardState.Hazards = append(tempBoardState.Hazards, newVerticalWall...)
|
||||||
tempBoardState.Hazards = append(tempBoardState.Hazards, point)
|
tempBoardState.Hazards = append(tempBoardState.Hazards, newHorizontalWall...)
|
||||||
}
|
|
||||||
for _, point := range newHorizontalWall {
|
|
||||||
tempBoardState.Hazards = append(tempBoardState.Hazards, point)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// We have both so need 4 sub-rooms
|
/// We have both so need 4 sub-rooms
|
||||||
if verticalWallPosition != -1 && horizontalWallPosition != -1 {
|
if verticalWallPosition != -1 && horizontalWallPosition != -1 {
|
||||||
|
|
@ -359,7 +355,7 @@ func (m SoloMazeMap) AdjustPosition(mazePosition rules.Point, actualBoardSize in
|
||||||
yAdjust := int((boardHeight - actualBoardSize) / 2)
|
yAdjust := int((boardHeight - actualBoardSize) / 2)
|
||||||
|
|
||||||
if DEBUG_MAZE_GENERATION {
|
if DEBUG_MAZE_GENERATION {
|
||||||
fmt.Println(fmt.Sprintf("currentLevel: %v, boardHeight: %v, boardWidth: %v, xAdjust: %v, yAdjust: %v", actualBoardSize, boardHeight, boardWidth, xAdjust, yAdjust))
|
fmt.Printf("currentLevel: %v, boardHeight: %v, boardWidth: %v, xAdjust: %v, yAdjust: %v\n", actualBoardSize, boardHeight, boardWidth, xAdjust, yAdjust)
|
||||||
}
|
}
|
||||||
|
|
||||||
return rules.Point{X: mazePosition.X + xAdjust, Y: mazePosition.Y + yAdjust}
|
return rules.Point{X: mazePosition.X + xAdjust, Y: mazePosition.Y + yAdjust}
|
||||||
|
|
@ -399,7 +395,7 @@ func (m SoloMazeMap) WriteBitState(boardState *rules.BoardState, state int64, ed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return value is first the wall that has been cut, the second is the holes we cut out
|
// Return value is first the wall that has been cut, the second is the holes we cut out
|
||||||
func cutHoles(s []rules.Point, intersection rules.Point, rand rules.Rand) ([]rules.Point, []rules.Point) {
|
func cutHoles(s []rules.Point, intersection rules.Point, rand rules.Rand) ([]rules.Point, []rules.Point) {
|
||||||
holes := make([]rules.Point, 0)
|
holes := make([]rules.Point, 0)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue