Skip to content

Final C Project for Unix Systems Programming Course: Arcade-Style Blackjack and War

Notifications You must be signed in to change notification settings

klaw772/cProject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 

Repository files navigation

Kathleen Law, James Blash
Final Project README

For our final project, we decided to implement an arcade-style program, with the user given options to play either Blackjack or War against the computer. We aimed to make this program as user-friendly as possible, using plenty of prompts to encourage the user to press the correct keys and understanding each step of each game. At the start of each game, the rules are displayed as the user clicks through. Then, the game begins!

Our goal was to successfully implement multiple concepts learned and utilized throughout the semester to make this program. Some of the several concepts we used include: queue data structures (by creating multiple card piles and decks), time delays (by using the sleep() function to delay execution of print statements and mimic a Loading screen), random number generation (by using srand(time(NULL)) and rand() to generate the most pseudo-random combinations), enumerations, utilization of different standard C libraries, creation of custom headers (by making a header file which collected the implementation of our queue, as well as global variables and function prototypes), utilization of arrays, pointers, dynamic memory allocation with malloc, and a heavy emphasis on the use of different functions. 

Throughout the process of coding this project, we encountered several difficulties. Our first difficulty was the implementation of a queue data structure in the C language. While we knew about the concept of queues from previous semesters, we needed to figure out how to implement them in C rather than in Java like in our Data Structures class. However, after some online research, we were able to successfully complete a queue structure with a front, back, size, capacity, and an integer pointer called array which kept track of the data inputted into the queue. This queue also had functions such as checking if it's empty or full, as well as functions to add elements to the end of the queue and removing elements from the front of the queue. After this implementation, we did not have major difficulty using the queue structure in our main program with creating the standard 52 card deck, as well as each player's card piles.

Another difficulty with this project involved the input buffer. Because our program relies on user input like the enter key or other numerical values, it is prone to errors in the input buffer if the user were to press other keys besides the appropriate values. While we tried to debug this area as best we could by calling for repeated prompts when the incorrect value was pressed, we found that the number of incorrect characters being entered may vary and that it is difficult to handle them all. However, for the current state of the program, we were able to handle some of these issues involving incorrect input.

A couple difficulties also arose when creating the blackjack functions, in particular the function that put a card into the human player's "hand" to add to 21. When a player chooses to "stand", they don't pick a card, and this function worked smoothly. However, when a player chooses to "hit," they pick a card to add to their hand. If the collection of cards in the player's hand adds to 21, then the game is over and the player wins. But, when the player goes over 21, they "bust" and lose. When we tried to implement the function to put a card into the player's hand, a segmentation fault appeared that, as of the time of the presentation, was not fixed.\

Another difficulty when implementing the blackjack game was the use of enums. In the game of War, each enum had their own unique integer value, making it easier to compare two card values together to pick the greater card. However, in blackjack, all face cards, as well as the 10 card, have the value of 10 when adding cards to the player's hand. We were able to set each of these enums to equal the value of 10, though, after discussion of how to implement such values.

Future extensions of this project include simply fixing our bugs in the program. While we have the majority of our code functioning properly, it is certainly not perfect, and we are definitely interested in working on it some more after the semester ends to get the whole program running successfully and "looking pretty" at the same time. We are proud of the work we have been able to accomplish not just for this project, but also throughout the course of the semester. 

Thank you! 

 

About

Final C Project for Unix Systems Programming Course: Arcade-Style Blackjack and War

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published