Quote: "could you show a quick demo if AI, can be simpler than this, "
Well, without getting into the detail of real game play, the basic AI for this type of game might be a comparison of credit expenditure vs earnings for each turn. These earnings would also be weighted depending on position (like even if it costs all of the computer credits to take down a fortress, it might be worth it to win the game). One turn would consist of a human player move and a computer player move. Assumingly, at the end of a complete turn, all owned property is tallied up for each player. What you have to have the computer do, is run simulations of what moves it could make and what moves the player could make to leave it with the most WEIGHTED credits possible.
It stores these moves in an array or table. As it finds a better move, it puts that move at the top of the heirarchy. You tell it how deep it should search. The deeper it searches for a move, in theory, the better chance it has of finding the best move. This depth is what would control the level of play. Also, the deeper it searches, the longer it will take to make a move.
Anyway, the choice for a better move is based on the criteria you give it. For example, the computer has 100 credits. A credit by itself only has it's own value so 100 credits = 100 credits.
Now a field has potential earnings. So we will weight the value of creating a field. Since it has earning potential, we need to tell the computer that it is a desirable thing to make. I want the return on the field to be higher than it's cost or else it isn't worth anything unless I project out several turns and add up it's earnings. But that makes things harder for me so I will just increase it's weighted value or it's earnings:
field_cost=-1
field_weight=+3
total_credits=field_cost + field_weight + credits
So. If the computer were to put down a field, in this scenario it's total credits would be 102 which is desirable because the credits increase. The costs and the weights are things you have to decide to see what plays out best. Remember, the computer will also suppose what the player would do. Now a player's retaliation would have a cost on the computers credits. Let's say after the computer placed a field in a particular place, the human can attack that field:
field_loss=-3
total_credits=total_credits+field_loss
Now the computer's credits are only worth 99 after one turn. So maybe placing that field in an area where the player could attack it isn't so desirable. However, the computer would compare it's total credits to the player's total credits after the end of this simulated turn to see who fairs best:
player_credits=100
player_field_attack=-1
player_total_credits=player_credits+player_field_attack
In this case, both the computer and the player end up with the same credits (99) so the computer's original move gives it no advantage.
You can handle this situation a couple different ways. If there are no better moves, then put it at the top of the heirarchy, but also don't allow the computer to keep playing the same move because it could be a stalemate if the player just attacks the field each time it is created because the credits balance. So have maybe a 2 or 3 move repetition code that would change the status of this move to undesirable.
The premise of cost and gain is applied throughout the entire board for all the different pieces and available moves. If a move would result in game victory, then the weight should be set to a number that couldn't be achieved by credit gain alone. How the computer makes a decision would be based on the most cost effective move. even if the computer can't come up with a better move than what it would predict the human player to do, it still has a best move, even if it is a losing move. This best move is the move that is always on top of the heirarchy table.
Enjoy your day.