abstracted action and buy phases into one function, added a Heuristic function type (in case it needs to change in the future, the type only needs to be changed in one place)