I'm making an awesome settlers of catan game for scratch and have managed to get a long ways through it. But there's a problem, I NEED an AI brain to be able to play with the player. I have a vague idea on how this will work but I've never done it before.
So I could really use some pointers on how to do this.
If you want to take a look at my latest version of the project: http://scratch.mit.edu/projects/bullelk12/2703045
You should also know that all the pieces you see in the project are sprites not stamps. That should be a very helpful part of the AI.
Last edited by bullelk12 (2012-08-08 13:24:46)
Offline
bullelk12 wrote:
I'm making an awesome settlers of catan game for scratch and have managed to get a long ways through it. But there's a problem, I NEED an AI brain to be able to play with the player. I have a vague idea on how this will work but I've never done it before.
So I could really use some pointers on how to do this.
If you want to take a look at my latest version of the project: http://scratch.mit.edu/projects/bullelk12/2703045
You should also know that all the pieces you see in the project are sprites not stamps. That should be a very helpful part of the AI.
What does the AI need to do exactly?
Offline
I want to know how to get an AI to beat you at crazy 8s like boltbait
Offline
bullelk12 wrote:
It needs to make decisions about where the best location to place a settlement is and where to build the roads to aim for new locations. I think I can work out the rest.
I'm not sure exactly, but if you had the conditions of every section of land, like available water etc then it could go over an area, find the best tile and place a settlement. The pathfinding one i've never done but plenty of people have.
Offline
Basically you have to take into account
a) what resources you need
b) what the probability of gaining a resource is
That said, you could probably make a fairly decent AI if it simply tried to place settlements on the highest probability intersections, regardless of resources. For a simple AI, I'd do something like this:
go through all intersections < 3 roads away from settlements find the one with the highest combined probability try to build to it
The problem with this very simple code (apart from scarcity of certain resources) is that "distance" can often be different than distance "as the crow flies" (if another player blocks you off). So < 3 away from settlements would probably have to be replaced with a more complex path-finding algorithm to eliminate this problem.
For combine probability, I'd add the chance of the three hexagons together using these values:
2 & 12: 1
3 & 11: 2
4 & 10: 3
5 & 9: 4
6 & 8: 5
To add "what resources you need", the first thing you'll need to do is come up with an ideal ratio of resources. Here's an example:
Brick: 2
Wood: 2
Stone: 3
Wheat: 3
Sheep: 2
Sum: 12
Then you'd have to give greater weight to intersections with access to "scarce" resources. First I'd find you "income" by adding all you stone-territory-probability-numbers, wheat-territory-probability-numbers, etc.
Example: You have 5 territories
Brick(4)
Wood(2)
Stone(5)
Wood(3)
Wheat(6)
Brick Income = 3
Wood Income = 1+2 = 3
Stone Income = 4
Wheat Income = 5
Sheep Income = 0
Sum Income = 3+3+4+5 = 15
Now, the "ideal sum" is 12, so the ratio of each resource-income should be the same as (ideal_resource_income)*15/12
Ideal Brick Income = 2.5
Ideal Wood Income = 2.5
Ideal Stone Income = 3.75
Ideal Wheat Income = 3.75
Ideal Sheep Income = 2.5
By comparing "ideal ___ income" with "____ income" you can see which resources you want.
Because 3>2.5 you don't really need brick
Because 3>2.5 you don't really need wood
Because 4>3.75 you don't really need stone
Because 5>3.75 you don't really need wood
Because 0<2.5 you really need sheep
I realize that the above post is very unorganized, but I've gotta go now. Good luck understanding that gibberish xD
Offline