| Author |
Message |
Ryan Moua (Pickerboom48)
New member Username: Pickerboom48
Post Number: 1 Registered: 3-2018
| | Posted on Thursday, March 01, 2018 - 6:56 am: | |
I recreated a Connect 4 game loosely based off the prepackaged vertical Tic-Tac-Toe game from the program. I used different graphics from Zillions. The images are closer to the real physical Connect 4 game (blue board, red and yellow discs). So far it's just normal Connect 4, first player to get 4-in-a-row wins. Now I want to add another move so that players can "pop" their own discs at the bottom out of the game. This disc gets removed from the game, and all the rest that was on top falls down. The only thing I did is a check whether the player can make a pop move such as: (define can-pop (and (friend? $1) (position? $1))) ; This means that the only discs that can pop are the current player's at the bottom. Programming the actual pop move had me stumped. I tried to reread on what each command does many times but to no avail. The only thing implemented is that I created a dummy piece that'll capture the spot a player's disc was on. Hence, a pop move was performed. But the discs on top of it doesn't fall as I haven't figured out what to do next. Here's some pseudo code to get the idea: (define pop (remove bottom disc $1) (shift (all pieces on $1) s) ) ; s meaning southward, downward, etc Is it possible to manipulate the current position after a move? Any help is much appreciated! |
Ryan Moua (Pickerboom48)
New member Username: Pickerboom48
Post Number: 2 Registered: 3-2018
| | Posted on Thursday, March 08, 2018 - 9:05 am: | |
Okay, by using while loops, cascades, and zones, I was able to recreate the falling disk effect. That dummy piece is no longer a dummy piece; it's a movable piece that's two columns up the board which moves down two spaces to do the job. The only thing that bothers me is that it's not popping where the player's bottom disc are at. How do I get it to happen? |
Sean Duggan (Dream)
New member Username: Dream
Post Number: 126 Registered: 9-2000
| | Posted on Thursday, March 08, 2018 - 12:23 pm: | |
Can you provide the code that you're using now? |
Ryan Moua (Pickerboom48)
New member Username: Pickerboom48
Post Number: 3 Registered: 3-2018
| | Posted on Friday, March 09, 2018 - 1:29 am: | |
(define column ($1 (while not-empty? up) (verify (not-in-zone? top)) (if (and (empty? $1) (in-zone? bottom)) (create Pop-Out up2)) (if (piece? Pop-Out up) (capture up) (create Pop-Out up2)) add)) (define start-piece-count (Yellow (disc off $1)) (Red (disc off $2))) (game (title "Connect Four") (option "prevent flipping" true) (players Yellow Red) (turn-order Yellow Red) (board (image "7x6p.bmp") (grid (start-rectangle 1 1 32 32) (directions (up 0 -1) (down 0 1) (down2 0 2) (up2 0 -2) (up3 0 -3) (right 1 0) (upright 1 -1) (upleft -1 -1) (still 0)) (dimensions ("A/B/C/D/E/F/G" (33 0)) ("t/7/6/5/4/3/2/1/p" (0 33))) ) (zone (name top) (players Yellow Red) (positions A7 B7 C7 D7 E7 F7 G7) ) (zone (name bottom) (players Yellow Red) (positions A1 B1 C1 D1 E1 F1 G1) ) (zone (name pop-zone) (players Yellow Red) (positions Ap Bp Cp Dp Ep Fp Gp) ) ) (piece (image Yellow "yellow.bmp" Red "red.bmp") (name disc) (drops (column A1) (column B1) (column C1) (column D1) (column E1) (column F1) (column G1) ) ) (piece (name Pop-Out) (moves (down2 capture (capture up2) (verify (piece? disc still)) (create Pop-Out up) (while (not-in-zone? pop-zone) cascade from down) (if (in-zone? pop-zone) capture) add) ) ) (board-setup (start-piece-count 2147483647 2147483647) ) (win-condition (Yellow Red) (or (relative-config disc up disc up disc up disc) (relative-config disc right disc right disc right disc) (relative-config disc upright disc upright disc upright disc) (relative-config disc upleft disc upleft disc upleft disc)) ) ) |
Ryan Moua (Pickerboom48)
New member Username: Pickerboom48
Post Number: 4 Registered: 3-2018
| | Posted on Friday, March 16, 2018 - 12:44 am: | |
By using the flip command immediately after the Pop-out "piece" is created, I was able to NOT get that piece swapped after each drop. It's now almost close to completion, but I still need to change it after a pop move to the player's bottommost disk. Any thoughts? |
Ryan Moua (Pickerboom48)
New member Username: Pickerboom48
Post Number: 5 Registered: 3-2018
| | Posted on Sunday, March 18, 2018 - 5:36 am: | |
Okay finally! I got it to work flawlessly and smoothly. So I have to mark the position to the bottom column with another while loop, and change the Pop-out piece to the side that's a column up the board before doing so. This was done through if-else statements and flipping, and then I need to revert the position back for any more drops. For some unknown reason, when either player pops their own disk out in which both sides have a Connect 4, the opposing side wins. It should be a win to the player that has made a pop; it doesn't matter if the other side has one too. I'm not too sure is this is fixable, but I'd say it probably cannot be. Thank you for any sporadic replies on this somewhat dead program. If interested, I can attach the ZRF file, and feel free to play around (or make improvements). (Spoiler: The first player has an enormous advantage as compared to the standard rules.) |