AI Prodding Log Out | Topics | Search
Moderators | Register | Edit Profile

Zillions of Games Discussion Forum » Designing Games for Zillions » AI Prodding « Previous Next »

Author Message
Dan Troyka (Dtroyka)
Posted on Sunday, January 05, 2003 - 9:35 am:   

I received an email from another coder about a macro in the Groups ZRF that contains a bunch of adds, as many as forty in a row. I sent him a response explaining the purpose of the macro and he suggested that I post it here, so here goes:

The adds are part of a special move block that defines moves that can never be made but that are counted in Zillions' evaluation of board positions. The block tells Zillions that pieces are more valuable in the center 16 squares (5 adds), in the center 4 squares (5 additional adds), next to two friends (40 adds), or next to only one friend (20 adds).

In the piece definition the block is called "AI" and is given a special move-type called "non-move." The "non-moves" cannot be made because the move-type "moving" is given priority in the move-priorities statement. Even if the "non-moves" could be made they would be passes that only the computer could make because there is no movement before the adds.

The overall effect of the "AI" block is to give the computer a tendency to play in the center and to make local connections. If you comment out "(AI)" in the piece definition, you can see how Zillions plays without any guidance. Basically pieces tend to disperse from the center and not form any connections.

I first used this method in Gonnect, where it guides the AI to make blocking moves. It is surprising that it works because Zillions should not be considering moves that cannot be made. Of course it only works so well, but in connection games the alternative is usually completely random moves.
Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 120
Registered: 8-2000
Posted on Thursday, March 29, 2007 - 2:28 am:   

A very good discussion on AI prodding was inadvertantly started within a topic it did not fit into. I am going try to "transfer" the contents of that discussion here.
Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 121
Registered: 8-2000
Posted on Thursday, March 29, 2007 - 2:32 am:   

Mats W (Kålroten)
Posted on Friday, December 02, 2005 - 2:28 am:

--------------------------------------------------------------------------------
I just wanted to point out how remarkably effective the tweaking of the values of squares is, as in the updated versaion of Halatafl, that will be published tomorrow. Earlier I could beat Halatafl, but seldom anymore. Now it tends to attack on its stongest wing (where the piece majority is) and defend on its weaker. It now tends to keep defensive pieces on the first rank. In the image below move directions from the important squares have been added, and dummy pieces have been added to the extraneous positions (so that no piece can go there). The computer, as black, will now tend to operate on the right wing, and refrain from moving the two important leftmost defensive (and counter-attacking) pieces on the left wing. If these are moved, he will often move put new pieces there. The tendency towards repetition of moves is strongly reduced, as the computer now has goals within its move horizon, namely to move his pieces to stronger squares. It is surprising how easy it is to strongly improve the engine's play in this way, and teach positional knowledge to it.
Position prodding example
Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 122
Registered: 8-2000
Posted on Thursday, March 29, 2007 - 2:33 am:   

Greg Schmidt (Gschmidt)
Posted on Friday, December 02, 2005 - 7:58 pm:

--------------------------------------------------------------------------------
Could you elaborate on what you mean by "tweaking of the values of squares"? I assume you are creating multiple pieces per square dependent upon square location to create a board weighting. Is that what you mean?

Regards,
-- Greg
Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 123
Registered: 8-2000
Posted on Thursday, March 29, 2007 - 2:34 am:   

Mats W (Kålroten)
Posted on Saturday, December 03, 2005 - 2:10 am:

