| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 844 人关注过本帖
标题:[求助]Video Poker Simulation编程问题
只看楼主 加入收藏
tx1988
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-5-29
收藏
 问题点数:0 回复次数:5 
[求助]Video Poker Simulation编程问题
QUOTE:
Video Poker Simulation



Acme Software, Inc, has been contracted to write a Video Poker Simulation game in basic C++ that follows the following rules:



Basic Setting:

The player places an initial bet between one (1) and fifty (50) coins. The player is then dealt five (5) cards and allowed to choose which cards, if any, they wish to keep. The cards that they do not wish to keep are discarded, and replacement cards are dealt so that they again have a total of five (5) cards. The computer then determines what amount they have won, if any.



Card Ranks and Suits:

Cards are ranked, from highest to lowest:

· Ace

· King

· Queen

· Jack

· Ten

· Nine

· Eight

· Seven

· Six

· Five

· Four

· Three

· Two

· Ace

(Ace can count as either low or high. See "Royal Flush"'s scoring, below.)

The card suits are: Hearts, Clubs, Diamonds, and Spades



Hand Ranks:

When you are dealt replacement cards for your discards, your new hand is evaluated. Based on what kind of hand you're holding, you'll receive a certain number of points.

Hands are listed below, from best (highest scoring), to worst (no score):

· Royal Flush - 2000 points

A straight flush, with the Ace high.

In other words, a Ten, Jack, Queen, King and Ace, all of the same suit.

· Straight Flush - 250 points

A straight flush.

In other words, all five cards are consecutive and are the same suit.

For example: Three of Clubs, Four of Clubs, Five of Clubs, Six of Clubs and Seven of Clubs.

· Four of a Kind - 125 points

Four cards of the same value. (Obviously, each of different suits.)

· Full House - 40 points

A three of a kind and a pair at the same time.

· Flush - 25 points

All cards in your hand are the same suit.

· Straight - 20 points

All five cards are consecutive.

For example: Three of Clubs, Four of Spades, Five of Clubs, Six of Diamonds, and Seven of Hearts.

· Three of a Kind - 15 points

Three cards of the same value.

· Two Pair - 10 points

Two pairs of cards.

In other words, two cards in your hand are the same value, and two other cards in your hand are also the same value.

· Pair - 5 points

Two cards in your hand are the same value. In this version, they must be Jacks or better!

· None of the Above - 0 points

Each turn "costs" 5 dollars, so if you get a pair, no money actually end up added to your total score. If you don't get anything, you actually lose five dollars! If you bet more than one 5 dollar coin, then the returns above are multiplied by the number of coins entered to give the actual yield. This is just how handheld and Vegas video poker games actually work!



Project Requirements:

Your project must meet the following specifications:

1. Text-based display of what is in the player’s hand.
2. Read all cards to be discarded at once
3. Read from the command line as a program parameter the name of a file that contains the state of a previous game so that a player can resume a game at any point. Thus, your program must read and write to a file as well as verify that a file exists.
4. Provided adequate “help” for the player on how to play the game.
5. Score all hands correctly.
6. Know the player’s name and be “friendly”


搜索更多相关主题的帖子: Poker Simulation Video 
2007-05-29 07:06
tx1988
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-5-29
收藏
得分:0 
回复:(tx1988)[求助]Video Poker Simulation编程问...
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <time.h>
#include <string>
#include <fstream>

using namespace std;

void loadDeck(string suits[4], string faceValue[13])
{
ifstream in;
in.open("cards.dat");
if(in.fail())
{
in.close();
cout<<"Deck of cards not found, program ending"<<endl;
exit(1);
}
for(int i=0; i<4; i++)
in>>suits[i];
for(int i=0; i<13; i++)
in>>faceValue[i];
in.close();
}

void shuffle( bool cards[52], int hand[5])
{
for(int i=0;i<52; i++)
cards[i] = false;
for(int i=0; i<5; i++)
hand[i] = -1;
}

void deal(bool card[], int hand[], int pos)
{
int dealt;
while(card[dealt=rand()%52]);
hand[pos] = dealt;
card[dealt] = true;
}


void initialDeal(bool card[], int hand[])
{
for(int i=0; i<5; i++)
deal(card, hand, i);
}

void discard(bool card[], int hand[])
{
char str[80];
cout<<"Which cards would you like to discard: ";
cin.getline(str, '\n',80);
char * pch;
pch = strtok (str," ,.-");
while (pch != NULL)
{
deal(card, hand, atoi(pch));
pch = strtok (NULL, " ,.-");
}
}

void display(int hand[], string suit[], string faceValue[])
{
cout<<"The cards in your hand are: "<<endl;
for(int i=0; i<5; i++)
cout<<i<<". "<<faceValue[hand[i]%13]<<" of "<<suit[hand[i]%4]<<endl;
// cout<<hand[i]<<endl;
cout<<endl;
}

int computepoints(hand,suits,faceValue,points)
{
for( int i = 0; i < 5; i++ )
{
for( int j = i+1; j < 5; j++ )
{
if( faceValue[ hand[i]%13 ] == faceValue[ hand[j]%13 ] )
{
if(faceValue[



bool again()
{
string ans;
cout<<"Do you want to do this again? ";
cin>>ans;
return (toupper(ans[0]) == 'Y');
}

int main(int argc, char *argv[])
{
string suits[4], faceValue[13];
bool cards[52];
int hand[5],points;
srand(time(NULL));
loadDeck(suits, faceValue);
do
{
shuffle(cards, hand);
initialDeal(cards, hand);
display(hand, suits, faceValue);
discard(cards, hand);
display(hand, suits, faceValue);
computepoints(hand,suits,faceValue,points);
}while(again());
system("PAUSE");
return EXIT_SUCCESS;
}




这是我的部分代码,我想请问如何编算分数的环节,如:如何表示5张连续的牌,2或3张值一样的牌,等等。。。
可不可以编一些例子给我或者讲的详细些,谢了!!!!
2007-05-29 07:10
tx1988
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-5-29
收藏
得分:0 
回复:(tx1988)回复:(tx1988)[求助]Video Poker ...
我给大家大致翻译一下,就是编一个纸牌游戏,每轮下注1个5分硬币或更多个,那五张牌,可以任意换牌一次(就是五张PASS),然后看手牌评分。如:
五张是10,J,Q,K,A就是2000分;五张连续(同花色)250分;四张牌面值一样,就是125分;3张一样还有一个对子是40分;全牌同花色25分;五张连续(不同花色)20分;3张一样15分;一个对子,5分。
如果你下注超过1个5分硬币,就把奖励分数乘以硬币数。要求纪录玩家的每轮分数。
大家一定要帮忙啊!我好怕阿,超级新手,都说美国的简单,可谁知这老师的题这么难啊!
2007-05-29 07:46
tx1988
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-5-29
收藏
得分:0 
回复:(tx1988)回复:(tx1988)回复:(tx1988)[求...
召唤斑竹‘s help!!!!!!!

2007-05-29 11:43
aipb2007
Rank: 8Rank: 8
来 自:CQU
等 级:贵宾
威 望:40
帖 子:2879
专家分:7
注 册:2007-3-18
收藏
得分:0 

没空啊,课多,有空帮你看看!

[此贴子已经被作者于2007-5-29 13:19:12编辑过]


Fight  to win  or  die...
2007-05-29 12:16
tx1988
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-5-29
收藏
得分:0 
回复:(aipb2007)没空啊,课多,有空帮你看看![a...
呜呜呜,斑竹不帮小弟的话,偶~~~~~偶就出家当和尚去,天天念经烦死你!!!!哈哈哈哈~~~~~~~~
2007-05-29 13:37
快速回复:[求助]Video Poker Simulation编程问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012032 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved