I’m writing this having just completed my first attempt at implementing AI. It’s working! Mostly! How often is it beating me at the game? Sometimes. It’s not dominating, but it’s rarely far behind in terms of points. It has beaten me a few times although the lucky bugger did get the better tiles! I am not a Camelot The Build pro though, or even much of a competent player myself, so it remains to be seen how good this ai really is. I don’t expect it will ever be able to challenge the best players of this game. Camelot requires more cunning than I am capable of squeezing out of the math operations which currently make up it’s brain.
I talked a little about what I was planning to do a few weeks back, but I’ll go into detail about what I ended up with.
First off, last time I said that making it calculate all the highest scoring places to put it’s tiles was going to be straightforward. Nope. I wasn’t thinking about how the scoring system of the game gives points from adjacent tiles, gardens or the score doubling. This made things much more complicated and actually was the hardest part of the whole thing. The rest of the ideas I had last time made it in though.
In a nutshell, the AI analyses all it’s possible plays and effectively makes a pros/cons list for each one. If an actual human attempted this it would lead to an incredibly boring and drawn out game, but computers tend to be pretty quick at this sort of thing when numbers are involved! Although currently not quick enough, as there are hundreds of potential plays near the start of the game and it takes a little time to calculate– something I’ll be working to refine in the coming weeks.
The pro column consists of the total score it can get this turn, and that’s pretty much it. Simple. I’ve added a little incentive to score off of already placed tiles though- these plays will weigh higher in it’s decision making process.
The cons column is a little more complicated and consists of 1) how much potential there is for an opponent to score from the tiles it’s just played, and 2) the perceived ‘worth/future scoring potential’ of the tiles it’s using.
1) counts up the probability of the opponents having the surrounding tiles and combines that with the points they can get from the tiles it can put down. This was an attempt to stop it from playing it’s most valuable tiles right away for it’s opponents to play off (although in some situations it still does play them fairly early because it decides the points it will get is ‘worth it’). This is a tricky balance to get right I am finding. If I make this variable too conservative, the ai will pass on some opportunities to score massive points which may not be there in later turns. Too aggressive means it will lay down it’s highest scoring tiles at times where an opponent can get a similar or better score by using average tiles.
2) This is something I came up with after I found the AI frequently wasted it’s garden tiles where it could of just used an empty tile. It’s reasoning was that garden tiles are worth 1 where empty tiles are worth 0, so to get the most points this turn I’ll use that garden now (even though the garden wasn’t being used to it’s full potential by scoring off diagonal tiles). So I had to come up with a system, separate to the points in red, that gave value to special tiles like the garden tile. This is a value assigned to each tile based on it’s worth, I guess in essence this is it’s maximum scoring potential. At the start of the game this value is at it’s maximum because there is the biggest chance it can be used to it’s full potential at some point in the game. This value is dropped as the game progresses because that chance lowers. This value is part of the ‘cons’ list, so it will count against it in the decision making process. This ensures tiles like the garden tile will only be played when it can score enough points to ‘overcome/justify’ this value.
I hope all that makes some kind of sense. In the next dev blog I should be telling you about how the presentation is progressing as well as improvements to the AI.by