A few years ago, there was a surge of "Twitch Plays" applications on Users would type in controller buttons into the chat, and the backend would use those inputs to play a (usually retro) game. The game would then be streamed back to the players with a delay. The goal was to beat the game.

Though these applications were plentiful, most of them were games that didn't make sense to be played from a chatroom (Indeed, this was part of the appeal). Battleship, however, is a game that can be played well from a chatroom, so I decided I wanted to write a "Twitch Plays Battleship" and name it "Chattleship"

What it does

It reads coordinates from a twitch chat, sends them off to a battleship server, and plays a game of battleship entirely with chat-read commands.

How I built it

I used a library called tmi.js to write the twitch chat bot that reads/writes messages to the chat. I used a simple HTML/CSS view for the board visualizer, since it was easy for me to serve from the same application that runs the battleship server. The bot and the server communicate via an HTTP api.

Challenges I ran into

Trying to find a balance between clean code and functionality was tough, and there were a few times I had to rewrite things so I could keep adding onto my product

Accomplishments that I'm proud of

I had a working twitch bot within the first hour of working, and I had a minimum viable product that could play games from a fixed board within 8 hours. I managed to get a decent AI working after about 2 hours of working on it. I hit the point where I was able to start streaming the game after about 15 hours of work.

What I learned

I learned how simple it is to write a twitch bot. I also learned a little bit about writing APIs, mainly the importance of making your API consistent in its structure. I also finally learned a fair amount about node.js and its ecosystem.

What's next for ChattleShip

An AI to play the game alongside twitch chat would be the ideal way to play (I did this!), since otherwise the game is stuck in singleplayer mode. I'd also love to get ChattleShip deployed on a server so I can keep it running. I'd also like to allow the chat to place their own battleships on the board.

Built With

Share this project: