So i have a c++ project for one of my classes where i basically have to recreate the hasbro game "sorry". Im not much of a programmer so i was hoping I could get a little help from you guys. First thing i have to do is be able to read the board. This is what im given:
/* The Board */
//////////////////////////////////////////////////////////
// The different kinds of squares.
enum SquareKind {
REGULAR,
BEGIN, // Begins a slide
END, // Ends a slide
STARTSQ, // Start square for a player
HOMESQ // Home square for a player
};
struct Role { // The role played by a square
SquareKind kind;
Color color; // NONE if kind is REGULAR
};
struct Pawn {
Color color; // Color of this pawn, NONE if "no pawn here"
int num; // Number of this pawn, if Color != NONE
};
// Note: Each square is guaranteed to play at most one slide role,
// and at most one start/stop role.
struct Square {
Role slide; // Slide start, end, or REGULAR
Role ends; // Player start, home, or REGULAR
Pawn occupant; // Pawn on this square (if any)
};
// The board
struct Board {
int numSquares; // How many squares total
Square squares[MAXSQUARES];
};
there are a total of 60 squares, including these:
SQUARES 60
1 BEGIN GREEN
2 HOMESQ GREEN
4 END GREEN
4 STARTSQ GREEN
9 BEGIN GREEN
13 END GREEN
16 BEGIN RED
17 HOMESQ RED
19 END RED
19 STARTSQ RED
24 BEGIN RED
28 END RED
31 BEGIN BLUE
32 HOMESQ BLUE
34 END BLUE
34 STARTSQ BLUE
39 BEGIN BLUE
43 END BLUE
46 BEGIN YELLOW
47 HOMESQ YELLOW
49 END YELLOW
49 STARTSQ YELLOW
54 BEGIN YELLOW
58 END YELLOW
So could anyone give me some help with how to read the board please?
//////////////////////////////////////////////////////////
This isn't the most important reason people hate Sepples, but I'm sure it's a significant one.
C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do nothing but keep the C++ programmers out, that in itself would be a huge reason to use C.
>>7
But if you give substandard programmers C, you'll be inadvertently mucking up C. Do you really want that?
Name:
Anonymous2010-03-12 0:52
>>7 a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it
I know English is Linus's second language, but this is just bad writing. As soon as I read to the point where I assume that the following clause will be a consequence of the previous clause; or at the very least have some logical connection. But that is not the case at all, for the two clauses turn out to be completely independent. If we can't trust this man to write a simple sentence, why is he in charge of an operating system?
Name:
Anonymous2010-03-12 8:29
;-------------------------------------------------------------
This isn't the most important reason people hate ASM, but I'm sure it's a significant one.
Name:
Anonymous2010-03-12 8:40
>>10
He initiated the project and people respect his management skills.
Name:
Anonymous2010-03-12 8:54
I can clearly see why Linus would use ``to the point where'' the way he did: he's simply applying Finnish grammar to English. Does it really bother native English speakers that much?
>>1
You're professor is retarded. I'm not going to go through and list what he done wrong, but I don't think there is a single well reasoned line of code in there. Most glaringly though, what the fuck is with the exorbitant usage of structs?
>>13
The expression "to the point" is used correctly here. The problem in this quote is that one clause does not logically follow the other. The fact that it is easy for a programmer to generate utter crap in C++ does not logically follow the fact a lot of substandard programmers use C++ and so, it doesn't make much sense to connect these two clauses in this way. These two clauses should really be separated into two distinct sentences.
>>15
What's wrong with him being his own professor? lrn2english
Name:
Anonymous2010-03-12 10:00
>>10
You see it as "a lot use it to the point".
He said as "substandard to the poin".
It is logically connected. Hist sentences are too difficult for you, you should stick with windows.
how to read the board please
With the STL, a decorator pattern and reflection.
Name:
Anonymous2010-03-12 16:49
You're probably having difficulty wrapping your mind around reading the board, OP, because the data structures are completely fucking wrong. It's almost like whoever wrote that code didn't even bother to look at the Sorry board.
You need path types. There's the main path and there's home paths, and if the home path color matches the pawn color, then the pawn needs to fork onto the home path. You also need two slide exits: one that's standard, that ends on the main path, and one that indicates that it forks into a home path. If the color of the pawn matches the color of the slide fork, then the slide needs to bring the pawn into the home path.
Start by redefining these horrible structs into ones that actually map all the data on the board. Only then will you be able to read the board.