milestone 4 devin gaines devin gaines graham gimbert graham gimbert ikhan mcclarty ikhan mcclarty...

42
Milestone 4 Milestone 4 Devin Gaines Devin Gaines Graham Gimbert Graham Gimbert Ikhan Mcclarty Ikhan Mcclarty James Cefaratti James Cefaratti Kwang Kim Kwang Kim Monarch Shah Monarch Shah

Post on 21-Dec-2015

224 views

Category:

Documents


2 download

TRANSCRIPT

Milestone 4Milestone 4

Devin GainesDevin Gaines Graham GimbertGraham Gimbert Ikhan McclartyIkhan Mcclarty James CefarattiJames Cefaratti Kwang KimKwang Kim Monarch ShahMonarch Shah

GraphicsGraphics

Ikhan Mcclarty Ikhan Mcclarty James CefarattiJames Cefaratti Monarch ShahMonarch Shah

OverviewOverview

Of the major parts of the code able Of the major parts of the code able graphics, the button class is almost graphics, the button class is almost done.done.

All of the graphics that we are going All of the graphics that we are going to use are already finished, barring to use are already finished, barring unforseen problems.unforseen problems.

We will cover some of the more We will cover some of the more major parts to the buttons.major parts to the buttons.

ClickedClicked bool Button::inButton()bool Button::inButton() {{ if( ( mouse_x >= getX() && mouse_x <= getRight() ) && ( mouse_y >= if( ( mouse_x >= getX() && mouse_x <= getRight() ) && ( mouse_y >=

getY() && mouse_y <= getBottom() ) )getY() && mouse_y <= getBottom() ) ) {{ return true;return true; }} elseelse {{ return false;return false; }} }}

//This code stub is used to detect if //This code stub is used to detect if the //mouse cursor is within the the //mouse cursor is within the bounds of the //button.bounds of the //button.

