To run the program:
> bin/find_invaders
To run the specs:
> rspec spec
I had to make some assumptions about requirements/effort, here's my list:
- Ignore rotation for invaders and the radar reading, everything is matched as given
- Invaders ar hardcoded as
Invaders::KNOWN_INVADERS
and new ones can be added easily here - Radar reading can be changed in toplevel radar_data file
Matching exact shapes will probably return bad results because of the possible noise. For that reason I implemented MatchStrategies The one used by the program computes the ratio of exact positional matches to all tiles for each invader.
For example:
Slice matches Invader
ooo-----o-- => --o-----o--
o--o-o-o--- => ---o---o---
--o-ooooo-- => --ooooooo--
oo--ooo-oo- => -oo-ooo-oo-
ooooooo-ooo => ooooooooooo
oooo--ooo-o => o-ooooooo-o
o-o-----o-o => o-o-----o-o
---oo-oo--- => ---oo-oo---
Confidence level: 0.875
MatchStrategy
is expected to return match level (0-1) in the runner (Invaders::Find
) I hardcoded
two confidence levels to show that with the lowel level we can find multiple suspectable regions.