Source code for bravo.utilities.automatic

from bravo.utilities.coords import XZ


[docs]def naive_scan(automaton, chunk): """ Utility function which can be used to implement a naive, slow, but thorough chunk scan for automatons. This method is designed to be directly useable on automaton classes to provide the `scan()` interface. This function depends on implementation details of ``Chunk``. """ acceptable = automaton.blocks for index, section in enumerate(chunk.sections): if section: for i, block in enumerate(section.blocks): if block in acceptable: coords = i & 0xf, (i >> 8) + index * 16, i >> 4 & 0xf automaton.feed(coords)
[docs]def column_scan(automaton, chunk): """ Utility function which provides a chunk scanner which only examines the tallest blocks in the chunk. This can be useful for automatons which only care about sunlit or elevated areas. This method can be used directly in automaton classes to provide `scan()`. """ acceptable = automaton.blocks for x, z in XZ: y = chunk.height_at(x, z) if chunk.get_block((x, y, z)) in acceptable: automaton.feed((x + chunk.x * 16, y, z + chunk.z * 16))