Developing my Development & Simple Game Design
When it comes to me and coding there’s a lot to talk about. I initially started back when I was 12 years old. Back then, I’d just got my first proper PC (and by proper I mean one with a GUI), I had access to the internet and I started my hand and web pages. Sure back then they were nothing fancy, not even dynamic, but little did I know at the time, it would be the first step in my now established career.
24 years on and things have changed drastically. I predominantly work in C#, leveraging the .NET platform, and while I’m a good programmer (of course I would say that) I’m always quite wary of the fact that I’m completely self taught in both the language and the framework. All the way through university, C++ was the language of choice, so when I stepped into my first job as a graduate in 2008, I was learning as I went along, grabbing everything I could from the projects I had available to me.
As a result of this approach, I’m always quite wary of my work and my coding. Whilst I’m confident of my ability, I’m always left with a niggling thought at the back of my mind of “What if I’m coding all wrong? What if my approaches and design choices are complete garbage? If I was to go for a new job, would I be laughed out of the interview room?”. My worries and lack of confidence isn’t helped either in a way by my current role as I’m a “One-man-Deprtment”, so I don’t have somebody to chat to or even say, “Hey, I wrote this piece of code. Can you review it for me”.
So I’ve had a thought (oh dear) and that is to make more of an effort to spend time developing my skills. Now sure I’ve had thoughts like this before, so what’s different this time? Well for starters I’ve got books and I’ve subscribed to a whole bunch of developers on YouTube. In addition, I’ve been back to the Microsoft Learn site (previously knows as MVA), bookmarked a number of development paths and am starting to chip away at them. My approach this time however is “no area is too amateur for me”. By this I mean I’m not only looking at the more advanced videos and material, but I’m also targeting the basics, in an effort to re-enforce the my current skill set and potentially correct any problem areas that arise from this approach.
So I decided to go out and look for a first project to work on and then one dropped right into my YouTube subscriber feed. I’ve started to follow a professor from the university of Phoenix called Shad Sluiter. I’ve noticed that he seems to post a variety of content to YouTube, some of which seems to be course material to support lectures / seminars, however every now and then he posts open projects / tutorials. The other day he posted a video starting the works on a Beginners “Tic-Tac-Toe” game and I thought this could be a great start (link to video here: https://www.youtube.com/watch?v=gTt1iqVs0_U). It seems like he was going to start with a basic console application in .NET Core (something which I’m looking into using more as opposed to .NET Standard), but then there would be future episodes taking the application to more advanced stages, eventually creating a GUI for it.
So I opened the video up, jumped into Visual Studio and started to follow along. Although I was following along for a start, it wasn’t long before I started to go off on a tangent, where I was using my own coding knowledge to create my own methods. Despite this, I continued to have the video running, just to be sure I was along the same lines as Shad. By the end of the project, I had my very own iteration of this game within a console app, however I was left with some interesting thoughts about “What more can I do to make this better?” Sure, we all know that Tic-Tac-Toe isn’t the most complex of games (heck, there’s only 9 elements to the whole thing), but my thoughts on improvement were more about the AI, and how I could make the computer more competitive for the the player.
There are really two main points of focus on the CPU difficulty here, an Easy mode and Hard mode. The easy mode is pretty much what I’ve developed so far. The CPU just picks a random number between 1 and 9 and places it’s marker on the board accordingly. Nothing special going on there and really no sort of challenge for the player. Heck, I’ve played about 15 games against the computer, purposely trying to lose and I’ve not managed to lose a single game yet (I guess I’m not trying hard enough). Now while it’s a great feeling to have a 100% success rate, it’s not particularly satisfying to be unchallenged by your opponent.
I already have a good idea about creating the AI (if you can call it AI) for the game to give the player more of a challenge. I’ve never really created a single player game where you’re playing against the computer, so this exciting for me to thing about. The way I plan on going about this is to have numerous checks that the CPU will do against the game board to see where the optimal place is to make it’s move. It’s AI will run down a certain precedence, which I believe to be the following:
- Check along all rows, columns and diagonals to see if there are already 2 CPU pieces placed and where the third cell is empty. If this condition is met, place the piece here as this will win the game
- Check along all rows, columns and diagonals to see if there are already 2 Player pieces placed and where the third cell is empty. If this condition is met, place the piece here as this will prevent the player from winning
- Look for an empty space and place a piece in a random empty spot.
Now like I said above, I don’t know that you can really call this AI as it’s pretty simple, but it will give the CPU a “brain” as such, so rather than just randomly placing pieces down, it makes a more logical choice.
On other addition that I have thought about adding at this point is to randomly choose who starts the game. At the moment, the player always begins, which some may argue gives the player the upper hand. A simple roll of the dice at the start of the game to decide the starting player would certainly spice things up and potentially add to the difficulty.
There’s a whole world of things which I want to work on in this project and I think having something this simple is a great starting block. In addition, it will also be interesting to see how I progress the game, as opposed to the way Shad does when his next instalment comes out on YouTube. As the project progresses on his side, I’m also looking forward to seeing his coding practises going forward, in the hope that there’s lots I can take from it to develop as an individual. I have a git repo where you can see my progress up to now, available here: https://github.com/nockscitney/TicTacToeGame
If you’re a developer I’d be interested to hear you approaches to learning and personal development, and please don’t be afraid to share any links, books or resources you think could help. I’m always interested in the way others work and learn. I’m also interested to hear any ideas or feedback you may have so that I can improve my game further, whether it be features or improvement to the AI itself.
Thanks for reading and have a great day! 😀