--------------------------------------------------------------------------------
In this particular example a square on the margin has three movements. I just add extra possible move directions (i.e. links) from these squares. These move directions goes to invisible squares outside the board. But the piece cannot go there anyway because it is blocked by a dummy piece. Nevertheless, the engine sees these squares as more powerful while they have more freedom of moves. Thus the engine tries to occupie these squares. This makes him go forward and attack in a very human way, or make defensive moves that are not merely short-sighted. So it improves the play considerably. In this particular case there is a strategical imbalance already in the opening. This is probably why this tweaking makes such a big difference. Earlier the engine, as black, often weakened its position on the left wing, creating a corridor for the enemy to attack the corner square. Now he avoids this. Moreover, as the corner square was beyond the move-horizon he didn't make consistent operations on the wing. But now he tries to conquer those "stronger" squares before the corner square. But as the corner-square then gets within the horizon, he continues his attack. Earlier the engine often moved important defensive pieces up from the first rank, as these squares are "weaker" than the second rank positions, as the latter have four move directions. But now I have given four move directions also to the c and e squares on the first rank. So the engine sees no motive to move these defensive pieces, except if there is a good reason.
Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 124
Registered: 8-2000
Posted on Thursday, March 29, 2007 - 2:34 am:   

Mats W (Kålroten)
Posted on Saturday, December 03, 2005 - 2:44 am:

--------------------------------------------------------------------------------
Correction: in Halatafl the squares on the margin have two freedom of moves and the others three, since pieces cannot go backwards.

Mats
Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 125
Registered: 8-2000
Posted on Thursday, March 29, 2007 - 2:35 am:   

Greg Schmidt (Gschmidt)
Posted on Saturday, December 03, 2005 - 8:43 am:

--------------------------------------------------------------------------------
Thanks for the explanation. I've seen the technique of using multiple "add"'s for a non-mobile piece to increase its value, but I've not seen your "tweaking" technique of creating additional (immobilized) directions from key board locations. The two techniques would seem to be complementary as they provide a means to do piece weighting and board weighting, respectively.

I find it interesting that Zillions considers potential movements even though they are blocked.

Regards,
-- Greg
Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 126
Registered: 8-2000
Posted on Thursday, March 29, 2007 - 2:37 am:   

Greg Schmidt (Gschmidt2)
New member
Username: Gschmidt2

Post Number: 10
Registered: 1-2007
Posted on Saturday, March 03, 2007 - 2:19 pm:

--------------------------------------------------------------------------------
"Tweaking" vs. "Bonus System" vs. ???

In partial reference to the above post:
Mats W (Kålroten) Posted on Friday, December 02, 2005 - 2:28 am:

DEFINITIONS:

Tweaking - To increase the valuation of a POSITION on the board by creating extra links from said position to a dummy position. The more links that are created, the greater the valuation of the position. The dummy positions are blocked by placing dummy pieces on them.

Bonus System - To increase the valuation of a MOVE by creating pieces in an invisible zone as a secondary effect of the move. The pieces do not move, but they can trick ZoG into believing they are more valuable by defining multiple adds. e.g.

(piece
(name Bonus3)
(moves (add add add))
)

The more adds, the higher valuation given to the MOVE that creates the bonus piece.

Is there a way to increase the valuation of a PIECE itself or is that what a bonus system effectively does as well?

Did I get this right?

Thanks -- Greg
Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 127
Registered: 8-2000
Posted on Thursday, March 29, 2007 - 2:38 am:   

Ronald W Brierley (Ronaldwb)
New member
Username: Ronaldwb

Post Number: 58
Registered: 2-2003
Posted on Sunday, March 04, 2007 - 8:57 am:

--------------------------------------------------------------------------------
According to my dictionary, tweak is defined to be a verb with one related meaning being ‘to fine tune’ whereas bonus is defined to be a noun with one related meaning being ‘a stimulus’.
I was interested to see that Karl Scherer uses bonuses in his programs but I have been too busy as yet to check in what way they are helpful since I am currently tweaking the values of the pieces in my torus chess game which is nearing completion.
Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 128
Registered: 8-2000
Posted on Thursday, March 29, 2007 - 2:39 am:   

Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 116
Registered: 8-2000
Posted on Monday, March 05, 2007 - 10:56 pm:

--------------------------------------------------------------------------------
Greg: "Tweaking" vs. "Bonus System" vs. ??? Did you get it right?

