![]() ![]() If you’re a TypeScript person and would like to change things, please feel free to raise an issue or open a pull request. In the case asked about here, a -1 and n 60. We can re-arrange the division equation above for r to get r a - nq. You can check it all out on the GitHub page for the repo. One of the useful applications is the ability to use to 'wrap' co-ordinates so that they loop back on themselves at the edges, as done in the implementation of the Game of Life seen in the above code. Test ( ' when there is a glider on the board, it moves ', () =>, 250 ) I’m going to use jest for the tests, which needs some help to work well with TS. I could start by copying my tests from the JS implementation I wrote years ago, but that would ruin some of the fun and purpose of this exercise. It’s a very effective tool for teaching basic TDD to junior developers, and I’d recommend it. The following four rules define the evolution of the ‘game’: 1. The destiny of each these tiny imaginary beings is determined by the eight neighbouring cells that surround it. Each cell in the scene holds one of two states dead (black) or alive (white). In fact, my first exposure to Conway’s Game was during an exercise intended to demonstrate how Test-Driven Development (TDD) works. A GPU simulation of Conway’s Game of Life a basic cellular automation. Whenever I build the GOL I insist on writing tests first. Or, if you want to see my favourite implementation of GoL I’ve done, check out the one I made with React. I’m going to write this devlog as I go, so I may include in it some challenges I’ve faced as they may be interesting to read about and learn from.ĭon’t wanna read this? Just want the code? Here is the GitHub repo. So, starting with the Game of Life is as good as any start with the language. However, I haven’t used it more than once or twice in small ways before. ![]() I suspect one day I will have a job where I’ll need to write a lot of TypeScript. It’s quite common these days for JS developers to espouse the benefits of TypeScript. In some cases, it could be a good introduction which leads to more serious use of the language, like a tasting menu of code. And finally, I do it because I’ll never have time to learn all the programming languages, but I may have time to at least expose myself to a little bit of them. ![]() I do this because I really like the Game of Life as a concept. I do this because t’s fun to have a collection of repos that do the same thing with different technologies. So far, I’ve done JavaScript, JavaScript with React, Python and Go. I have an ongoing project on GitHub to build a collection of implementations of Conway’s Game of Life using various technologies. Published 27 November 2020 in Vancouver, BC, Canada (~10min read) Preamble The Game of Life in TypeScript - Dan Hough - Independent Software Developer Dan Hough ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |