DarkChess (Chess with Fog of War)

https://playdarkchess.com / https://github.com/c0nrad/darkchess

I joined a new team at work, and figured it’d be fun to build something that uses their tech stack (java jersey/react), and thus DarkChess was born.

Why DarkChess?

I love Chess, I used to play on the chess team in high school and I was president of the Chess club back in college. It’s a fun game, but it’s a perfect information game meaning everyone has the exact same amount of information. Which is good, but it’d be fun if part of the game was to learn information.

And that’s what DarkChess is. In Darkchess you can only “see” pieces if they are in your capture zone.

Screen Shot 2019-03-16 at 11.42.46 AM.png

This brings a fun element to the game where you have to use pieces to scout where the enemy is located. It also allows you to be sneaky with assassinations, and leverage high visibility pieces and open lanes much more.

I built a little story mode with a series of challenges, give it a try:

http://playdarkchess.com/#/story/1

Tech Stack

I haven’t built a Java app in awhile, but it was fun to build one from scratch (using vscode too, no eclipse magic).

My personal opinions on the matter:

Backend

  • Maven was a real life saver for managing dependencies and the build chain
  • JUnit was simple enough for testing, I would of liked to learn more about cucumber, maybe next project
    • No surprise, but the chess engine I built had some interesting gotchas that were thankfully caught by unit tests
  • Morphia for MongoDB was interesting, (not sure if I’m using it correctly) GameDatastore.java
    • Unfortunately there was some issues with serializing a 2-dimension array. Had to write some pre-post serialization code that was a tiny bit frustrating
  • Jersey is very cool. I love using decorators for tagging function routes. Keeping the route/method/function in one spot is very nifty instead of having to declare the route<->function binding in a routes.js or something similar.

UI

  • The react documentation is amazing! https://reactjs.org/docs/hello-world.html
    • It’s so simple, and a fun read. After reading the 12 different steps I felt like I knew react decently well (I have a background in angularjs)
  • react-router-v4 was very confusing and frustrating for me (specially with typescript). Not being able to say “go to this state” everywhere unless it was specifically defined within the <HashRouter>. I def missed angular’s dependency injection and $state.
    • But again, I was probably just using it wrong
  • ‘create-react-app’ was pretty nify for building production ready minimized builds. no more messing around with gulp files or googles minimizer.

Deployment

  • I went full into AWS for my CI/CD pipeline
    • AWS CodeCommit – Git remote, kicks off the pipeline
    • AWS CodeBuild – builds and tests the code (buildspec.yml), published artifacts to s3
    • AWS CodeDeploy – deploys to my ec2 instances (appspec.yml), restarts the darkchess service and some housekeeping
  • Dependencies suck, so I build fat jars (maven shader), which means they just include the dependencies.
  • DNS entry through route53 to an ALIAS ALB infront of the ec2’s. (stateless thanks to MongoDB, so easy to scale).
  • Logs are sent to Cloudwatch using the aws cloudlog agent. It was a little weird to setup, but it works
  • The service is run in an init.d/ script with nohup
    • I’ve had 0 outages so far! (knock on wood)

Conclusion

Overall it was a very fun project. Learned a lot about fully setting up a java project.

Questions/comments/conseling/concerns? Always feel free to reach out šŸ™‚ c0nrad@c0nrad.io

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s