refactor: extract grid abstraction for reuse

This commit is contained in:
Stevan Freeborn
2025-12-07 21:25:34 -06:00
parent d185ffda50
commit 4ca54ebb63
9 changed files with 418 additions and 131 deletions
+27
View File
@@ -0,0 +1,27 @@
// Package position provides types and functions to represent and manipulate positions and moves on a 2D grid.
package position
type Position interface {
Row() int
Column() int
}
type position struct {
row int
column int
}
func From(row int, column int) Position {
return position{
row: row,
column: column,
}
}
func (p position) Row() int {
return p.row
}
func (p position) Column() int {
return p.column
}