i am working on this blackjack game.. now this code is not completed, but i am facing problem to call function inside another function ,for example how to use parametrs corectly.
for example: in chickcoputercards function i know the way i called chickcomputercards in incorrect .. how to do this the write way ?
my code is:
the game is basicly, the computer gets two random cards , and a special card, if the two cards+special card <21 the computer gets extra cards untill the total sum is>21..
then the player gets two random cards , and he can chose if he can chose if he wants extra cards , at the end who has total sum that is closer to 21 but not bigger than 21 wins !
there is more rules , but now i am trieng to solve these problems first..
What I have tried:
#include <stdio.h>
#include <stdlib.h>
#define MIN_BET 1
#define INITIAL_MONEY 1000
int rand_range (int low, int high) {
static unsigned int next = 1;
next = next * 1103515245 + 12345;
return ((unsigned int)(next/65536) % 32768) % (high - low + 1) + low;
}
void srand_range (unsigned int seed)
{
for (int i = 0; (unsigned int)i < seed; i++) {
rand_range(i,i+1);
}
}
int bett(int initialMoney)
{
int riskedMoney;
printf("You currently have %d fake dollars. How much do you want to bet?\n",initialMoney );
scanf("%d",&riskedMoney);
while((riskedMoney>initialMoney)&&(riskedMoney<min_bet mode="hold" /> {
printf("Your bet must be at least MIN_BET and at most %d, try again:\n",initialMoney );
scanf("%d",&riskedMoney);
}
return(riskedMoney);
}
int chosecomputercards(int first_card,int second_card)
{
int sum=0;
first_card=rand_range(1,13);
second_card=rand_range(1,13);
printf("The computer got %d and %y.",first_card,second_card);
sum=first_card+second_card;
return(sum);
}
int chickcomputercards(int sum,int special_card,int bet)
{
int extra_card;
sum=chosecomputercards(first_card,second_card);
while((sum+special_card)<21)
{
extra_card=rand_range(1,13);
if((sum+special_card+extra_card)<=21)
{
printf("Extra card:%d.",extra_card);
sum+=extra_card;
}
}
if((sum+special_card)>21)
{
printf("The computer got more than 21\n");
printf("You have won %d fake dollars!\n",bet);
}
return(sum);
}
int choseplayercard(int first_card,int second_card)
{
first_card=rand_range(1,13);
second_card=rand_range(1,13);
printf("You got %d and %d",first_card,second_card);
return(first_card+second_card);
}
int chickplayersum(int sum,int special_card,int bet)
{
int extra_card;
int money;
bet=bett(money)
sum=choseplayercards;
char player_answer;
while(sum<21)
{
printf("The current sum is %d. Do you want another card? (Y / N)\n",sum);
scanf("%c"&player_answer);
while(player_answer=='Y')
{
extra_card=rand_range(1,13);
printf("Extra card:%d.\n",extra_card);
sum=sum+extra_card;
}
if(player_answer=!'Y')
return(sum);
}
if(sum>21)
printf("The computer has won this round… you lose &d fake dollars!\n",bet)
}
chickwinner()
{
achickcomputercards(int sum,int special_card,int bet)}
int main()
{
int money=INITIAL_MONEY;
int seed=0;
int bet=0;
int special_card;
int first_card,second_card;
int computer_cards;
int total_computer_cards;
int player_cards,total_player_cards;
printf("Welcome to CS intro Blackjack!\n");
printf("Start by entering a random seed:\n");
scanf("%d",&seed);
srand_range(seed);
while(money>=1)
{
bet=bett(money);
computer_cards=chosecomputercards(first_card,second_card);
special_card=find_special_card;
total_computer_cards=chickcomputercards(computer_cards,special_card,bet);
player_cards=choseplayercard(first_card,second_card);
total_player_cards=chickplayersum(player_cards,special_card);
return 0;
}