{"id":49846755,"url":"https://github.com/singharyan006/battleship","last_synced_at":"2026-05-14T12:43:47.327Z","repository":{"id":305276176,"uuid":"1021264090","full_name":"singharyan006/battleship","owner":"singharyan006","description":"A classic Battleship game built with JavaScript using Test-Driven Development (TDD). Features intelligent AI, complete game logic, and 100% test coverage with Jest.","archived":false,"fork":false,"pushed_at":"2025-07-19T07:18:07.000Z","size":65,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-19T10:34:36.100Z","etag":null,"topics":["ai","battleship","es6-modules","game-development","javascript","jest","tdd","terminal-game","the-odin-project","unit-testing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/singharyan006.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-17T06:28:24.000Z","updated_at":"2025-07-19T07:18:09.000Z","dependencies_parsed_at":"2025-07-19T10:34:41.290Z","dependency_job_id":"70727d6b-5840-463c-be2d-443cfdfecb22","html_url":"https://github.com/singharyan006/battleship","commit_stats":null,"previous_names":["singharyan006/battleship"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/singharyan006/battleship","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singharyan006%2Fbattleship","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singharyan006%2Fbattleship/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singharyan006%2Fbattleship/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singharyan006%2Fbattleship/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/singharyan006","download_url":"https://codeload.github.com/singharyan006/battleship/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singharyan006%2Fbattleship/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33026037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","battleship","es6-modules","game-development","javascript","jest","tdd","terminal-game","the-odin-project","unit-testing"],"created_at":"2026-05-14T12:43:46.590Z","updated_at":"2026-05-14T12:43:47.275Z","avatar_url":"https://github.com/singharyan006.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚢 Battleship Game\n\nA classic Battleship game implemented in JavaScript using **Test-Driven Development (TDD)** methodology. Features a complete game engine with ship placement, attack tracking, player management, and terminal-based gameplay.\n\n![Tests](https://img.shields.io/badge/tests-15%2F15%20passing-brightgreen)\n![JavaScript](https://img.shields.io/badge/language-JavaScript-yellow)\n![Jest](https://img.shields.io/badge/testing-Jest-red)\n![TDD](https://img.shields.io/badge/methodology-TDD-blue)\n\n## 🎮 Features\n\n### Core Game Logic\n- ⚓ **Ship Module**: Ship creation, hit detection, and sink status\n- 🎯 **Gameboard**: 10x10 grid with ship placement and attack tracking\n- 👤 **Player System**: Human and computer players with move validation\n- 🤖 **AI Player**: Intelligent computer opponent with move tracking\n- 🎮 **Game Controller**: Turn-based gameplay logic\n- 💻 **Terminal Interface**: Command-line game runner\n\n### Development Features\n- ✅ **100% Test Coverage**: 15 comprehensive tests across 4 test suites\n- 🔄 **TDD Methodology**: Built using test-driven development\n- 📦 **ES Modules**: Modern JavaScript module system\n- 🧪 **Jest Testing**: Comprehensive unit testing suite\n- 🔧 **Babel Integration**: ESM compatibility for Jest\n\n## 🚀 Quick Start\n\n### Prerequisites\n- Node.js (v14+ recommended)\n- npm or yarn\n\n### Installation\n```bash\n# Clone the repository\ngit clone https://github.com/singharyan006/battleship.git\ncd battleship\n\n# Install dependencies\nnpm install\n\n# Run tests\nnpm test\n\n# Play the game (if terminal interface is complete)\nnpm start\n```\n\n## 🏗️ Project Structure\n\n```\nbattleship/\n├── src/\n│   ├── ship.js          # Ship creation and management\n│   ├── gameboard.js     # Game board logic and ship placement\n│   ├── player.js        # Player factory (human/computer)\n│   ├── ai.js           # AI player logic and move generation\n│   ├── game.js          # Game controller and turn management\n│   └── index.js         # Terminal game interface\n├── tests/\n│   ├── ship.test.js     # Ship module tests\n│   ├── gameboard.test.js # Gameboard tests\n│   ├── player.test.js   # Player system tests\n│   └── game.test.js     # Game logic tests\n├── .babelrc             # Babel configuration for ESM\n├── jest.config.js       # Jest testing configuration\n├── package.json         # Project dependencies and scripts\n└── README.md           # Project documentation\n```\n\n## 🧪 Testing\n\nThis project was built using **Test-Driven Development (TDD)**, with comprehensive test coverage:\n\n```bash\n# Run all tests\nnpm test\n\n# Run tests in watch mode\nnpm run test:watch\n\n# Run tests with coverage\nnpm run test:coverage\n```\n\n### Test Coverage\n- **Ship Module**: 3 tests - Creation, hit detection, sink status\n- **Gameboard Module**: 5 tests - Placement, attacks, win conditions\n- **Player Module**: 4 tests - Human/computer moves, validation\n- **Game Module**: 3 tests - Turn management, game flow\n\n**Total: 15/15 tests passing ✅**\n\n## 🎯 Game Rules\n\n### Classic Battleship\n1. Each player has a 10x10 grid\n2. Ships are placed on the grid (various sizes)\n3. Players take turns attacking coordinates\n4. First player to sink all opponent ships wins\n\n### Ship Types (Standard)\n- Carrier (5 spaces)\n- Battleship (4 spaces)\n- Cruiser (3 spaces)\n- Submarine (3 spaces)\n- Destroyer (2 spaces)\n\n## 🔧 Development\n\n### Built With TDD\n1. **Red**: Write failing test\n2. **Green**: Write minimal code to pass\n3. **Refactor**: Improve code while keeping tests green\n\n### Git Workflow\n- Feature branches for each module\n- Comprehensive commit messages\n- Merge to main after testing\n\n### Recent Development\n- ✅ Implemented core Ship module\n- ✅ Built Gameboard with attack tracking\n- ✅ Created Player system (human + AI)\n- ✅ Added dedicated AI module with smart move tracking\n- ✅ Added Game controller logic\n- ✅ Built terminal interface\n- ✅ Fixed coordinate parameter bug\n- ✅ Enhanced computer player with move validation\n- ✅ Achieved 100% test coverage\n\n## 🐛 Known Issues\n\n- Terminal interface may need refinement for better UX\n- Ship placement validation could be enhanced\n\n## 🚀 Future Enhancements\n\n- [ ] Enhanced AI strategy (hunt/target mode after hits)\n- [ ] Web-based GUI interface\n- [ ] Multiplayer support\n- [ ] Advanced ship placement validation\n- [ ] Game statistics tracking\n- [ ] Save/load game functionality\n- [ ] AI difficulty levels\n\n## 🤝 Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feat/amazing-feature`)\n3. Write tests for your feature (TDD approach)\n4. Implement the feature\n5. Ensure all tests pass (`npm test`)\n6. Commit your changes (`git commit -m 'feat: add amazing feature'`)\n7. Push to the branch (`git push origin feat/amazing-feature`)\n8. Open a Pull Request\n\n## 📝 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 👨‍💻 Author\n\n**Aryan Singh** - [@singharyan006](https://github.com/singharyan006)\n\n## 🙏 Acknowledgments\n\n- Built as part of [The Odin Project](https://www.theodinproject.com/) curriculum\n- Test-driven development methodology\n- Jest testing framework\n- Modern JavaScript ES Modules\n\n---\n\n*\"The way to get started is to quit talking and begin doing.\" - Walt Disney*\n\n🚢 **Happy Sailing!** ⚓\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsingharyan006%2Fbattleship","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsingharyan006%2Fbattleship","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsingharyan006%2Fbattleship/lists"}