I am going to have to answer this in two posts. A short one first. I used move priorities in Cephalopod to increase piece values.

Define two move types "used" and "unused" then define the turn order so the "unused" moves never get used. Any moves assigned to the "unused" catagory increase the value of the piece.
Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 129
Registered: 8-2000
Posted on Thursday, March 29, 2007 - 2:40 am:   

Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 117
Registered: 8-2000
Posted on Wednesday, March 07, 2007 - 5:36 am:

--------------------------------------------------------------------------------
As it just so happens I came to the Zillions forums because I have been working on improving the AI play of Cannon and was looking for additional methods to use. Using a variation of the method I described in my previous post, I have been making the unused move value increase conditional on the piece moving to certain zones. Using an ELO rating formula in reverse to calculate relative rating change the improvements have been substantial: +219 points for the e1/f10 town starting positions and +502 points for the b1/i10 town starting positions. The purpose of this post is to explain what I know about the unused move method.

A good example of the need for piece value modification is Cephalopod which I did for Zillions about three months ago. There are six piece types representing mathematical values of one through six. A six can not be captured and is worth the most by far, a five less than that, a four a little less than a five etc. down to a one that is extremely easy to capture. However all the pieces use only drop moves and once a piece is dropped it does not move so Zillions gives all of the pieces the same base value of 100. Zillions then played the game very poorly.

Here are the Cephalopod move descriptions placed in the unused priority category and the new value of the pieces on the 5x5 default variant board.

1= no additional unused move = 100
2= ( n n n n e add ) = 160 or 189
3= (n n n e add) = 220 or 249
4= ( n n e w add) = 280 or309
5= (n n add) = 325 or 354
6= (add add) = 908

The value of a bare add like the 6-piece uses changes with the size of the board and the other moves of the piece. The value of the bare add used for the 6-piece on the 5x5 board is 504 for the first add and 404 for the second. In the case of Cephalopod 3x5 board the value of the bare add used for the 6-piece is 354 for the first add and 254 for the second add. For a chess queen the first bare add is worth about 980 and for a chess pawn the first bare add is worth about 1100. In the case of the game Cannon the first bare add is worth about 1,400 for the soldier piece. This can make using bare adds alone a blunt instrument for manipulating piece values.

One method of reducing the amount of piece value increase is to add directional movement such as is done with the 2, 3, 4, and 5 piece types in Cephalopod. The reason for the range of values is that the directional aspect of the move description causes the piece to move off the board part of the time giving the piece a lower value for a piece occupying those squares. In the case of the 1-piece squares a1-a4 are worth 189 and the rest of the squares on the board are worth 160. It also slightly lowers the value of those squares where the full move is possible. The full move is possible for a piece starting on square a3 for both the 4-piece and the 5-piece. If the move were made the piece would end up on c3 in both cases yet the piece value between the two is different.

The drawback to this method is that it makes the same move worth different values on some squares and might encourage the Zillions AI to favor some squares when there is no good play reason to do so. In this case I tried to avoid that by experimenting with directional moves till I got the value range not to overlap other pieces. So a 3-piece is always worth more than a 2-piece and less than a 4-piece etc.

Another method of manipulating a piece’s value is to swap it out for a more or less valuable piece that looks and moves the same by using change-type depending on what square it moves to. For example, the entire board is broken into high, middle, and low value zones. Each piece type has three versions with the same exact moves in the used priority, the same piece graphic, and different moves in the unused move priority to create low, middle and high value versions of the pieces. The move definitions include a zone test and change the piece type to high, middle or low depending on what zone it is in. This has the effect of herding a players pieces into the right area of the board.

A third method is to give a piece moves in the unused priority that are conditional. This is an increase dependent upon the piece meeting the condition regardless of piece type. For example it is useful when a piece’s value needs to be increased because of its position relative to other pieces regardless of which part of the board (zone) it is in.
Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 130
Registered: 8-2000
Posted on Thursday, March 29, 2007 - 2:40 am:   

Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 118
Registered: 8-2000
Posted on Wednesday, March 07, 2007 - 5:38 am:

