C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 13th, 2005, 12:09 AM
BloodlustShaman BloodlustShaman is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: in earth
Posts: 176 BloodlustShaman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 12 h 9 m 3 sec
Reputation Power: 4
Send a message via Yahoo to BloodlustShaman
Point Making

so as i said in one of my threads i was goin to first try to do a original game by using C++ well as u guys notice in the code it kinda looks the same as tic-tac-toe code but as u guys know to win in tic tac toe all u have to do is get 3 in a row but in my game i want it to make it 2 posiibly wins and they r either to reach in a certain amount of points or do the diamond(as u see in the code i think i got the diamond thing done) but i dont know how to do it for the point part look at code
Code:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;


const char H = 'H';
const char C = 'C';
const char NONE = '[ ]';
const char NO_ONE = 'N';

void rules();
char FirstMove(string question);
int Movement(string question, int high, int low = 1);
char YourPiece();
char Opponent(char Piece);
void showBoard(const vector<char>& board);
char winner(const vector<char>& board);
bool Acceptable(const vector<char>& board, int move);
int YourMove(vector<char>& board, char You);
int OpponentMove(vector<char>& board, char Opponent);
void ShowWinner(char winner, char Opponent, char You);
int Points;

int main()
{
int move;
const int NUM_SQUARES = 25;
vector<char>& board(NUM_SQUARES, NONE);

rules();
char You = YourPiece();
char YPiece = H;
char Opponent = Opponent(You);
char OPiece = C;
showBoard(board);

while (winner(board)  == NO_ONE)
{
if (turn == You)
{
move = YourMove(board, You);
board[move] = You;
}
else
{
move = OpponentMove(board, Opponent);
board[move] = Opponent;
}
showBoard(board);
turn = Opponent(turn);
}
ShowWinner(winner(board), Opponent, You);
return 0;
}

void rules()
{
cout<<"Welcome to Bloodlust Shaman's first original game!\n";
cout<<"Test your skills in Dominate Diamond!\n";

cout<<"To move press a number that corresponds to you\n";
cout<<"To quit type: 'leave'   To recieve rules type: 'gamerules'!\n";
cout<<"Okay have fun and remember to never leave your guard down in this game!\n";

cout<< "   21-----22-----23-----24-----25\n";
cout<< "   | \     |    / | \    |    / |\n";
cout<< "   |  \    |   /  |  \   |   /  |\n";
cout<< "   |   \   |  /   |   \  |  /   |\n";
cout<< "   16-----17-----18-----19-----20\n";
cout<< "   |     / | \    |    / | \    |\n";
cout<< "   |    /  |  \   |   /  |  \   |\n";
cout<< "   |   /   |   \  |  /   |   \  |\n";
cout<< "   11-----12-----13-----14-----15\n";
cout<< "   | \     |    / | \    |    / |\n";
cout<< "   |  \    |   /  |  \   |   /  |\n";
cout<< "   |   \   |  /   |   \  |  /   |\n";
cout<< "   6----- 7------8----- 9----- 10\n";
cout<< "   |     / | \   |    / | \     |\n";
cout<< "   |    /  |  \  |   /  |  \    |\n";
cout<< "   |   /   |   \ |  /   |   \   |\n";
cout<< "   1----- 2----- 3----- 4 ----- 5\n\n";

cout<< "Remember to never leave your guard down!\n\n";
}

char FirstMove(string question)
{
char response;
do
{
cout<< question<< " (y/n): ";
cin>> response;
} while (response != 'y' && response != 'n' && response != 'Y' && response != 'N' && response != 'yes' && response != 'no');

return response;
}

int Movement(string question, int high, int low)
{
int number;
do
{
cout<< question << "(" << low << " - " << high << "): ";
cin>> number;
} while (number > high || number < low);

return number;
}

char YourPiece()
{
char go_first = FirstMove("Do you require the first move?");
if (go_first == 'y')
{
return H;
}
else
{
return H;
}
}

char opponent(char piece) //may have a problem here
{
return C;
}

