generated from bethanyj28/go-api-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7703ef0
commit 85206f4
Showing
3 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package clairvoyant | ||
|
||
import "github.com/bethanyj28/battlesnek/internal" | ||
|
||
// Snake is a clairvoyant implementation of snake | ||
type Snake struct { | ||
lookahead int | ||
} | ||
|
||
// NewClairvoyantSnake creates a new clairvoyant snake | ||
func NewClairvoyantSnake(lookahead int) Snake { | ||
if lookahead == 0 { | ||
lookahead = 1 | ||
} | ||
return Snake{lookahead: lookahead} | ||
} | ||
|
||
// Move decides which move is ideal based on seeing the future | ||
func (s *Snake) Move(state internal.GameState) (internal.Action, error) { | ||
moves := drillDown(state, s.lookahead) | ||
|
||
return internal.Action{Move: moves.move}, nil | ||
} | ||
|
||
// Info ensures the snake is stylin and profilin | ||
func (s *Snake) Info() internal.Style { | ||
return internal.Style{ | ||
Color: "#00cc99", | ||
Head: "beluga", | ||
Tail: "freckled", | ||
} | ||
} | ||
|
||
type route struct { | ||
move string | ||
food int | ||
hazard int | ||
} | ||
|
||
func drillDown(state internal.GameState, lookahead int) route { | ||
return route{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters