blocks.go 635 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package solver
  2. import (
  3. "embed"
  4. "log"
  5. "strconv"
  6. "strings"
  7. "time"
  8. )
  9. // Dirty AF. Not happy with this. 😒
  10. //
  11. //go:embed blocks.csv
  12. var f embed.FS
  13. func (solver *Solver) LoadBlocks() {
  14. defer solver.timeTrack(time.Now(), "Loaded blocks")
  15. log.Println("Loading blocks")
  16. var blocks []int
  17. file, err := f.ReadFile("blocks.csv")
  18. if err != nil {
  19. panic(err)
  20. }
  21. temp := strings.Split(string(file), "\n")
  22. for _, line := range temp {
  23. block, _ := strconv.Atoi(string(line))
  24. if block == 0 { // Ignore new-line at the end of the file.
  25. continue
  26. }
  27. blocks = append(blocks, block)
  28. }
  29. solver.Controller.Blocks = blocks
  30. }