Daniel Petersen's Blog

Developing two videogames -- 9001, an addictively fast paced arcade game, and It Usually Ends In Nuclear War, a strategy game which is something of a mix between Civilization and Stellaris.


Risk 2.0

Posted on 2015-04-04

Late last Saturday I decided to check out Typescript, which is a programming language which takes Javascript and adds static typing, classes, and a few other much needed features. I’m really liking it, it’s so much more of a joy to work with compared to regular Javascript. Javascript gets a lot of hate, and while I think a lot of that hate is unwarranted, it definitely can be improved upon, and there’s no doubt in my mind that Typescript is an improvement.

So I played around with Typescript and ended up making a clone of the board game Risk.

I’m hosting it here – Link
The code for it is here – Link

I have no idea what the proper project structure is for a Typescript project, nor do I know how to properly do version control with it. I suspect you’re not supposed to commit the .SLN file, but I can’t say that this project is important enough, or that I’m motivated enough to find out right now.

But yeah. Feature wise it’s complete, although I made a few sacrifices such as a lackluster UI, and I opted to allow infinite moves per turn. I think in the official version you can attack an unlimited amount of times a turn, but only move an army to a friendly territory once per turn.

This concession was made entirely for the AI, which I still need to finish. I imagine it won’t ever be good, but I think it’ll be all right once I finish up the code for making the AI capture a continent if it determines it has the numbers to do so, and spreading its armies better across continent chokepoints. There’s also one bug that I’ve encountered and need to squash, where occasionally territories won’t change owners after an attack. I’ve looked into it and I have absolutely no idea why that’s happening.

I’m thinking I’ll spend a few hours over the next week on finishing that up. This weekend, though, I’m going to continue to work on my eternal struggle, It Always Ends In Nuclear War. I think I have to occasionally take a break from working on It Always Ends In Nuclear War and do these smaller projects, or I’m going to lose my mind.

Copyright © - Daniel J. Petersen