--------------------------------------------------------------------------------
My question is how much does adding unusable directions tweak the value of a move? Bare adds can add such large chunks of value that it might be better to use a method with a smaller granularity.
Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 131
Registered: 8-2000
Posted on Thursday, March 29, 2007 - 2:41 am:   

Greg Schmidt (Gschmidt2)
New member
Username: Gschmidt2

Post Number: 11
Registered: 1-2007
Posted on Friday, March 09, 2007 - 9:00 am:

--------------------------------------------------------------------------------
Wow, thanks for the informative post, I hadn't realized there are so many ways to influence the AI. The notions of changing piece types or using move priorities had not even occurred to me. Also, it appears that several developers have been using these techniques, and variations of them, to expand the scope of playable games.

[My question is how much does adding unusable directions tweak the value of a move?]

Although I haven't tried it, I would think that adding a single direction would be more "granular" than a bare add because it only adds mobility to a single square. Mats could best answer to this. Mats are you there?

-- Greg
Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 132
Registered: 8-2000
Posted on Thursday, March 29, 2007 - 2:42 am:   

Ronald W Brierley (Ronaldwb)
New member
Username: Ronaldwb

Post Number: 59
Registered: 2-2003
Posted on Saturday, March 10, 2007 - 6:38 am:

--------------------------------------------------------------------------------
Keith,
I find your description of the three ways of piece value tweaking very interesting.
I would particularly like to know your source for the ELO rating formula and what the details are of your reversing technique,
Ronald
Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 133
Registered: 8-2000
Posted on Thursday, March 29, 2007 - 2:42 am:   

Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 119
Registered: 8-2000
Posted on Saturday, March 10, 2007 - 6:20 pm:

--------------------------------------------------------------------------------
Ronald, here is the link to the ELO difference calculator:

http://www.3dkingdoms.com/chess/elo.htm
Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 134
Registered: 8-2000
Posted on Thursday, March 29, 2007 - 2:43 am:   

M Winther (Kalroten)
New member
Username: Kalroten

Post Number: 9
Registered: 1-2007
Posted on Wednesday, March 21, 2007 - 2:21 am:

--------------------------------------------------------------------------------
(Sorry, I missed out on this tweaking discussion, which should really be somewhere else). But if one introduces "bare adds" then the engine can pass a move even if the bare adds have the lowest move priority. This occurs when the player is stalemated. So it should not be possible to use bare adds in chess, although it could be possible in other games.

The above suggestions are interesting. I have confined myself to placing adds to occupied extraneous squares, and in this way avoiding the stalemate problem. I have used this method extensively while it is absolutely necessary in most chess variants. The effectiveness is proved by my tweaked versions of Korean Chess and Chinese Chess. By changing the piece values my versions nearly always beat the standard Zillions versions. I have also used this method to lowering a piece's value by adding value to all the other pieces. In this way one can fine-tune piece values, by changing their relative values.

Pieces often change value while the position changes, and Zillions increases piece value depending on movement freedom, which means that they become more valuable in the endgame. But many of my pieces don't add value according to this simple principle. However, I haven't addressed the problem. Probably, some of the above suggestions could be applicable. Possibly, at a stage in the game, one could add a copy of the same piece, but with less tweaking value, thus lessening the value of the piece during the game. This is a simple method, but this means that one must keep count of how many pieces have been captured. /Mats
Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 135
Registered: 8-2000
Posted on Thursday, March 29, 2007 - 3:01 am:   

Glad to see you did catch the end of the tweaking discussion Mats. I would like to hear more from you about it. For example, how much does it increase a space's value when blocked directions are added?

The bare add generating a pass problem can be avoided if the turn order can be set up so that the unused move priority is never used. Making it the lowest priority is where the pass problem can arise. For example in the new Cannon AI I am working on the move priorities are "used" and "unused" and the turn order is