Left ClickedLeft Clicked bool Button::clicked()bool Button::clicked() {{ if( inButton() ) //This is the code to determine when a if( inButton() ) //This is the code to determine when a

button is button is {{ //left clicked. Obviously this is going to be //left clicked. Obviously this is going to be

importantimportant if( mouse_b & 1)if( mouse_b & 1) //to the overall project, as buttons will guide //to the overall project, as buttons will guide

when when {{ //the game will advance. //the game will advance. return true;return true; }} elseelse {{ return false;return false; }} }} elseelse {{ return false;return false; }} }}

Draw ButtonDraw Button void Button::drawButton(BITMAP *putSkin )void Button::drawButton(BITMAP *putSkin ) {{ draw_sprite( screen, putSkin, getX(), getY() );draw_sprite( screen, putSkin, getX(), getY() ); }}

//Draw button is also very important, //Draw button is also very important, as it //is what displays the button to as it //is what displays the button to the screen.the screen.

//The actual function that gets called //The actual function that gets called is //from the allegro graphical library.is //from the allegro graphical library.

Correctness of ButtonsCorrectness of Buttons

Firstly, all of the get and set methods Firstly, all of the get and set methods were tested with a console application were tested with a console application to test that they were correct.to test that they were correct.

Another major problem regarding Another major problem regarding correctness are filenames.correctness are filenames.

If a filename is incorrect when trying If a filename is incorrect when trying to load, the program will crash.to load, the program will crash.

Testing this was important.Testing this was important.

Correctness of ButtonsCorrectness of Buttons

The way we tested the correctness of the The way we tested the correctness of the buttons was to set up a test program.buttons was to set up a test program.

In the test program, the button’s (x,y) In the test program, the button’s (x,y) position was always on the screen, as position was always on the screen, as was the mouse’s (x,y) position.was the mouse’s (x,y) position.

By clicking all around and in the button By clicking all around and in the button while keeping track of all the clicks, we while keeping track of all the clicks, we were able to determine that the buttons were able to determine that the buttons work properlywork properly

Correctness of ButtonsCorrectness of Buttons

With the Buttons and the file input With the Buttons and the file input working correctly, we were able to working correctly, we were able to get the buttons to actually serve a get the buttons to actually serve a purpose.purpose.

We made it so that when a button is We made it so that when a button is clicked, a file was written to.clicked, a file was written to.

After the test was finished, with text After the test was finished, with text in the file, we knew that the buttons in the file, we knew that the buttons were fully functional.were fully functional.

IntegrationIntegration

The graphics are modular, to the The graphics are modular, to the point where integration will just be a point where integration will just be a matter of using the given classesmatter of using the given classes

There is nothing that has to be There is nothing that has to be modified to work in the environment modified to work in the environment it was destined to.it was destined to.

The graphics front end will rely upon The graphics front end will rely upon all of the other back end code being all of the other back end code being developed concurrently.developed concurrently.

IntegrationIntegration

As an overview, the graphics will As an overview, the graphics will need to know what the AI is doing, need to know what the AI is doing, when chips are being passed around, when chips are being passed around, and the cards available to the player.and the cards available to the player.

When all of the above things are When all of the above things are happening the GUI needs to change happening the GUI needs to change to accommodate what is happening to accommodate what is happening in the backend. in the backend.

IntegrationIntegration

The graphics engine will also need The graphics engine will also need to have access to the save game and to have access to the save game and load game featuresload game features

As well as the ability to advance to As well as the ability to advance to the next stage in the game.the next stage in the game.

SuccessSuccess

The graphics functions will work The graphics functions will work when the project is finished because when the project is finished because they are modular.they are modular.

A button can act as a flag for almost A button can act as a flag for almost anything. anything.

As long as allegro works as it should, As long as allegro works as it should, the rest of the graphics should fall the rest of the graphics should fall into place.into place.

Without Further Adieu Without Further Adieu

Some buttons…Some buttons…

Shuffling Shuffling FunctionFunction

Devin Thomas GainesDevin Thomas Gaines

Classes and FunctionsClasses and Functions

Classes Classes Deck ClassDeck ClassRandomNumber ClassRandomNumber Class*Distribution Class (this will be optional)*Distribution Class (this will be optional)

I wanted to make the code more I wanted to make the code more functional and broke it down into functional and broke it down into modules for ease of integration. modules for ease of integration.

Deck ClassDeck Classclass Deck {class Deck {public:public:

// default conmstructor // default conmstructor Deck();Deck();

// intializes the deck array and size of deck// intializes the deck array and size of deckvoid initDeck( int deck[] , int size );void initDeck( int deck[] , int size );

//shuffles the deck using random number generator and swapping//shuffles the deck using random number generator and swappingvoid shuffleDeck( int deck[] , int size );void shuffleDeck( int deck[] , int size );

//deals hands given the number of players and cards per player//deals hands given the number of players and cards per player//Max number of players is 10 (arbitrary value!) and max number of cards being dealt is 5//Max number of players is 10 (arbitrary value!) and max number of cards being dealt is 5void dealHand( int deck[] , int numberOfPlayers , int cardsPerHand);void dealHand( int deck[] , int numberOfPlayers , int cardsPerHand);

//sorts a deck//sorts a deckvoid sortHand( int hand[] , int size );void sortHand( int hand[] , int size );

//prints a given hand or whole deck//prints a given hand or whole deckvoid printHand( int hand[] , int size );void printHand( int hand[] , int size );

//prints individual cards//prints individual cardsvoid printCard( int card );void printCard( int card );

private:private:// sets size and array// sets size and arrayint deck[DECKSIZE];int deck[DECKSIZE];

};};

RandomNumber ClassRandomNumber Classclass RandomNumber {class RandomNumber {public:public:

// default conmstructor with defaults of 0&1// default conmstructor with defaults of 0&1RandomNumber(int a=0, int b=1);RandomNumber(int a=0, int b=1);

// Mutator:// Mutator:// Sets high and low values// Sets high and low valuesvoid SetInterval(int a, int b);void SetInterval(int a, int b);

// Faclitators:// Faclitators:// Display Random numbers...// Display Random numbers...int DrawRandomNumber();int DrawRandomNumber();

// Set seed using current time// Set seed using current timevoid SetTimerSeed();void SetTimerSeed();

private:private:// Inspectors:// Inspectors:int GetLow();int GetLow();int GetHigh();int GetHigh();

// Data members// Data membersint Low, High;int Low, High;

};};#endif#endif

The Shuffle ProgramThe Shuffle Program Here is a demo of how the shuffling Here is a demo of how the shuffling

program works. program works. I basically made a main function that tests I basically made a main function that tests

all my other functions using the all my other functions using the printHand() and printCard() methods. printHand() and printCard() methods.

From here, I have these functions print From here, I have these functions print out the original deck, the shuffled deck out the original deck, the shuffled deck and then the sorted deck, which should and then the sorted deck, which should resemble the original deck exactly.resemble the original deck exactly.

I also have the beginnings of a dealHand() I also have the beginnings of a dealHand() function that will distribute the cards out function that will distribute the cards out among players.among players.

Snapshots of Demo (Ex. Snapshots of Demo (Ex. 1)1)

Snapshots of Demo (Ex. Snapshots of Demo (Ex. 2)2)

Snapshots of Demo (Ex. Snapshots of Demo (Ex. 3)3)

Integration…how?Integration…how?

The only class that will be The only class that will be communicating with the rest of the communicating with the rest of the program is the Deck class. program is the Deck class.

There will need to be shuffleDoneFlag There will need to be shuffleDoneFlag variable to let the Game Class know variable to let the Game Class know when shuffling has occurred and is when shuffling has occurred and is complete.complete.

Also, I will need to send my deck array Also, I will need to send my deck array to player algorithm and the best hand to player algorithm and the best hand algorithm for further play and analysis.algorithm for further play and analysis.

Current IssuesCurrent Issues Currently, I am working on the distribution Currently, I am working on the distribution

of the random numbers in my program.of the random numbers in my program. At first, with the way that I seeded my At first, with the way that I seeded my

random function, the distribution always random function, the distribution always came out to be the same.came out to be the same.

Reworking the Reworking the DistributionDistribution

I’m trying to vary distribution methods in I’m trying to vary distribution methods in order to make the program more random-order to make the program more random-like. like.

So far I been working with uniform, normal So far I been working with uniform, normal and exponential distributions and shifting and exponential distributions and shifting between those three types.between those three types.

Any Possible ChangesAny Possible Changes

The only possible changes or The only possible changes or additions that might happen is the additions that might happen is the formation of another class or formation of another class or function that will carry different function that will carry different distribution patterns for the shuffle distribution patterns for the shuffle program. program.

AIAI

Kwang KimKwang Kim

MethodsMethods bool Player::preFlop() {bool Player::preFlop() {

int result = rankHand(firstCard, secondCard);int result = rankHand(firstCard, secondCard);switch (result) {switch (result) {

case 1:case 1: raise(currBet); raise(currBet); break;break; case 2:case 2: callBet(currBet);callBet(currBet); break;break; case 3:case 3: fold();fold(); break;break; default:default: cout << playerName << " pre-flop strategy" << endl;cout << playerName << " pre-flop strategy" << endl; break;break; }} return true;return true; }}

//preflop uses the strength of the hand //preflop uses the strength of the hand to //determine whether or not it is to //determine whether or not it is playable.playable.

RankHandRankHand

rankHand is used by the preflop rankHand is used by the preflop strategy to determine what it should strategy to determine what it should do.do.

The method is too long to show here, The method is too long to show here, but is just a function that uses a but is just a function that uses a series of if statements to determine series of if statements to determine if the hand is “raise-able” “check-if the hand is “raise-able” “check-able” or “fold-able”able” or “fold-able”

CorrectnessCorrectness

The getter and setter functions that The getter and setter functions that are in this class were tested through are in this class were tested through the console.the console.

By using options to set and get By using options to set and get different values we were able to different values we were able to determine that they were working determine that they were working correctly.correctly.

CorrectnessCorrectness

For the actual workhorse code, we For the actual workhorse code, we used a different console application. used a different console application.

This separate console application This separate console application was designed to take in two card was designed to take in two card values, and output if the player values, and output if the player should fold, raise, or call.should fold, raise, or call.

The result was that the subroutine The result was that the subroutine rankHand was functioning properlyrankHand was functioning properly

IntegrationIntegration

This module is what makes the game This module is what makes the game advance.advance.

The player AI is responsible for The player AI is responsible for making the decision to raise, call, or making the decision to raise, call, or bet, and is essentially the thing that bet, and is essentially the thing that makes this game playable.makes this game playable.

IntegrationIntegration

By making a Player class, we are By making a Player class, we are able to modularize them, and add as able to modularize them, and add as many as we want to a table.many as we want to a table.

The only thing that comes out of The only thing that comes out of integration is the automation of play.integration is the automation of play.

We are going to have to loop We are going to have to loop through all the active players and through all the active players and use the AI to make them decide what use the AI to make them decide what to do.to do.

This will work!This will work!

The reason this will work is the same The reason this will work is the same reason all the other pieces will work.reason all the other pieces will work.

It is all just many parts of a whole.It is all just many parts of a whole. In order to make that whole work, In order to make that whole work,

all of the pieces work symbiotically. all of the pieces work symbiotically. With thorough testing and play we With thorough testing and play we

will succeed.will succeed.

Best HandBest Hand

Graham GimbertGraham Gimbert

Minor ModificationsMinor Modifications

The BestHand class has been slightly The BestHand class has been slightly modified now to accommodate the modified now to accommodate the recently agreed on naming recently agreed on naming conventionconvention

BestHand no longer uses a list to BestHand no longer uses a list to keep track of the best hand, just a keep track of the best hand, just a two dimensional 7x7 matrix of two dimensional 7x7 matrix of Cards. Cards.

MethodsMethods Insert(Card temp)Insert(Card temp)

{{ if (cardList[0] == NULL)if (cardList[0] == NULL)

cardList[0][0] = temp;cardList[0][0] = temp;

elseelse

{{ for (int i = 0; i < 7; i++)for (int i = 0; i < 7; i++)

{{ if (temp.rank >= cardList[i][0])if (temp.rank >= cardList[i][0])

{{ for (int j = 7; j > i; j--) //Move cards aheadfor (int j = 7; j > i; j--) //Move cards ahead

cardList[j][0] = cardList[j-1][0];cardList[j][0] = cardList[j-1][0];

cardList[i][0] = temp;//Not shown, moving all downward cardList[i][0] = temp;//Not shown, moving all downward cardscards

}}

}}

}}

This is the basic idea of inserting the This is the basic idea of inserting the cards.cards.

CorrectnessCorrectness

The correctness of this was again The correctness of this was again tested with a console application.tested with a console application.

Using the console application we are Using the console application we are able to show that correct values are able to show that correct values are received…received…some of the timesome of the time

The function is not quite finished The function is not quite finished yet.yet.

CorrectnessCorrectness

The testing application reads in 7 The testing application reads in 7 cards from user input, and runs the cards from user input, and runs the best hand algorithm. best hand algorithm.

If the output matches the correct If the output matches the correct best hand, then we have a success.best hand, then we have a success.

IntegrationIntegration

The place where the best hand The place where the best hand algorithm belongs is in the Player algorithm belongs is in the Player class. class.

In order to determine what the player In order to determine what the player should do for a post flop strategy, the should do for a post flop strategy, the best hand algorithm is used.best hand algorithm is used.

Since the best hand algorithm was Since the best hand algorithm was encapsulated into a class, it makes it encapsulated into a class, it makes it easy to add it anywhere it is needed.easy to add it anywhere it is needed.

IntegrationIntegration

Once we have the finished best hand Once we have the finished best hand algorithm, we will able to finish up algorithm, we will able to finish up the player classes very quickly. the player classes very quickly.

With the player classes done, and With the player classes done, and the shuffling done, we will be able to the shuffling done, we will be able to tie everything in together with the tie everything in together with the graphics and make the game graphics and make the game functional.functional.

Finished IntegrationFinished Integration

We are confident, that with all of our We are confident, that with all of our functions finished, we will have a functions finished, we will have a complete and functional product.complete and functional product.

There will be bugs, but that is to be There will be bugs, but that is to be expected.expected.

The result of the integration will be The result of the integration will be a success, with hard work and a success, with hard work and

determinationdetermination..