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
package main | |
import ( | |
"github.com/matburt/vindinium-go-engine" | |
"fmt" | |
) | |
var ( | |
client vindinium.Client | |
) | |
type MatBot struct {} | |
func (m MatBot) Move(state *vindinium.State) vindinium.Direction { | |
game := vindinium.NewGame(state) | |
distance := 100000 | |
goal := vindinium.Position{0,0} | |
//Go to the bar if we are getting thirsty | |
if state.Hero.Life <= 20 { | |
for tavern := range game.TavernsLocs { | |
if itemDistance := game.Board.ManhattanDistance(*state.Hero.Pos, tavern); itemDistance < distance { | |
distance = itemDistance | |
goal = tavern | |
} | |
} | |
} else { //Lets go get some gold!! | |
for mine := range game.MinesLocs { | |
if itemDistance := game.Board.ManhattanDistance(*state.Hero.Pos, mine); itemDistance < distance { | |
distance = itemDistance | |
goal = mine | |
} | |
} | |
} | |
pathSet, e := game.Board.ShortestPath(*state.Hero.Pos, goal) | |
if e != nil { | |
// Stay put if we can't find a way | |
return game.Board.GetDirection(*state.Hero.Pos, *state.Hero.Pos) | |
} | |
// Take the first step of the path | |
p, _ := pathSet.Pop() | |
return game.Board.GetDirection(*state.Hero.Pos, p) | |
} | |
func main() { | |
b := MatBot{} | |
c := vindinium.NewTrainingClient("bk7nu9em", "100", true, false, true, b) | |
c.Start() | |
c.Play() | |
fmt.Println("Game Finished") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment