Commit 76bf4ce7 authored by Boris Mühmer's avatar Boris Mühmer
Browse files

removed debug section

parent 94e949ea
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
package wator

// Celler is just a simple cell.
type Celler interface {
	String() string
}

// Food is not water, but somthing that can be consumed.
type Food interface {
	Celler
	Age() int
	SetAge(int)
}

// Hunter is something that goes for food.
type Hunter interface {
	Food
	Ate() int
	SetAte(int)
}
+4 −35
Original line number Diff line number Diff line
@@ -77,45 +77,14 @@ func (w *Wator) Populate() error {
// Display the current state.
func (w *Wator) Display() error {
	var sb strings.Builder
	if w.Debug {
		sb.WriteString("+")
		for x := 0; x < w.Width; x++ {
			sb.WriteString("---+")
		}
		sb.WriteString("\n")
		for y := 0; y < w.Height; y++ {
			sb.WriteString("|")
			for x := 0; x < w.Width; x++ {
				p := position{x: x, y: y}
				s := fmt.Sprintf("%s", w.current.cells[p])
				sb.WriteString(s)
				age := w.current.cells[p].Age()
				switch age {
				case -1:
					sb.WriteString("  ")
				default:
					s := fmt.Sprintf("%2d", age)
					sb.WriteString(s)
				}
				sb.WriteString("|")
			}
			sb.WriteString("\n")
			sb.WriteString("+")
			for x := 0; x < w.Width; x++ {
				sb.WriteString("---+")
			}
			sb.WriteString("\n")
		}
	} else {
	for y := 0; y < w.Height; y++ {
		for x := 0; x < w.Width; x++ {
			p := position{x: x, y: y}
				s := fmt.Sprintf("%s", w.current.cells[p])
			s := fmt.Sprintf("%s", w.current.cells[p].String())
			sb.WriteString(s)
		}
		sb.WriteString("\n")
	}
	}
	fmt.Printf("%s", sb.String())
	return nil
}