| Author |
Message |
Ole Meinert (Buttercup)
| | Posted on Thursday, February 05, 2004 - 1:42 pm: | |
I'm trying to implement a move and am stuck as I expected before: There is a piece called Meteor, which can go as far as it wants, but only, if it is in contact to one of the other team-pieces (planets) in one of the normal 8 directions all the time - like an orbit. It does not have to be the same piece during one move. Meteor can change it's leading-planet as often as it likes. And after this partial-move it is even allowed to go one step further (n,e,s,w) The best thing I could come up with so far was a multiple add-partial (one step at a time). But that's not nice and I don't even know how to end the move. Another idea was to change all pieces colours, put dummy-files around the now enemy-colored pieces with adjacent-to-enemy and try something with collecting those dummy files so that no way could be taken more than once, but that even sounds too weird to me Any ideas, how this could be realized? |
Karl Scherer (Karl)
| | Posted on Sunday, February 08, 2004 - 12:44 am: | |
Hi, I suppose the following should work: Let $1 stand for the directions e, w, s, n, se, sw, ne, sw. now define moves for your piece for all of the eight standard directions: (define piece.... (moves (Shift e)(Shift w)(Shift s)(Shift n) (Shift sw)(Shift nw)(Shift se)(Shift ne) ) ) where Shift is defined by (define Shift ( (set-flag found? true) (while (on-board? $1) $1 (set-flag found? false) (Check e)(Check w)(Check s)(Check n) (Check sw).... (verify (flag? found?)) add ) )) and submacro 'Check' checks your special condition, namely whether a friendly piece is in the given direction. If found, it sets the flag found? to true: (define Check (if (not-flag? found) ;not found yet? mark (while (on-board? $1) $1 (if friend? (set-flag found? true) ) back ) ) Cheers, Karl |
Karl Scherer (Karl)
| | Posted on Sunday, February 08, 2004 - 12:45 am: | |
Hi, I suppose the following should work: Let $1 stand for the directions e, w, s, n, se, sw, ne, sw. now define moves for your piece for all of the eight standard directions: (define piece.... (moves (Shift e)(Shift w)(Shift s)(Shift n) (Shift sw)(Shift nw)(Shift se)(Shift ne) ) ) where Shift is defined by (define Shift ( (set-flag found? true) (while (on-board? $1) $1 (set-flag found? false) (Check e)(Check w)(Check s)(Check n) (Check sw).... (verify (flag? found?)) add ) )) and submacro 'Check' checks your special condition, namely whether a friendly piece is in the given direction. If found, it sets the flag found? to true: (define Check (if (not-flag? found?) ;not found yet? mark (while (on-board? $1) $1 (if friend? (set-flag found? true) ) back ) ) Cheers, Karl |
Ole Meinert (Buttercup)
| | Posted on Sunday, February 08, 2004 - 12:47 pm: | |
Hi, thanks for your help. It seems like your approach doesn't take into account, that Meteor has to be in touch with another friendly-piece all the time, or does it? But I did it similar to that with defining 8x8=64 directions and checking those. You need to do 2-3 partial moves to get to your destination but that's fine with me, only AI takes much more time to think |
Ole Meinert (Buttercup)
| | Posted on Sunday, February 08, 2004 - 3:38 pm: | |
Now I did think a little more about it, and the problem was, that Meteor can change directions as often as it likes and I didn't mention that... Sorry. But it works quite well now. Anyway, thanks for your efforts. |
Karl Scherer (Karl)
| | Posted on Sunday, February 29, 2004 - 3:28 am: | |
Hi Ole, you wrote "It seems like your approach doesn't take into account, that Meteor has to be in touch with another friendly-piece all the time, or does it?" Of course it does : Just read the code again; my comments read: "..submacro 'Check' checks your special condition, namely whether a friendly piece is in the given direction. If found, it sets the flag found? to true". And this flag is then checked with a verify, which guarantees that your condition is ALWAYS fulfilled. I hope that clarified it. Cheers, Karl |
|