And welcome back to another java programming , showcase in this video i'll showcase my new game i built in java if you have not heard of . baccarat it's a fun and easy casino gambling game also baccarat has one of the lowest house edge . percentages meaning you are statistically more likely to win on this game than most other tables , in a casino since this was such an easy and rewarding game to build i thought it would be fun , to add to my casino project i've been working on if you're not familiar with this i'm working , on building a whole casino game in java which includes projects like blackjack craps and , more that you can check out on my channel anyway let's get right into it when we first load up the game we are brought to a menu where you can select which game to play we'll scroll over to press the baccarat table now if you don't know how to play baccarat it's a very simple game to . keep it easy we just have three bets we can place the bets are if the banker wins player wins or , if they tie the goal of this game is to see who can draw closest to the number nine and if , you go over your count starts back at zero i'll place some money down on the player bet which is betting that the player will get closer to nine than the banker when i press the deal button . the player will get dealt their first two cards i received a three and a five which is eight , it is a great starting number next the banker will get dealt two cards they first got . drawn a queen which is a zero and a ten which is also zero zero is the farthest from , nine so they automatically lose and we win five dollars and the game is as simple as that let's play another round and repeat our bet i'll place a 25 chip on the banker this time we got dealt . 2 8 which is 16. however we cannot go over 10 so we subtract 10 from our total so 16 minus . 10 is 6 which is not a bad number to have it looks like the dealer received an ace which is a 1 and a jack which is a zero sometimes the dealer or player will draw another card based on their score if it is low enough in this case the dealer drew one more card which . was a seven which put their total to eight another note is betting on the dealer gives the , players a house edge advantage which results in it being a better bet than the casino allows usually the player will have to pay a five percent fee on their winnings to make it more even for the casino , when they bet on the banker theoretically betting on the banker will provide slightly better odds
because they can also sometimes draw a third card depending on the player's first card . which could give them a better outcome let's play another round and , see how much money we can win i'll go with another 25 chip on the banker the player gets a total of three and i get four we both draw one more and it looks like the dealer comes out on top let's do another 25 chip again it looks like the banker is out on , top we win 23 dollars and 75 cents back let's keep riding the banker train looks like the player now has a . total of two and the dealer has seven that's another 23.75 cents in our pocket for the , last hand the player has received the tough to tie nine hand we're most likely going to lose , his hand let's start betting on the player now as i run through a few hands we went from starting . out a hundred dollars and was able to double our money in a matter of minutes as always gambling is , about luck and the outcomes won't always make us win some of the rules that the dealer would . need to know and what i needed to know when i programmed this game is when the player or dealer should draw a third card we can usually follow this diagram either the player or banker , will draw a third card depending on their score let's first look at the player the player . will draw a card if their hand is a one two three four five or a zero slash ten otherwise they will stand on 6 7 8 and 9. if either the player or banker draw an 8 or 9 as their total for their first two cards neither the player nor banker can draw a third . card no matter what next we can look at when the banker should draw a card they should draw another , card depending on their total and what the total that the player has as long as the player does not , have an 8 or a 9 the banker has a chance to draw another card similar to the player if , the dealer has a 7 8 or 9 they will stand if the banker's first two cards total 0 1 or 2 they will always draw a card as long as the player does not have a natural win the statistics . are slightly more complex if the player draws a third card and the banker has a specific , amount let's take a look at the first row if the banker's first two cards total a three they will not draw a third card if the player's third card is an 8. if the player's third card is any other card but an 8 the banker will draw a card if we take a look at the next row when the banker has their first two cards totaling to four they will draw a third card only if the player's
third card is a two three four five six or seven otherwise they will stand as i said earlier if you . went to a casino you would not have to memorize these rules only the dealer needs to know them but is always good to keep in mind when playing if we take a look at the game and its functionality it only has about 500 lines of code for the complete project like the other games we have in this project we reference a few other classes such as the deck cards and card image classes that will give us our deck what cards are in each of the player and banker's hands and . the image and card number we hold for each hand as always we have our init tick and render method , that is standard in each game our init method initializes the hitboxes and any images we would . need to load in our tick method that captures runtime functionality we are looping through when each button press is happening when we are placing and removing chips and running , the game functionality if it has started when we are running through the game , loop it is a pretty simple function we add a card to each hand and delay a . certain amount to give a slight animation then based on the rules mentioned above the . player or dealer will receive another card at the end we calculate who has a closer value to 9 or if it was a tie the render method is even easier to understand we . are simply displaying certain properties whether the game has not started in progress or finished , if it is not started we want to display the chip information and where our chips are along with . the help box to help new users play the game if the game is in progress we want to see , both hands and the totals for each hand as we are getting dealt cards finally if the game is done we want to see the statistics and how much we either won or lost in the game overall this was . a pretty fun and quick game to build that helps early developers learn how to build and maintain projects such as this casino game i'm building i hope you enjoyed and as always if you have any , other comments suggestions or feedback then let me know in the comments below don't forget you , can download this project on my website neehaw.com here you can also find other types of projects , ranging from other java game development to working with the arduino and making projects , come to life let me know what type of gambling game you would like me to build next in this casino project and as always thanks for watching,