| 09-30-2002, 01:04 AM | #1 |
Guest | I spent about an hour creating this blackjack game and for some reason I cant make it work. It uses simple variables and random numbers. The problem is everytime you play you beat the dealer under all circumstances unless you bust. If someone could check this out and tell me what is wrong it would be appriciated. |
| 09-30-2002, 01:51 AM | #2 |
Guest | Oh my, where do I begin. The key to figuring out why something isn't working is to check to see if everything is working as you'd expect. In most cases all you need to do is add a few text messages displaying a variable, or a message whenever a trigger runs. In this map, all you're showing the user is the dealers score. We're then left to remember what score we had and wether it was a win or a loss. The easiest thing you could do is have a text message showing the dealer's score, and then the player's score. This would at least verify that your math is correct.... And it isn't. The main problem is your chekuser trigger. You are checking the Hero's inventory every .10 seconds and then adding onto the card count based on what is in the inventory. But you are in no way checking to see if you've counted that card before. You are simply saying "If King in inventory, add 10 to cards" every .10 seconds. Simply put a text message displaying cards at the end of this trigger and you'll quickly see that the cards score is quickly into the 1000s let alone above 21. Really, you can just remove that whole trigger. Not only is it not needed, but running it every .1 seconds is not even close to needed (if it worked as written, then you'd just have to run the trigger after the player deals or hits). When you add the cards to the inventory, just add another action to increase "Cards" at that point. |
| 09-30-2002, 07:09 PM | #3 |
Guest | Thanks. I did not quite think about that in the checkusr trigger. I have another question if ne one reads this. How should I make ace 1 and 11. I was thinking an if cards greater than 21 checkuser for item - ace. if item ace=true then cards=(cards-10) |
| 09-30-2002, 09:11 PM | #4 |
Not really related to the triggers, but a couple things about the map idea in general: 1. Unique, very, I'll give it that. 2. Really, of all things we buy WC3 to play, I expected Blackjack to be the last of them. A deck of cards is like $1.50 compared to $60. 3. Using random numbers in triggers wouldn't simulate a real blackjack game. In a real game there are far more face cards and 10s than there are 9 and below. This would make it really hard to simulate a real blackjack game. |
| 09-30-2002, 09:19 PM | #5 |
The real aproach to the card game would have to actually use 52 random numbers. 1-13 one suit...the next 13 another and another. Then to be fair and to make sure cards aren't being reused you would create a boolean array which would turn on once a card is in play. Then if you do happen to get a card already used then it will just pick another random number. This will probably cuase long periods of wait after 30 or so cards had been drawn, so you should probably make the game quick like 5 wins total and you win. |
| 09-30-2002, 11:49 PM | #6 |
Or you could place a unit for each individual card in some area and when a card is drawn it just takes a random unit form there and moves it to another area "The Card Table" :P You wouldn't have to deal with a lot of numbers to seperate the suits because you can just put 4 of each unit in the area. This would also keep track of the cards very effectively because you can thing make it so if the cards total up over 21 it turns a unit named Ace (11) into a unit called Ace (1) and recalculate the number. As for the fact that you always win, just make sure that the game keeps a variable for your total and your opponent's total, and compares them at the end of the hand. If your trying to put this as a mini-game within another map it might not be so easy if your already using up all of the custom units. Also if you don't like showing the players cards as units just make it so they can't see the area that the units are kept to keep track of the players hand. It becomes easy to keep track of the cards and the player can't even see what's going on. Of course if you've already worked out most of the variables theres no reason to go back and do any of this! :D |
| 09-30-2002, 11:50 PM | #7 | |
Quote:
I was actually thinking something like that would work, but it might be a lot of work. |
| 10-01-2002, 01:47 AM | #8 |
Guest | Fear F - Yes, you are right I thought about that today after I was almost finished. Weaddar - Great idea, I was wondering how I could manage that. That shouldnt be too tricky and then after 5 wins it will shuffle (reset). I think that how im going to do that. Yes it is for a mini game in a map. Good way to make money (or lose it :ggani: ) |