void showBoard(const vector<char>& board)
{
cout<<"\n\t   " << board[21] << "-----" << board[22] << "-----" << board[23] << "-----" << board[24] << "-----" << board[25];
cout<<"\n\t   | \     |    / | \    |    / |";
cout<<"\n\t   |  \    |   /  |  \   |   /  |";
cout<<"\n\t   |   \   |  /   |   \  |  /   |";
cout<<"\n\t   " << board[16] << "-----" << board [17] << "-----" << board[18] << "-----" << board[19] << "-----" << board[20];
cout<<"\n\t   |     / | \    |    / | \    |";
cout<<"\n\t   |    /  |  \   |   /  |  \   |";
cout<<"\n\t   |   /   |   \  |  /   |   \  |";
cout<<"\n\t   " << board[11] << "-----" << board[12] << "-----" << board[13] << "-----" << board[14] << "-----" << board[15];
cout<<"\n\t   | \     |    / | \    |    / |";
cout<<"\n\t   |  \    |   /  |  \   |   /  |";
cout<<"\n\t   |   \   |  /   |   \  |  /   |";
cout<<"\n\t   " << board[6] << "----- " << board[7] << "-----" << board[8] << "----- " << board[9] << "----- " << board[10];
cout<<"\n\t   |     / | \    |    / | \     |";
cout<<"\n\t   |    /  |  \   |   /  |  \    |";
cout<<"\n\t   |   /   |   \  |  /   |   \   |";
cout<<"\n\t   "<< board[1] << "----- " << board[2] << "----- " << board[3] << "----- " << board[4] << " ----- "<< board[5];
cout<<"\n\n";
}

char winner(const vector<char>& board)
{
//the diamond win
const int WINNING_ROW[1][13] = { {3, 7, 8, 9, 11, 12, 13, 14, 15, 17, 18, 19, 23} };

const int TOTAL_ROW = 1;


as u see its still far away to be finish but let me show u the parts i want to show u
Code:
int YourMove(vector<char>& board, char You);
int OpponentMove(vector<char>& board, char Opponent);
void ShowWinner(char winner, char Opponent, char You);
int Points;


this was in the beginin in the code but here is where i am goin to with this does it need to go like this
Code:
int YourMove(vector<char>& board, char You, int Points);
int OpponentMove(vector<char>& board, char Opponent, int Points);
void ShowWinner(char winner, char Opponent, char You, int Points);
int Points


cause i know i am not explaining myself right but if u see the whole code u see the board and i want it so when when people make shapes in the board they can get points -example if they make a triangle or a square they get points .

but i have no idea how to do so points will be added
i do have an idea of how to show how to make shapes though kinda like this
Code:
//all posible ways making a triangle
const Triangle{ {1, 2, 7}, {2, 7, 3}, {3, 4, 9} (so one and so one) }

thats an idea but i dont know how to put that points to the computer or player if i dont make myself clear say so ill probably can explain it better


but the points is how to add points to the computer and player when they make shapes!

-for b-con: yes b-con i did looked at the book for help and did some internet search but helped no way so dont use ur time askin if i did some search

Reply With Quote
  #2  
Old August 24th, 2005, 04:17 PM
BloodlustShaman BloodlustShaman is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: in earth
Posts: 176 BloodlustShaman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 12 h 9 m 3 sec
Reputation Power: 4
Send a message via Yahoo to BloodlustShaman
So I have still been working on this and I will not show all code cause my question is do I have to make a class when it comes to adding numbers for this situation

Cause I want to keep track to points in this game also I know i have to use looping for this game.

Well heres am image so those that won't read or understand the code.

After making a move it will go like this:

You moved to section 8.(or where ever they moved to)
Your current points are: 145(an example)
Computer's current points are: 230(an example)

And i want to know if making a class for points(or numbers whatever you would like to call it) would be easier.

Also i want to know how to do so that when people make a big shape they will get points by making the small one, so like recounting

like this, the person made a big square which looks like this:

11-----12-----13
| \ | / | \ |
| \ | / | \ |
| \ | / | \ |
6----- 7------8--
| / | \ | / |
| / | \ | / |
| / | \ | / |
1----- 2----- 3--

lol yeah it looks slappy but for me its alright, k back to topic as you see there r some shapes in that place like small squares and triangles and more

Here let me point out how it to make shapes
If player(as in u) has your pieces in section 1, 2, 7 you made a small triangle, heres the shape

7
/ |
/ |
/ |
1----- 2

So now I want the player to get points for doing that(lets say 10).

Now when the player does this shape:

11-----12-----13
| \ | / | \ |
| \ | / | \ |
| \ | / | \ |
6----- 7------8--
| / | \ | / |
| / | \ | / |
| / | \ | / |
1----- 2----- 3--

I want the player to get the points for the small traingles and the other small shapes again, so for example the player gets 120 more points cause of the small triangles and i have tried to search for ways to do this and i have not found any.
All I want is when the player makes a bigger shape to get points off the small shapes again. And as i said I have looked for ways to know how to make it happen but I have found no way to do so plz help.

If you did'nt understand say so, so i can explain in different way cause I really want to finish this project

y when i put spaces here it well show with no spaces don't look at shape the cause it looks wierd look up where the source code is and look at the board cause it is looking different that it should be

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Point Making


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway