leftiness / hex_math

MIT License
4 stars 1 forks source link

Make a line iterator #83

Closed leftiness closed 7 years ago

leftiness commented 7 years ago

Or maybe even implement iterator. Then maybe I could get the index from the iterator and not have to increment it myself.

leftiness commented 7 years ago

wip

What I did:

leftiness commented 7 years ago

Now that I've got this iterator stuff implemented, I should look at making other iterators.

Maybe Range/flood could use the same iterator with different predicates. Not sure.

Rotate and travel could maybe be iterators. They'd probably be a lot easier to write, but it also doesn't make as much sense. I mean.. maybe. Maybe you could provide arbitrary predicates to travel. Travel until you run out of move points maybe? Idk. Don't implement those yet. If I find a good use case, then do it. Otherwise it's just added complexity. Travel is already a very simple function, and it doesn't seem like he needs predicates.

Line of sight? I guess he could be an iterator. You could take from the iterator until you run out of vision distance or something? But... wouldn't you /always/ want to see as far as you can? There's no circumstance in which you would maybe want to break that loop /before/ you've seen everything that you can... Is there?

leftiness commented 7 years ago

Merged