space-invaders
Oh Oh! Space Invaders are trying to infitrate your terminal. Here is an idea on how to find them
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (9.5%) to scientific vocabulary
Repository
Oh Oh! Space Invaders are trying to infitrate your terminal. Here is an idea on how to find them
Basic Info
- Host: GitHub
- Owner: megarami
- License: other
- Language: Ruby
- Default Branch: main
- Size: 65.4 KB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
Space Invaders Detector
This application detects Space Invader patterns in radar samples. By using pattern matching with customizable similarity thresholds, it can identify potential invaders even with noise and partial visibility.
Features
- Detect multiple known Space Invader patterns in radar samples
- Multiple detection algorithms with pluggable architecture
- Adjust similarity threshold for detection sensitivity
- Handle partially visible invaders at radar edges
- Configurable via command-line options
- Filter detection by invader types
- Extensible design for adding new invader patterns and algorithms
Requirements
- Ruby 3.4.2 or higher
- Bundler
Installation
Clone the repository:
bash git clone https://github.com/megarami/space-invaders cd space_invadersInstall dependencies:
bash bundle install
Usage
Run the detector with a radar sample file:
bash
ruby bin/run_detector.rb radar_1.txt
Command Line Options
Usage: run_detector.rb [options] RADAR_FILE
-s, --similarity FLOAT Minimum similarity threshold (default: 0.7)
-i, --invaders LIST Invader types to detect: large, small, or all (default: large,small)
-a, --algorithm ALGORITHM Detection algorithm to use: naive, cross, block (default: naive)
--[no-]visualization Enable/disable visualization (default: true)
-f, --format FORMAT Output format: text or ascii (default: text)
-v, --visibility FLOAT Minimum visibility threshold (default: 0.5)
-d, --duplicate-threshold FLOAT Duplicate detection threshold (default: 0.1)
-h, --help Show this help message
Examples
Detect all invaders with default settings:
bash
ruby bin/run_detector.rb samples/radar1.txt
Detect with a lower similarity threshold (more sensitive):
bash
ruby bin/run_detector.rb -s 0.6 samples/radar_1.txt
Detect only small invaders:
bash
ruby bin/run_detector.rb -i small samples/radar_1.txt
Use a specific detection algorithm:
bash
ruby bin/run_detector.rb -a cross samples/radar_1.txt
Disable visualization output:
bash
ruby bin/run_detector.rb --no-visualization samples/radar_1.txt
Known Invader Patterns
Large Invader
--o-----o--
---o---o---
--ooooooo--
-oo-ooo-oo-
ooooooooooo
o-ooooooo-o
o-o-----o-o
---oo-oo---
Small Invader
---oo---
--oooo--
-oooooo-
oo-oo-oo
oooooooo
--o--o--
-o-oo-o-
o-o--o-o
How It Works
- The application loads the radar sample and known invader patterns
- For each invader, it scans the radar by sliding a window across all possible positions
- At each position, it calculates the similarity between the invader pattern and the radar data
- If the similarity exceeds the threshold and enough of the pattern is visible, it's considered a match
- Duplicate matches (same invader in very close positions) are filtered out
- Results are displayed, showing each match with its position and similarity score
Detection Algorithms
The application supports multiple detection algorithms:
- Naive Detection Algorithm (naive) - A straightforward sliding window approach that compares each pattern position.
- Cross Correlation Algorithm (cross) - Uses cross-correlation techniques for more efficient detection.
- Block Scanning Algorithm (block) - Optimized algorithm that scans in blocks for faster processing.
Adding New Invader Patterns
To add a new invader pattern, simply create a new file in the patterns folder with your pattern.
For example, to add a medium invader pattern, create patterns/medium_invader.txt:
```
Your pattern here using o for invader pixels
and - or spaces for empty pixels
```
Adding New Detection Algorithms
To add a new detection algorithm:
- Create a new algorithm class in
lib/space_invaders/algorithms/(e.g.,enhanced_algorithm.rb):
```ruby
frozenstringliteral: true
module SpaceInvaders class EnhancedAlgorithm < DetectionAlgorithm def detect(radar, invader, threshold) # Your detection logic here end end end ```
- Register your algorithm with the registry in your initialization code:
ruby
SpaceInvaders::AlgorithmRegistry.register('enhanced', EnhancedAlgorithm)
Running Tests
Run the test suite with:
bash
bundle exec rspec
To check code quality:
bash
bundle exec rubocop
License
This project is licensed under the MIT License - see the LICENSE file for details.
Owner
- Name: Nedim Ramic
- Login: megarami
- Kind: user
- Location: Sarajevo, Bosnia and Herzegovina
- Repositories: 1
- Profile: https://github.com/megarami
Citation (CITATION.cff)
cff-version: 1.2.0
message: Please use the following metadata when citing this project in your work.
title: Space Invaders
abstract:
version: 0.0.0
license: Hippocratic-2.1
date-released: 2025-02-18
authors:
- family-names:
given-names:
affiliation: %<organization_label>s
orcid: https://orcid.org/
keywords:
- ruby
repository-code: https://github.com/undefined/space_invaders
repository-artifact: https://rubygems.org/gems/space_invaders
url: https://undefined.io/projects/space_invaders
GitHub Events
Total
- Push event: 25
- Create event: 2
Last Year
- Push event: 25
- Create event: 2
Dependencies
- amazing_print ~> 1.7 development
- caliber ~> 0.68 development
- debug ~> 1.10 development
- git-lint ~> 9.0 development
- irb-kit ~> 1.1 development
- rake ~> 13.2 development
- reek ~> 6.4 development
- repl_type_completor ~> 0.1 development
- rspec ~> 3.13 development
- simplecov ~> 0.22 development
- awesome_print ~> 1.9
- refinements ~> 13.0
- zeitwerk ~> 2.7
- amazing_print 1.7.2
- ast 2.4.2
- awesome_print 1.9.2
- bigdecimal 3.1.9
- bundler 2.6.3
- caliber 0.71.0
- cogger 1.1.0
- concurrent-ruby 1.3.5
- containable 1.1.0
- core 2.1.0
- date 3.4.1
- debug 1.10.0
- diff-lcs 1.6.0
- docile 1.4.1
- dry-configurable 1.3.0
- dry-core 1.1.0
- dry-inflector 1.2.0
- dry-initializer 3.2.0
- dry-logic 1.6.0
- dry-monads 1.7.1
- dry-schema 1.13.4
- dry-types 1.8.2
- etcher 3.1.0
- git-lint 9.1.0
- gitt 4.2.0
- infusible 4.2.0
- io-console 0.8.0
- irb 1.15.1
- irb-kit 1.1.0
- json 2.10.1
- language_server-protocol 3.17.0.4
- logger 1.6.6
- marameters 4.2.0
- optparse 0.6.0
- parallel 1.26.3
- parser 3.3.7.1
- pp 0.6.2
- prettyprint 0.2.0
- prism 1.3.0
- psych 5.2.3
- racc 1.8.1
- rainbow 3.1.1
- rake 13.2.1
- rbs 3.8.1
- rdoc 6.12.0
- reek 6.4.0
- refinements 13.1.0
- regexp_parser 2.10.0
- reline 0.6.0
- repl_type_completor 0.1.10
- rexml 3.4.1
- rspec 3.13.0
- rspec-core 3.13.3
- rspec-expectations 3.13.3
- rspec-mocks 3.13.2
- rspec-support 3.13.2
- rubocop 1.71.2
- rubocop-ast 1.38.0
- rubocop-capybara 2.21.0
- rubocop-disable_syntax 0.1.1
- rubocop-packaging 0.5.2
- rubocop-performance 1.23.1
- rubocop-rake 0.6.0
- rubocop-rspec 3.4.0
- rubocop-thread_safety 0.6.0
- ruby-progressbar 1.13.0
- runcom 12.1.0
- simplecov 0.22.0
- simplecov-html 0.13.1
- simplecov_json_formatter 0.1.4
- sod 1.1.0
- spek 4.1.0
- stringio 3.1.3
- tone 2.1.0
- unicode-display_width 3.1.4
- unicode-emoji 4.0.4
- versionaire 14.1.0
- xdg 9.1.0
- zeitwerk 2.7.2