| Author |
Message |
Carlos (Carlos)
| | Posted on Saturday, January 20, 2001 - 11:29 am: | |
Hi! I'm working in a game that does not have a regular grid, so I have to use many positions to define a Piece (in my case a piece is a line). When I click in one of those positions the entire line should be "add"ed. The Game is already doing this (to draw the line I'm using the "links" and "cascade" commands), but when I use the win-condition the game doesn't take the line as one piece, he takes all positions of that line. I need to take the line just as one object, even though there are more positions in the line. That's because when the game search for the best way to win, thinks too long and no perfect. I already tested it, and when I'm using just one position for every line, the game is perfect and fast. How can I get this? Thanks for your help, Any help would be appreciated Regards Carlos |
Karl Scherer (Karl)
| | Posted on Sunday, January 21, 2001 - 4:20 pm: | |
Hi Carlos, this is a general remark, not connected to win condition: I found that Zillions is much easier to code and runs much faster when you do NOT use cascade for changing many positions, but use the CHANGE-TYPE command. Fill the board first with invisible pieces (I usually call them 'dot' in my programs). When a player moves, use "drops" of one invisible piece and then use "change-type" as often as needed on the board. This is extremely fast and more flexible and versatile than handling large cascade commands. As example, study some of my tiling game (Nutts, Tangram, Pento, Ypento,...) ....... I have the feeling that your question about the win-condition is not quite clear. Maybe you can exactly describe you problem in detail. Have you tried using zones in the absolute-config part? Cheers, Karl |
Karl Scherer (Karl)
| | Posted on Monday, January 22, 2001 - 4:39 pm: | |
A few more remarks on your problem: 1. My game "Spaghetti" deals with simple line-like pieces. The sequel "Spaghetti II" has even more complicated snake-like pieces. Maybe it helps you to study the rules files of these games. 2. Win-condition for complex multi-position pieces: I solve this problem usually in the way that I check on the piece with a while-loop inside the move-code and if the appropriate win-condition is fulfilled (a certain piece is on a certain place) then I set a "permanent flag" which the win-condition can check. A "permanent flag" is a piece that is positioned outside the board (negative coordinates) and serves purely as an indicator. I will give you an example: Say you want White to win whenever the diagonal from a1 to h8 is occupied by pieces. You have a subroutine "Check" that is called before any "add": (define Kingshift (.....(Check) add) (define Check (set-flag diagonal-full? true) (while (on-board? ne) ;loop over diagonal ne ; go northeast (if empty? (set-flag diagonal-full? false)) ) ;end while (if (flag? diagonal-full?)(change-type Win z0)) ) ; end of Check In the board-definition you define (dummy a0) (link ne (a0 a1)) (positions (z0 -1 -1 -1 -1)) In the piece-definitions you define (piece (name Win)..... and associate it with any (small) image. In the board-setup you initialize position z0 with any other piece. I usually use an invisible (=green) piece 'dot': (White (dot z0)...) 3. In general, it is a good idea to study other people's code. You can learn a lot from it. Cheers, Karl |
Carlos (Carlos)
| | Posted on Monday, January 22, 2001 - 5:31 pm: | |
Hi Karl, Thanks for your help. I tried to use the invisible pieces and the 'change-type' command too, but without exit In the win-condition, in my case the loss-condition I was using just one position from the line to make the verification. I thought that Zillions would think better in this form, but I was wrong. It was something like that: (loss-condition (Red Green) (or (absolute-config line_AB line_AC line_BC (ab2 ac2 bc2)) (absolute-config line_AB line_AD line_BD (ab2 ad2 bd2)) ... After I read your remark about the zones I used this form: (loss-condition (Red Green) (or (and (absolute-config line_AB zoneAB) (absolute-config line_AC zoneAC) (absolute-config line_BC zoneBC) ) (and (absolute-config line_AB zoneAB) (absolute-config line_AD zoneAD) (absolute-config line_BD zoneBD) ) ... The game worked than better and faster, but still no perfect if I compare it with the same game when every line has just two or three positions. (In the end game a line has between 2 and 14 positions) Maybe your suggestion about the 'permanent flag' could work, I'll take a look in your 'Spaghettis' games The game I'm working consists in six nodes with 15 lines between them. The Player and the Computer (or two Players) alternate coloring the Lines, then the first player who builds a triangle with all three edges drawn by himself/herself loses. Thanks again Carlos |
Karl Scherer (Karl)
| | Posted on Tuesday, January 23, 2001 - 6:54 am: | |
Hi Carlos, If you want to send me your game, I will have a look at it and maybe can help you better than by this general discussion on the discussion board. Cheers, Karl : karl@kiwi.gen.nz |
|