Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Territory: A Future Project

Author
Message
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 29th Nov 2007 13:56 Edited at: 29th Nov 2007 13:57
I have promised myself that I will finish breakout before I start this project but since it will be the first game I make with any sophisticated AI, and I have no idea when it comes to AI, I would like to hear what suggestions you guys have.

Territory is a grid based strategy game; The main aim being to control every tile on the board. You gain control of, and upgrade tiles by assigning credits to them.
You control a cursor that is moved around the board using the keyboard, the cursor is used to allocate credits to tiles.
Through assigning credits to tiles you can give them different properties:
Quote: "
* 1 credit = Field
Fields produce 1 credit per turn.
* 2 credits = Wall
Cursors cannot pass through wall squares.
* 4 credits = Gate
Only the owning cursor can pass through gate squares.
* 8 credits = Warehouse
Warehouses store credits that were not used by the last turn.
* 16 credits = Fortress
The cursor originates from a Fortress. All players must have at least one Fortress or they have lost the game.
"

Destroying an enemy square costs its current value and turns the square into a field owned by the attacker. e.g.
Quote: "
Blue attacks Red Field
Blue spends 1 credit and gains a Field.

Red attacks Blue Wall
Red spends 2 credits and gains a Field.
"


"You must be someone's friend to make comments about them." - MySpace lied.
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 29th Nov 2007 23:01
Looks like there are two ways to win - control all the squares, or eliminate the enemy fortress(es). From an AI stand point, since everything has a value, winning also has a value. You'll want the computer to go after the cheapest way to win, and that is going after a fortress directly without worrying about the rest of the board. Bascially, the AI will do a comparison with how many credits it has, how many it can earn based on the current board positions, how much it would cost at any given board position to take down an enemy fortress and the cheapest path to do it. The computer will take the cheapest path that it can or will be able to afford. Depending on how the cursor or pieces can be moved and the number of grid squares on the board, the computer could go through many iterations or nodes of possibilities each turn because the math doesn't seem too hard for this game. The way you describe the game, a brute force method of AI would probably do the trick.

You temper or change the value of the computer decision by not only equating the cheapest way to take down the fortresses, but you have to add value to whatever it builds. It will have to play both sides in order to make the correct moves (it never really plays for the human but just calculates the best human moves it can come up with based on it's own criteria for conquest). This all adds up to the cheapest move the computer can make while getting towards the it's goal. Since eliminating fortresses is also a method for winning, the computer would almost never find it cost effective to try and conquer the whole grid because that would require taking down the fortresses anyway and all the extra squares would be wasted time and resources - unless it's earnings per field were justification. So, certain board formations or certain areas of advancement may be worth more (programitcally) and thus make the computer try and build some sort of defense or offense. Otherwise, depending on who goes first, it would just be a battle of fields and credits. The first move from whichever player would be to eliminate as many enemy fields as possible (assuming credits are earned based on the condition of the board after the last turn). The opposing player just wouldn't have enough money to recover and retaliate to the same extent and within a few turns, the starting player would win.

So maybe instead of the square changing to the attacking color, it should just be left neutral. If the attacker wants it, they have to spend the money to build their own property type. That way, the attacker doesn't gain a credit advantage for this turn and neither would the defender even if they reclaimed the field on their turn because they would have to spend that extra credit to attack and then rebuild.

Just a few ideas... really depends on how the moves/turns are handled.

Enjoy your day.
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 30th Nov 2007 00:38 Edited at: 30th Nov 2007 00:38
Quote: "So maybe instead of the square changing to the attacking color, it should just be left neutral. If the attacker wants it, they have to spend the money to build their own property type. That way, the attacker doesn't gain a credit advantage for this turn and neither would the defender even if they reclaimed the field on their turn because they would have to spend that extra credit to attack and then rebuild."

That's a very good point, thanks

and you're right, controlling all the squares is pretty pointless if you can win by destroying the fortresses, which are squares anyway!

could you show a quick demo if AI, can be simpler than this, I'm a total noob at AI and don't even know how I should be thinking. I can't find any tutorials on AI either

Thanks very much Latch

"You must be someone's friend to make comments about them." - MySpace lied.
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 30th Nov 2007 12:26 Edited at: 30th Nov 2007 17:14
The playing area 'board' sounds like what DB's matrix was made for!

My initial thoughts on one way of doing it attached...

TDK_Man

Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 30th Nov 2007 22:20
It looks like chess
what are the different shades of colour for? (in the bitmap not the board)

"You must be someone's friend to make comments about them." - MySpace lied.
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 1st Dec 2007 02:08
Just dummy tiles. They could be replaced with whatever you wanted as I had no idea what the board for your game looked like.

Feel free to use the fort model I made if it's any use to you...

TDK_Man

Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 1st Dec 2007 18:05
@TDK
thanks, I didn't even think of making this in 3D.

"You must be someone's friend to make comments about them." - MySpace lied.
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th Dec 2007 21:00
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:



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:



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:



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.
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 6th Dec 2007 09:06
thanks Latch, that really helped
I can see my code ballooning out horribly trying to get it to work but I'm sure it will be good practice.

thanks bud

"You must be someone's friend to make comments about them." - MySpace lied.

Login to post a reply

Server time is: 2026-07-05 12:33:47
Your offset time is: 2026-07-05 12:33:47