(turn-order (Black used) (White used))

So I think bare adds could be used in chess where stalemates are possible. Put all the regular chess moves in the "used" priority. I am not sure what to do if you have three move priorites.
M Winther (Kalroten)
New member
Username: Kalroten

Post Number: 11
Registered: 1-2007
Posted on Friday, March 30, 2007 - 10:50 pm:   

When adding directions from a square, the square's value is increased relative to how many directions there exist already. I always use this method from the corner squares to discourage the king from unnecessarily wasting moves to the corners. In chess one can seldom afford these tempo-losses. In Korean Chess I used this to discourage the king from wasting moves immediately, thus making opening play better and less monotonous. Zillions always wants to put the king on a square with as few directions as possible.

Other pieces are attracted to squares with extra directions, something which could possibly be used.

The additional adds from pieces to blocked squares increases the piece value relative to how many adds there exist already. This means that you can determine how much piece value you want to add by changing the amount of adds in all pieces. The extra adds doesn't cost anything because they have the lowest move priority. /Mats
Michael Hofmann (Darion)
New member
Username: Darion

Post Number: 1
Registered: 4-2007
Posted on Sunday, April 01, 2007 - 6:18 am:   

Hello all,
I used the idea of "unused" 'add' moves to adjust the piece values of Chu Shogi to what I think is right and it works great! So far so good.
But is there a way to encourage Zillions to use certain pieces (in my case the Step Movers) more often or at least bring them forward to the center? I tried to define a 'center' zone and increase a Step Mover's value with 'add' commands like
(move-type unused) (if (in-zone? center) (add))
but this adds value to the piece regardless where it is since I suppose that an unused add is the same as an unused add that fulfils a condition.
Is there a way to influence the engine in this way?

Michael
M Winther (Kalroten)
New member
Username: Kalroten

Post Number: 13
Registered: 1-2007
Posted on Sunday, April 01, 2007 - 9:31 am:   

In my chess variants I always encourage castling by creating an invisible dummy-piece on an external square. In the same manner, early pawn moves to certain central positions are encouraged. This has increased playing strength very much, and the play becomes much more varied. Otherwise Zillions tends to hop around with leaping pieces too much, or move around the queen too early. At the same time I discourage early queen moves, by a special method, that it's also worth to copy. As soon as Zillions has moved a couple of pawns it starts to play good and quite enjoyable chess.
By the way, I have created a new version of my Gladiatrix chess, where the board is enlarged, making it easier to develop these powerful pieces.

/Mats
Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 136
Registered: 8-2000
Posted on Saturday, April 07, 2007 - 2:11 am:   

quote/...is there a way to encourage Zillions to use certain pieces (in my case the Step Movers) more often or at least bring them forward to the center? I tried to define a 'center' zone and increase a Step Mover's value with 'add' commands like (move-type unused) (if (in-zone? center) (add)).../quote Darion

I get a conditional change when using an area this way

(define row8_adjust_move
((verify (in-zone? row_eight))add add add add add add add add add add add add )
)

I have two suggestions. 1) Try using verify. 2) try your if statment approach with too many adds at first when first trying to adjust values to make sure the value change is obvious. I have seen a bare add increase the value of a low movement piece as little as 12 points under the right conditions.
Keith Carter (Keithc)
New member
Username: Keithc

Post Number: 151
Registered: 8-2000
Posted on Saturday, June 21, 2008 - 8:10 am:   

I finally got Cannon AI finished and released. It is a good example of two types of AI prodding. 1) a piece’s value is changed by swapping it out for a more or less valuable piece that looks and moves the same by using change-type. 2) a piece keeps the same type but is given an increase in value based on what zone it occupies. In Cannon AI the highest value piece used in method 1) is given a bonus for advancing towards the enemy town.

Add Your Message Here
Post:
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Password:
Options: Enable HTML code in message
Automatically activate URLs in message
Action: