Transformation Rules Applied to File:Monop.java

Showing full text of file after each rule

Rules AppliedJavaKeywordRule app0.txt PPspaceRule PPifndefRule PPRule PPdefineRule.DefineReplacementRule EscapedNewlineRule snippets0b.txt TypedefRule.DefineReplacementRule FunctionPointerDeclarationRule FunctionPointerReferenceRule OneDeclarationPerLineRule ConflictingFileAndVariableRule SizeofRule ArrayDeclaration0Rule fpcleanupsnippet.txt AddBracesRule LabelRemoverRule voidstarsnippet.txt ConflictingVariableDeclarationRule StaticVariablesRule StaticFunctionsRule pointercast.txt CharToShortRule snippets0f.txt MultipleAssignmentRule readline2.lsnippet readempty.lsnippet ArrayDeclarationRule StringRule stringfunctions.txt CallocRule CallocRule.Player * players ZeroAssignmentRule DeclarationAssignmentRule PointerRule invalidStatement2.txt ArrayIndexRule StructInitRule.AddConstructorRule: Monopoly(8) StructInitRule.AddConstructorRule: Property(6) StructInitRule.AddConstructorRule: Square(4) StructInitRule.AddConstructorRule: Square(5) StructInitRule.AddConstructorRule: Square(3) ArrayInitializerRule BooleanUsageRule WrongParameterTypeRule snippets2.txt snippets2a.txt snippets3.txt ElseIfRule MainRule SignalRule PrintfRule stdin.txt IOExceptionRule UninitializedVariableRule UnreachableStatementRule InsertClassRule ImportRule (Final Version)
JavaKeywordRule
app0.txt
PPspaceRule
PPifndefRule
PPRule
PPdefineRule.DefineReplacementRule
EscapedNewlineRule
snippets0b.txt
TypedefRule.DefineReplacementRule
FunctionPointerDeclarationRule
FunctionPointerReferenceRule
OneDeclarationPerLineRule
ConflictingFileAndVariableRule
SizeofRule
ArrayDeclaration0Rule
fpcleanupsnippet.txt
AddBracesRule
LabelRemoverRule
voidstarsnippet.txt
ConflictingVariableDeclarationRule
StaticVariablesRule
StaticFunctionsRule
pointercast.txt
CharToShortRule
snippets0f.txt
MultipleAssignmentRule
readline2.lsnippet
readempty.lsnippet
ArrayDeclarationRule
StringRule
stringfunctions.txt
CallocRule
CallocRule.Player * players
ZeroAssignmentRule
DeclarationAssignmentRule
PointerRule
invalidStatement2.txt
ArrayIndexRule
StructInitRule.AddConstructorRule: Monopoly(8)
StructInitRule.AddConstructorRule: Property(6)
StructInitRule.AddConstructorRule: Square(4)
StructInitRule.AddConstructorRule: Square(5)
StructInitRule.AddConstructorRule: Square(3)
ArrayInitializerRule
BooleanUsageRule
WrongParameterTypeRule
snippets2.txt
snippets2a.txt
snippets3.txt
ElseIfRule
MainRule
SignalRule
PrintfRule
stdin.txt
IOExceptionRule
UninitializedVariableRule
UnreachableStatementRule
InsertClassRule
ImportRule
final
# include	"monop.h"
# include	"deck.h"
extern bool trading,
 spec,
 fixing,
 told_em;
extern char * yn[],
 * comlist[],
 * name_list[],
 * lucky_mes[];
extern int num_play,
 player,
 num_doub,
 num_luck;
extern void ( * func[]) ();
extern DECK deck[2];
extern MON mon[];
extern PLAY * play,
 * cur_p;
extern PROP prop[];
extern RR_S rr[];
extern SQUARE board[];
extern UTIL_S util[];
# include	"monop.h"
# include	"deck.h"
bool fixing,
 trading,
 told_em,
 spec;
char * name_list[MAX_PL + 2],
 * comlist[] = {
    "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     "mortgage",
     "unmortgage",
     "buy houses",
     "sell houses",
     "card",
     "pay",
     "trade",
     "resign",
     "save",
     "restore",
     "roll",
     "",
     0}
,
 * yn[] = {
    "yes",
     "no",
     "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     0}
,
 * lucky_mes[] = {
    "You lucky stiff",
     "You got lucky",
     "What a lucky person!",
     "You must have a 4-leaf clover",
     "My, my!  Aren't we lucky!",
     "Luck smiles upon you",
     "You got lucky this time",
     "Lucky person!",
     "Your karma must certainly be together",
     "How beautifully Cosmic",
     "Wow, you must be really with it"}
;
int player,
 num_play,
 num_doub,
 num_luck = sizeof lucky_mes / sizeof (char * );
void ( * func[]) ();
( * func[]) () = {
    quit,
     printboard,
     where,
     list,
     list_all,
     mortgage,
     unmortgage,
     buy_houses,
     sell_houses,
     card,
     pay,
     trade,
     resign,
     save,
     restore,
     do_move,
     do_move}
;
DECK deck[2];
PLAY * play,
 * cur_p;
RR_S rr[N_RR];
UTIL_S util[2];
MON mon[N_MON] = {
    #		include	"mon.dat"
}
;
PROP prop[N_PROP] = {
    #		include	"prop.dat"
}
;
SQUARE board[N_SQRS + 1] = {
    #		include	"brd.dat"
}
;
#ifndef lint
char copyright[] = "@(#) Copyright (c) 1980 Regents of the University of California.\n\
 All rights reserved.\n";
#endif
#ifndef lint
static char sccsid[] = "@(#)monop.c	5.7 (Berkeley) 6/1/90";
#endif
#include 
#include 
#include 
# include	"monop.def"
int main(register int ac, register char * * av) {
    srand(getpid());
    if (ac > 1) {
        if (!rest_f(av[1])) restore();
    }
    else {
        getplayers();
        init_players();
        init_monops();
    }
    num_luck = sizeof lucky_mes / sizeof (char * );
    init_decks();
    signal(2, sigquit);
    for (;;) {
        printf("\n%s (%d) (cash $%d) on %s\n", cur_p->name, player + 1, cur_p->money, board[cur_p->loc].name);
        printturn();
        force_morg();
        execute(getinp("-- Command: ", comlist));
    }
    return 0;
}
void getplayers(void) {
    while (!getplayers2());
}
bool getplayers2(void) {
    regchar * sp;
    regint i,
     j;
    char buf[257];
    blew_it:for (;;) {
        if ((num_play = get_int("How many players? ")) <= 0 || num_play > MAX_PL) printf("Sorry. Number must range from 1 to 9\n");
        else break;
    }
    cur_p = play = (PLAY * ) calloc(num_play, sizeof (PLAY));
    for (i = 0;i < num_play;i++) {
        over:printf("Player %d's name: ", i + 1);
        for (sp = buf;( * sp = getchar()) != '\n';sp++) continue;
        if (sp == buf) {
            i--;
            continue;
        }
         * sp++ = '\0';
        strcpy(name_list[i] = play[i].name = (char * ) calloc(1, sp - buf) , buf);
        play[i].money = 1500;
    }
    name_list[i++] = "done";
    name_list[i] = 0;
    for (i = 0;i < num_play;i++) for (j = i + 1;j < num_play;j++) if (strcasecmp(name_list[i], name_list[j]) == 0) {
        if (i != num_play - 1) printf("Hey!!! Some of those are IDENTICAL!!  Let's try that again....\n");
        else printf("\"done\" is a reserved word.  Please try again\n");
        for (i = 0;i < num_play;i++) cfree(play[i].name);
        cfree(play);
        return false;
    }
    return true;
}
void init_players(void) {
    regint i,
     rl,
     cur_max;
    bool over;
    int max_pl;
    again:do {
        putchar('\n');
        for (cur_max = i = 0;i < num_play;i++) {
            printf("%s (%d) rolls %d\n", play[i].name, i + 1, rl = roll(2, 6));
            if (rl > cur_max) {
                over = FALSE;
                cur_max = rl;
                max_pl = i;
            }
            else if (rl == cur_max) over++;
        }
        if (over) {
            printf("%d people rolled the same thing, so we'll try again\n", over + 1);
            continue;
        }
    }
    while (false);
    player = max_pl;
    cur_p = & play[max_pl];
    printf("%s (%d) goes first\n", cur_p->name, max_pl + 1);
}
void init_monops(void) {
    reg MON * mp;
    regint i;
    for (mp = mon;mp < & mon[N_MON];mp++) {
        mp->name = mp->not_m;
        for (i = 0;i < mp->num_in;i++) mp->sq[i] = & board[mp->sqnums[i]];
    }
}
# include	"monop.h"
# include	"deck.h"
extern bool trading,
 isSpecialCard,
 fixing,
 moneyStatusGiven;
extern char * yesNoChoices[],
 * commandList[],
 * playerNames[],
 * luckyMessages[];
extern int numberOfPlayers,
 currentPlayerNumber,
 numberOfDoubles,
 luckyMessagesCount;
extern void ( * functions[]) ();
extern DECK deck[2];
extern MON monopolies[];
extern PLAY * players,
 * currentPlayer;
extern PROP properties[];
extern RR_S railroads[];
extern SQUARE board[];
extern UTIL_S util[];
# include	"monop.h"
# include	"deck.h"
bool fixing,
 trading,
 moneyStatusGiven,
 isSpecialCard;
char * playerNames[MAX_PLAYERS + 2],
 * commandList[] = {
    "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     "mortgage",
     "unmortgage",
     "buy houses",
     "sell houses",
     "card",
     "pay",
     "trade",
     "resign",
     "save",
     "restore",
     "roll",
     "",
     0}
,
 * yesNoChoices[] = {
    "yes",
     "no",
     "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     0}
,
 * luckyMessages[] = {
    "You lucky stiff",
     "You got lucky",
     "What a lucky person!",
     "You must have a 4-leaf clover",
     "My, my!  Aren't we lucky!",
     "Luck smiles upon you",
     "You got lucky this time",
     "Lucky person!",
     "Your karma must certainly be together",
     "How beautifully Cosmic",
     "Wow, you must be really with it"}
;
int currentPlayerNumber,
 numberOfPlayers,
 numberOfDoubles,
 luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
void ( * functions[]) ();
( * functions[]) () = {
    quit_confirm,
     printBoard,
     printPlayerLocations,
     printHoldings,
     promptAndPrintHoldings,
     mortgagePrompt,
     unmortgagePrompt,
     buyHouses,
     sellHouses,
     playGetOutOfJailCard,
     payToGetOut,
     trade,
     resign,
     saveGame,
     restoreGame,
     doMove,
     doMove}
;
DECK deck[2];
PLAY * players,
 * currentPlayer;
RR_S railroads[NUMBER_OF_RAILROADS];
UTIL_S util[2];
MON monopolies[NUMBER_OF_MONOPOLIES] = {
    #		include	"mon.dat"
}
;
PROP properties[NUMBER_OF_PROPERTIES] = {
    #		include	"prop.dat"
}
;
SQUARE board[NUMBER_OF_SQUARES + 1] = {
    #		include	"brd.dat"
}
;
#ifndef lint
char copyright[] = "@(#) Copyright (c) 1980 Regents of the University of California.\n\
 All rights reserved.\n";
#endif
#ifndef lint
static char sccsid[] = "@(#)monop.c	5.7 (Berkeley) 6/1/90";
#endif
#include 
#include 
#include 
# include	"monop.def"
int main(register int argc, register char * * argv) {
    srand(getpid());
    if (argc > 1) {
        if (!restoreFromFile(argv[1])) restoreGame();
    }
    else {
        getPlayersLoop();
        rollToSeeWhoGoesFirst();
        initializeMonopolies();
    }
    luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
    initializeDecks();
    signal(2, sigquit);
    for (;;) {
        printf("\n%s (%d) (cash $%d) on %s\n", currentPlayer->name, currentPlayerNumber + 1, currentPlayer->money, board[currentPlayer->location].name);
        printTurn();
        fixupPrompt();
        execute(getinp("-- Command: ", commandList));
    }
    return 0;
}
void getPlayersLoop(void) {
    while (!getPlayers());
}
bool getPlayers(void) {
    regchar * sp;
    regint i,
     j;
    char buf[257];
    blew_it:for (;;) {
        if ((numberOfPlayers = getInteger("How many players? ")) <= 0 || numberOfPlayers > MAX_PLAYERS) printf("Sorry. Number must range from 1 to 9\n");
        else break;
    }
    currentPlayer = players = (PLAY * ) calloc(numberOfPlayers, sizeof (PLAY));
    for (i = 0;i < numberOfPlayers;i++) {
        over:printf("Player %d's name: ", i + 1);
        for (sp = buf;( * sp = getchar()) != '\n';sp++) continue;
        if (sp == buf) {
            i--;
            continue;
        }
         * sp++ = '\0';
        strcpy(playerNames[i] = players[i].name = (char * ) calloc(1, sp - buf) , buf);
        players[i].money = 1500;
    }
    playerNames[i++] = "done";
    playerNames[i] = 0;
    for (i = 0;i < numberOfPlayers;i++) for (j = i + 1;j < numberOfPlayers;j++) if (strcasecmp(playerNames[i], playerNames[j]) == 0) {
        if (i != numberOfPlayers - 1) printf("Hey!!! Some of those are IDENTICAL!!  Let's try that again....\n");
        else printf("\"done\" is a reserved word.  Please try again\n");
        for (i = 0;i < numberOfPlayers;i++) cfree(players[i].name);
        cfree(players);
        return false;
    }
    return true;
}
void rollToSeeWhoGoesFirst(void) {
    regint i,
     rl,
     currentMax;
    bool over;
    int max_pl;
    again:do {
        putchar('\n');
        for (currentMax = i = 0;i < numberOfPlayers;i++) {
            printf("%s (%d) rolls %d\n", players[i].name, i + 1, rl = roll(2, 6));
            if (rl > currentMax) {
                over = FALSE;
                currentMax = rl;
                max_pl = i;
            }
            else if (rl == currentMax) over++;
        }
        if (over) {
            printf("%d people rolled the same thing, so we'll try again\n", over + 1);
            continue;
        }
    }
    while (false);
    currentPlayerNumber = max_pl;
    currentPlayer = & players[max_pl];
    printf("%s (%d) goes first\n", currentPlayer->name, max_pl + 1);
}
void initializeMonopolies(void) {
    reg MON * monopoly;
    regint i;
    for (monopoly = monopolies;monopoly < & monopolies[NUMBER_OF_MONOPOLIES];monopoly++) {
        monopoly->name = monopoly->lowercaseColor;
        for (i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i] = & board[monopoly->squareNumbers[i]];
    }
}
#include	"monop.h"
#include	"deck.h"
extern bool trading,
 isSpecialCard,
 fixing,
 moneyStatusGiven;
extern char * yesNoChoices[],
 * commandList[],
 * playerNames[],
 * luckyMessages[];
extern int numberOfPlayers,
 currentPlayerNumber,
 numberOfDoubles,
 luckyMessagesCount;
extern void ( * functions[]) ();
extern DECK deck[2];
extern MON monopolies[];
extern PLAY * players,
 * currentPlayer;
extern PROP properties[];
extern RR_S railroads[];
extern SQUARE board[];
extern UTIL_S util[];
#include	"monop.h"
#include	"deck.h"
bool fixing,
 trading,
 moneyStatusGiven,
 isSpecialCard;
char * playerNames[MAX_PLAYERS + 2],
 * commandList[] = {
    "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     "mortgage",
     "unmortgage",
     "buy houses",
     "sell houses",
     "card",
     "pay",
     "trade",
     "resign",
     "save",
     "restore",
     "roll",
     "",
     0}
,
 * yesNoChoices[] = {
    "yes",
     "no",
     "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     0}
,
 * luckyMessages[] = {
    "You lucky stiff",
     "You got lucky",
     "What a lucky person!",
     "You must have a 4-leaf clover",
     "My, my!  Aren't we lucky!",
     "Luck smiles upon you",
     "You got lucky this time",
     "Lucky person!",
     "Your karma must certainly be together",
     "How beautifully Cosmic",
     "Wow, you must be really with it"}
;
int currentPlayerNumber,
 numberOfPlayers,
 numberOfDoubles,
 luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
void ( * functions[]) ();
( * functions[]) () = {
    quit_confirm,
     printBoard,
     printPlayerLocations,
     printHoldings,
     promptAndPrintHoldings,
     mortgagePrompt,
     unmortgagePrompt,
     buyHouses,
     sellHouses,
     playGetOutOfJailCard,
     payToGetOut,
     trade,
     resign,
     saveGame,
     restoreGame,
     doMove,
     doMove}
;
DECK deck[2];
PLAY * players,
 * currentPlayer;
RR_S railroads[NUMBER_OF_RAILROADS];
UTIL_S util[2];
MON monopolies[NUMBER_OF_MONOPOLIES] = {
    #include	"mon.dat"
}
;
PROP properties[NUMBER_OF_PROPERTIES] = {
    #include	"prop.dat"
}
;
SQUARE board[NUMBER_OF_SQUARES + 1] = {
    #include	"brd.dat"
}
;
#ifndef lint
char copyright[] = "@(#) Copyright (c) 1980 Regents of the University of California.\n\
 All rights reserved.\n";
#endif
#ifndef lint
static char sccsid[] = "@(#)monop.c	5.7 (Berkeley) 6/1/90";
#endif
#include 
#include 
#include 
#include	"monop.def"
int main(register int argc, register char * * argv) {
    srand(getpid());
    if (argc > 1) {
        if (!restoreFromFile(argv[1])) restoreGame();
    }
    else {
        getPlayersLoop();
        rollToSeeWhoGoesFirst();
        initializeMonopolies();
    }
    luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
    initializeDecks();
    signal(2, sigquit);
    for (;;) {
        printf("\n%s (%d) (cash $%d) on %s\n", currentPlayer->name, currentPlayerNumber + 1, currentPlayer->money, board[currentPlayer->location].name);
        printTurn();
        fixupPrompt();
        execute(getinp("-- Command: ", commandList));
    }
    return 0;
}
void getPlayersLoop(void) {
    while (!getPlayers());
}
bool getPlayers(void) {
    regchar * sp;
    regint i,
     j;
    char buf[257];
    blew_it:for (;;) {
        if ((numberOfPlayers = getInteger("How many players? ")) <= 0 || numberOfPlayers > MAX_PLAYERS) printf("Sorry. Number must range from 1 to 9\n");
        else break;
    }
    currentPlayer = players = (PLAY * ) calloc(numberOfPlayers, sizeof (PLAY));
    for (i = 0;i < numberOfPlayers;i++) {
        over:printf("Player %d's name: ", i + 1);
        for (sp = buf;( * sp = getchar()) != '\n';sp++) continue;
        if (sp == buf) {
            i--;
            continue;
        }
         * sp++ = '\0';
        strcpy(playerNames[i] = players[i].name = (char * ) calloc(1, sp - buf) , buf);
        players[i].money = 1500;
    }
    playerNames[i++] = "done";
    playerNames[i] = 0;
    for (i = 0;i < numberOfPlayers;i++) for (j = i + 1;j < numberOfPlayers;j++) if (strcasecmp(playerNames[i], playerNames[j]) == 0) {
        if (i != numberOfPlayers - 1) printf("Hey!!! Some of those are IDENTICAL!!  Let's try that again....\n");
        else printf("\"done\" is a reserved word.  Please try again\n");
        for (i = 0;i < numberOfPlayers;i++) cfree(players[i].name);
        cfree(players);
        return false;
    }
    return true;
}
void rollToSeeWhoGoesFirst(void) {
    regint i,
     rl,
     currentMax;
    bool over;
    int max_pl;
    again:do {
        putchar('\n');
        for (currentMax = i = 0;i < numberOfPlayers;i++) {
            printf("%s (%d) rolls %d\n", players[i].name, i + 1, rl = roll(2, 6));
            if (rl > currentMax) {
                over = FALSE;
                currentMax = rl;
                max_pl = i;
            }
            else if (rl == currentMax) over++;
        }
        if (over) {
            printf("%d people rolled the same thing, so we'll try again\n", over + 1);
            continue;
        }
    }
    while (false);
    currentPlayerNumber = max_pl;
    currentPlayer = & players[max_pl];
    printf("%s (%d) goes first\n", currentPlayer->name, max_pl + 1);
}
void initializeMonopolies(void) {
    reg MON * monopoly;
    regint i;
    for (monopoly = monopolies;monopoly < & monopolies[NUMBER_OF_MONOPOLIES];monopoly++) {
        monopoly->name = monopoly->lowercaseColor;
        for (i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i] = & board[monopoly->squareNumbers[i]];
    }
}
#include	"monop.h"
#include	"deck.h"
extern bool trading,
 isSpecialCard,
 fixing,
 moneyStatusGiven;
extern char * yesNoChoices[],
 * commandList[],
 * playerNames[],
 * luckyMessages[];
extern int numberOfPlayers,
 currentPlayerNumber,
 numberOfDoubles,
 luckyMessagesCount;
extern void ( * functions[]) ();
extern DECK deck[2];
extern MON monopolies[];
extern PLAY * players,
 * currentPlayer;
extern PROP properties[];
extern RR_S railroads[];
extern SQUARE board[];
extern UTIL_S util[];
#include	"monop.h"
#include	"deck.h"
bool fixing,
 trading,
 moneyStatusGiven,
 isSpecialCard;
char * playerNames[MAX_PLAYERS + 2],
 * commandList[] = {
    "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     "mortgage",
     "unmortgage",
     "buy houses",
     "sell houses",
     "card",
     "pay",
     "trade",
     "resign",
     "save",
     "restore",
     "roll",
     "",
     0}
,
 * yesNoChoices[] = {
    "yes",
     "no",
     "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     0}
,
 * luckyMessages[] = {
    "You lucky stiff",
     "You got lucky",
     "What a lucky person!",
     "You must have a 4-leaf clover",
     "My, my!  Aren't we lucky!",
     "Luck smiles upon you",
     "You got lucky this time",
     "Lucky person!",
     "Your karma must certainly be together",
     "How beautifully Cosmic",
     "Wow, you must be really with it"}
;
int currentPlayerNumber,
 numberOfPlayers,
 numberOfDoubles,
 luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
void ( * functions[]) ();
( * functions[]) () = {
    quit_confirm,
     printBoard,
     printPlayerLocations,
     printHoldings,
     promptAndPrintHoldings,
     mortgagePrompt,
     unmortgagePrompt,
     buyHouses,
     sellHouses,
     playGetOutOfJailCard,
     payToGetOut,
     trade,
     resign,
     saveGame,
     restoreGame,
     doMove,
     doMove}
;
DECK deck[2];
PLAY * players,
 * currentPlayer;
RR_S railroads[NUMBER_OF_RAILROADS];
UTIL_S util[2];
MON monopolies[NUMBER_OF_MONOPOLIES] = {
    #include	"mon.dat"
}
;
PROP properties[NUMBER_OF_PROPERTIES] = {
    #include	"prop.dat"
}
;
SQUARE board[NUMBER_OF_SQUARES + 1] = {
    #include	"brd.dat"
}
;
#if !defined(lint)
char copyright[] = "@(#) Copyright (c) 1980 Regents of the University of California.\n\
 All rights reserved.\n";
#endif
#if !defined(lint)
static char sccsid[] = "@(#)monop.c	5.7 (Berkeley) 6/1/90";
#endif
#include 
#include 
#include 
#include	"monop.def"
int main(register int argc, register char * * argv) {
    srand(getpid());
    if (argc > 1) {
        if (!restoreFromFile(argv[1])) restoreGame();
    }
    else {
        getPlayersLoop();
        rollToSeeWhoGoesFirst();
        initializeMonopolies();
    }
    luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
    initializeDecks();
    signal(2, sigquit);
    for (;;) {
        printf("\n%s (%d) (cash $%d) on %s\n", currentPlayer->name, currentPlayerNumber + 1, currentPlayer->money, board[currentPlayer->location].name);
        printTurn();
        fixupPrompt();
        execute(getinp("-- Command: ", commandList));
    }
    return 0;
}
void getPlayersLoop(void) {
    while (!getPlayers());
}
bool getPlayers(void) {
    regchar * sp;
    regint i,
     j;
    char buf[257];
    blew_it:for (;;) {
        if ((numberOfPlayers = getInteger("How many players? ")) <= 0 || numberOfPlayers > MAX_PLAYERS) printf("Sorry. Number must range from 1 to 9\n");
        else break;
    }
    currentPlayer = players = (PLAY * ) calloc(numberOfPlayers, sizeof (PLAY));
    for (i = 0;i < numberOfPlayers;i++) {
        over:printf("Player %d's name: ", i + 1);
        for (sp = buf;( * sp = getchar()) != '\n';sp++) continue;
        if (sp == buf) {
            i--;
            continue;
        }
         * sp++ = '\0';
        strcpy(playerNames[i] = players[i].name = (char * ) calloc(1, sp - buf) , buf);
        players[i].money = 1500;
    }
    playerNames[i++] = "done";
    playerNames[i] = 0;
    for (i = 0;i < numberOfPlayers;i++) for (j = i + 1;j < numberOfPlayers;j++) if (strcasecmp(playerNames[i], playerNames[j]) == 0) {
        if (i != numberOfPlayers - 1) printf("Hey!!! Some of those are IDENTICAL!!  Let's try that again....\n");
        else printf("\"done\" is a reserved word.  Please try again\n");
        for (i = 0;i < numberOfPlayers;i++) cfree(players[i].name);
        cfree(players);
        return false;
    }
    return true;
}
void rollToSeeWhoGoesFirst(void) {
    regint i,
     rl,
     currentMax;
    bool over;
    int max_pl;
    again:do {
        putchar('\n');
        for (currentMax = i = 0;i < numberOfPlayers;i++) {
            printf("%s (%d) rolls %d\n", players[i].name, i + 1, rl = roll(2, 6));
            if (rl > currentMax) {
                over = FALSE;
                currentMax = rl;
                max_pl = i;
            }
            else if (rl == currentMax) over++;
        }
        if (over) {
            printf("%d people rolled the same thing, so we'll try again\n", over + 1);
            continue;
        }
    }
    while (false);
    currentPlayerNumber = max_pl;
    currentPlayer = & players[max_pl];
    printf("%s (%d) goes first\n", currentPlayer->name, max_pl + 1);
}
void initializeMonopolies(void) {
    reg MON * monopoly;
    regint i;
    for (monopoly = monopolies;monopoly < & monopolies[NUMBER_OF_MONOPOLIES];monopoly++) {
        monopoly->name = monopoly->lowercaseColor;
        for (i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i] = & board[monopoly->squareNumbers[i]];
    }
}
extern bool trading,
 isSpecialCard,
 fixing,
 moneyStatusGiven;
extern char * yesNoChoices[],
 * commandList[],
 * playerNames[],
 * luckyMessages[];
extern int numberOfPlayers,
 currentPlayerNumber,
 numberOfDoubles,
 luckyMessagesCount;
extern void ( * functions[]) ();
extern DECK deck[2];
extern MON monopolies[];
extern PLAY * players,
 * currentPlayer;
extern PROP properties[];
extern RR_S railroads[];
extern SQUARE board[];
extern UTIL_S util[];
bool fixing,
 trading,
 moneyStatusGiven,
 isSpecialCard;
char * playerNames[MAX_PLAYERS + 2],
 * commandList[] = {
    "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     "mortgage",
     "unmortgage",
     "buy houses",
     "sell houses",
     "card",
     "pay",
     "trade",
     "resign",
     "save",
     "restore",
     "roll",
     "",
     0}
,
 * yesNoChoices[] = {
    "yes",
     "no",
     "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     0}
,
 * luckyMessages[] = {
    "You lucky stiff",
     "You got lucky",
     "What a lucky person!",
     "You must have a 4-leaf clover",
     "My, my!  Aren't we lucky!",
     "Luck smiles upon you",
     "You got lucky this time",
     "Lucky person!",
     "Your karma must certainly be together",
     "How beautifully Cosmic",
     "Wow, you must be really with it"}
;
int currentPlayerNumber,
 numberOfPlayers,
 numberOfDoubles,
 luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
void ( * functions[]) ();
( * functions[]) () = {
    quit_confirm,
     printBoard,
     printPlayerLocations,
     printHoldings,
     promptAndPrintHoldings,
     mortgagePrompt,
     unmortgagePrompt,
     buyHouses,
     sellHouses,
     playGetOutOfJailCard,
     payToGetOut,
     trade,
     resign,
     saveGame,
     restoreGame,
     doMove,
     doMove}
;
DECK deck[2];
PLAY * players,
 * currentPlayer;
RR_S railroads[NUMBER_OF_RAILROADS];
UTIL_S util[2];
MON monopolies[NUMBER_OF_MONOPOLIES] = {
    {0, - 1, 2, 0, 1, "Purple", "PURPLE", {1, 3}},
     {0, - 1, 3, 0, 1, "Lt. Blue", "LT. BLUE", {6, 8, 9}},
     {0, - 1, 3, 0, 2, "Violet", "VIOLET", {11, 13, 14}},
     {0, - 1, 3, 0, 2, "Orange", "ORANGE", {16, 18, 19}},
     {0, - 1, 3, 0, 3, "Red", "RED", {21, 23, 24}},
     {0, - 1, 3, 0, 3, "Yellow", "YELLOW", {26, 27, 29}},
     {0, - 1, 3, 0, 4, "Green", "GREEN", {31, 32, 34}},
     {0, - 1, 2, 0, 4, "Dk. Blue", "DK. BLUE", {37, 39}}}
;
PROP properties[NUMBER_OF_PROPERTIES] = {
    {0, 0, 1, 0, & mon[0], {2, 10, 30, 90, 160, 250}},
     {0, 0, 3, 0, & mon[0], {4, 20, 60, 180, 320, 450}},
     {0, 0, 6, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 7, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 9, 0, & mon[1], {8, 40, 100, 300, 450, 600}},
     {0, 0, 11, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 13, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 14, 0, & mon[2], {12, 60, 180, 500, 700, 900}},
     {0, 0, 16, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 17, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 19, 0, & mon[3], {16, 80, 220, 600, 800, 1000}},
     {0, 0, 21, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 23, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 24, 0, & mon[4], {20, 100, 300, 750, 925, 1100}},
     {0, 0, 26, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 27, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 29, 0, & mon[5], {24, 120, 360, 850, 1025, 1200}},
     {0, 0, 31, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 32, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 34, 0, & mon[6], {28, 150, 450, 1000, 1200, 1400}},
     {0, 0, 37, 0, & mon[7], {35, 175, 500, 1100, 1300, 1500}},
     {0, 0, 39, 0, & mon[7], {50, 200, 600, 1400, 1700, 2000}}}
;
SQUARE board[NUMBER_OF_SQUARES + 1] = {
    {"=== GO ===", - 1, SAFE, 0},
     {"Mediterranean ave. (P)", - 1, PRPTY, & prop[0], 60},
     {"Community Chest i", - 1, CC, },
     {"Baltic ave. (P)", - 1, PRPTY, & prop[1], 60},
     {"Income Tax", - 1, INC_TAX, },
     {"Reading RR", - 1, RR, & rr[0], 200},
     {"Oriental ave. (L)", - 1, PRPTY, & prop[2], 100},
     {"Chance i", - 1, CHANCE, },
     {"Vermont ave. (L)", - 1, PRPTY, & prop[3], 100},
     {"Connecticut ave. (L)", - 1, PRPTY, & prop[4], 120},
     {"Just Visiting", - 1, SAFE, 0},
     {"St. Charles pl. (V)", - 1, PRPTY, & prop[5], 140},
     {"Electric Co.", - 1, UTIL, & util[0], 150},
     {"States ave. (V)", - 1, PRPTY, & prop[6], 140},
     {"Virginia ave. (V)", - 1, PRPTY, & prop[7], 160},
     {"Pennsylvania RR", - 1, RR, & rr[1], 200},
     {"St. James pl. (O)", - 1, PRPTY, & prop[8], 180},
     {"Community Chest ii", - 1, CC, },
     {"Tennessee ave. (O)", - 1, PRPTY, & prop[9], 180},
     {"New York ave. (O)", - 1, PRPTY, & prop[10], 200},
     {"Free Parking", - 1, SAFE, 0},
     {"Kentucky ave. (R)", - 1, PRPTY, & prop[11], 220},
     {"Chance ii", - 1, CHANCE, },
     {"Indiana ave. (R)", - 1, PRPTY, & prop[12], 220},
     {"Illinois ave. (R)", - 1, PRPTY, & prop[13], 240},
     {"B&O RR", - 1, RR, & rr[2], 200},
     {"Atlantic ave. (Y)", - 1, PRPTY, & prop[14], 260},
     {"Ventnor ave. (Y)", - 1, PRPTY, & prop[15], 260},
     {"Water Works", - 1, UTIL, & util[1], 150},
     {"Marvin Gardens (Y)", - 1, PRPTY, & prop[16], 280},
     {"GO TO JAIL", - 1, GOTO_J, },
     {"Pacific ave. (G)", - 1, PRPTY, & prop[17], 300},
     {"N. Carolina ave. (G)", - 1, PRPTY, & prop[18], 300},
     {"Community Chest iii", - 1, CC, },
     {"Pennsylvania ave. (G)", - 1, PRPTY, & prop[19], 320},
     {"Short Line RR", - 1, RR, & rr[3], 200},
     {"Chance iii", - 1, CHANCE, },
     {"Park place (D)", - 1, PRPTY, & prop[20], 350},
     {"Luxury Tax", - 1, LUX_TAX, },
     {"Boardwalk (D)", - 1, PRPTY, & prop[21], 400},
     {"JAIL", - 1, IN_JAIL, }}
;
char copyright[] = "@(#) Copyright (c) 1980 Regents of the University of California.\n\
 All rights reserved.\n";
static char sccsid[] = "@(#)monop.c	5.7 (Berkeley) 6/1/90";
int main(register int argc, register char * * argv) {
    srand(getpid());
    if (argc > 1) {
        if (!restoreFromFile(argv[1])) restoreGame();
    }
    else {
        getPlayersLoop();
        rollToSeeWhoGoesFirst();
        initializeMonopolies();
    }
    luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
    initializeDecks();
    signal(2, sigquit);
    for (;;) {
        printf("\n%s (%d) (cash $%d) on %s\n", currentPlayer->name, currentPlayerNumber + 1, currentPlayer->money, board[currentPlayer->location].name);
        printTurn();
        fixupPrompt();
        execute(getinp("-- Command: ", commandList));
    }
    return 0;
}
void getPlayersLoop(void) {
    while (!getPlayers());
}
bool getPlayers(void) {
    regchar * sp;
    regint i,
     j;
    char buf[257];
    blew_it:for (;;) {
        if ((numberOfPlayers = getInteger("How many players? ")) <= 0 || numberOfPlayers > MAX_PLAYERS) printf("Sorry. Number must range from 1 to 9\n");
        else break;
    }
    currentPlayer = players = (PLAY * ) calloc(numberOfPlayers, sizeof (PLAY));
    for (i = 0;i < numberOfPlayers;i++) {
        over:printf("Player %d's name: ", i + 1);
        for (sp = buf;( * sp = getchar()) != '\n';sp++) continue;
        if (sp == buf) {
            i--;
            continue;
        }
         * sp++ = '\0';
        strcpy(playerNames[i] = players[i].name = (char * ) calloc(1, sp - buf) , buf);
        players[i].money = 1500;
    }
    playerNames[i++] = "done";
    playerNames[i] = 0;
    for (i = 0;i < numberOfPlayers;i++) for (j = i + 1;j < numberOfPlayers;j++) if (strcasecmp(playerNames[i], playerNames[j]) == 0) {
        if (i != numberOfPlayers - 1) printf("Hey!!! Some of those are IDENTICAL!!  Let's try that again....\n");
        else printf("\"done\" is a reserved word.  Please try again\n");
        for (i = 0;i < numberOfPlayers;i++) cfree(players[i].name);
        cfree(players);
        return false;
    }
    return true;
}
void rollToSeeWhoGoesFirst(void) {
    regint i,
     rl,
     currentMax;
    bool over;
    int max_pl;
    again:do {
        putchar('\n');
        for (currentMax = i = 0;i < numberOfPlayers;i++) {
            printf("%s (%d) rolls %d\n", players[i].name, i + 1, rl = roll(2, 6));
            if (rl > currentMax) {
                over = FALSE;
                currentMax = rl;
                max_pl = i;
            }
            else if (rl == currentMax) over++;
        }
        if (over) {
            printf("%d people rolled the same thing, so we'll try again\n", over + 1);
            continue;
        }
    }
    while (false);
    currentPlayerNumber = max_pl;
    currentPlayer = & players[max_pl];
    printf("%s (%d) goes first\n", currentPlayer->name, max_pl + 1);
}
void initializeMonopolies(void) {
    reg MON * monopoly;
    regint i;
    for (monopoly = monopolies;monopoly < & monopolies[NUMBER_OF_MONOPOLIES];monopoly++) {
        monopoly->name = monopoly->lowercaseColor;
        for (i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i] = & board[monopoly->squareNumbers[i]];
    }
}
extern boolean trading,
 isSpecialCard,
 fixing,
 moneyStatusGiven;
extern char * yesNoChoices[],
 * commandList[],
 * playerNames[],
 * luckyMessages[];
extern int numberOfPlayers,
 currentPlayerNumber,
 numberOfDoubles,
 luckyMessagesCount;
extern void ( * functions[]) ();
extern DECK deck[2];
extern MON monopolies[];
extern PLAY * players,
 * currentPlayer;
extern PROP properties[];
extern RR_S railroads[];
extern SQUARE board[];
extern UTIL_S util[];
boolean fixing,
 trading,
 moneyStatusGiven,
 isSpecialCard;
char * playerNames[MAX_PLAYERS + 2],
 * commandList[] = {
    "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     "mortgage",
     "unmortgage",
     "buy houses",
     "sell houses",
     "card",
     "pay",
     "trade",
     "resign",
     "save",
     "restore",
     "roll",
     "",
     0}
,
 * yesNoChoices[] = {
    "yes",
     "no",
     "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     0}
,
 * luckyMessages[] = {
    "You lucky stiff",
     "You got lucky",
     "What a lucky person!",
     "You must have a 4-leaf clover",
     "My, my!  Aren't we lucky!",
     "Luck smiles upon you",
     "You got lucky this time",
     "Lucky person!",
     "Your karma must certainly be together",
     "How beautifully Cosmic",
     "Wow, you must be really with it"}
;
int currentPlayerNumber,
 numberOfPlayers,
 numberOfDoubles,
 luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
void ( * functions[]) ();
( * functions[]) () = {
    quit_confirm,
     printBoard,
     printPlayerLocations,
     printHoldings,
     promptAndPrintHoldings,
     mortgagePrompt,
     unmortgagePrompt,
     buyHouses,
     sellHouses,
     playGetOutOfJailCard,
     payToGetOut,
     trade,
     resign,
     saveGame,
     restoreGame,
     doMove,
     doMove}
;
DECK deck[2];
PLAY * players,
 * currentPlayer;
RR_S railroads[NUMBER_OF_RAILROADS];
UTIL_S util[2];
MON monopolies[NUMBER_OF_MONOPOLIES] = {
    {0, - 1, 2, 0, 1, "Purple", "PURPLE", {1, 3}},
     {0, - 1, 3, 0, 1, "Lt. Blue", "LT. BLUE", {6, 8, 9}},
     {0, - 1, 3, 0, 2, "Violet", "VIOLET", {11, 13, 14}},
     {0, - 1, 3, 0, 2, "Orange", "ORANGE", {16, 18, 19}},
     {0, - 1, 3, 0, 3, "Red", "RED", {21, 23, 24}},
     {0, - 1, 3, 0, 3, "Yellow", "YELLOW", {26, 27, 29}},
     {0, - 1, 3, 0, 4, "Green", "GREEN", {31, 32, 34}},
     {0, - 1, 2, 0, 4, "Dk. Blue", "DK. BLUE", {37, 39}}}
;
PROP properties[NUMBER_OF_PROPERTIES] = {
    {0, 0, 1, 0, & mon[0], {2, 10, 30, 90, 160, 250}},
     {0, 0, 3, 0, & mon[0], {4, 20, 60, 180, 320, 450}},
     {0, 0, 6, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 7, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 9, 0, & mon[1], {8, 40, 100, 300, 450, 600}},
     {0, 0, 11, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 13, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 14, 0, & mon[2], {12, 60, 180, 500, 700, 900}},
     {0, 0, 16, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 17, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 19, 0, & mon[3], {16, 80, 220, 600, 800, 1000}},
     {0, 0, 21, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 23, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 24, 0, & mon[4], {20, 100, 300, 750, 925, 1100}},
     {0, 0, 26, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 27, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 29, 0, & mon[5], {24, 120, 360, 850, 1025, 1200}},
     {0, 0, 31, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 32, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 34, 0, & mon[6], {28, 150, 450, 1000, 1200, 1400}},
     {0, 0, 37, 0, & mon[7], {35, 175, 500, 1100, 1300, 1500}},
     {0, 0, 39, 0, & mon[7], {50, 200, 600, 1400, 1700, 2000}}}
;
SQUARE board[NUMBER_OF_SQUARES + 1] = {
    {"=== GO ===", - 1, SAFE, 0},
     {"Mediterranean ave. (P)", - 1, PRPTY, & prop[0], 60},
     {"Community Chest i", - 1, CC, },
     {"Baltic ave. (P)", - 1, PRPTY, & prop[1], 60},
     {"Income Tax", - 1, INC_TAX, },
     {"Reading RR", - 1, RR, & rr[0], 200},
     {"Oriental ave. (L)", - 1, PRPTY, & prop[2], 100},
     {"Chance i", - 1, CHANCE, },
     {"Vermont ave. (L)", - 1, PRPTY, & prop[3], 100},
     {"Connecticut ave. (L)", - 1, PRPTY, & prop[4], 120},
     {"Just Visiting", - 1, SAFE, 0},
     {"St. Charles pl. (V)", - 1, PRPTY, & prop[5], 140},
     {"Electric Co.", - 1, UTIL, & util[0], 150},
     {"States ave. (V)", - 1, PRPTY, & prop[6], 140},
     {"Virginia ave. (V)", - 1, PRPTY, & prop[7], 160},
     {"Pennsylvania RR", - 1, RR, & rr[1], 200},
     {"St. James pl. (O)", - 1, PRPTY, & prop[8], 180},
     {"Community Chest ii", - 1, CC, },
     {"Tennessee ave. (O)", - 1, PRPTY, & prop[9], 180},
     {"New York ave. (O)", - 1, PRPTY, & prop[10], 200},
     {"Free Parking", - 1, SAFE, 0},
     {"Kentucky ave. (R)", - 1, PRPTY, & prop[11], 220},
     {"Chance ii", - 1, CHANCE, },
     {"Indiana ave. (R)", - 1, PRPTY, & prop[12], 220},
     {"Illinois ave. (R)", - 1, PRPTY, & prop[13], 240},
     {"B&O RR", - 1, RR, & rr[2], 200},
     {"Atlantic ave. (Y)", - 1, PRPTY, & prop[14], 260},
     {"Ventnor ave. (Y)", - 1, PRPTY, & prop[15], 260},
     {"Water Works", - 1, UTIL, & util[1], 150},
     {"Marvin Gardens (Y)", - 1, PRPTY, & prop[16], 280},
     {"GO TO JAIL", - 1, GOTO_J, },
     {"Pacific ave. (G)", - 1, PRPTY, & prop[17], 300},
     {"N. Carolina ave. (G)", - 1, PRPTY, & prop[18], 300},
     {"Community Chest iii", - 1, CC, },
     {"Pennsylvania ave. (G)", - 1, PRPTY, & prop[19], 320},
     {"Short Line RR", - 1, RR, & rr[3], 200},
     {"Chance iii", - 1, CHANCE, },
     {"Park place (D)", - 1, PRPTY, & prop[20], 350},
     {"Luxury Tax", - 1, LUX_TAX, },
     {"Boardwalk (D)", - 1, PRPTY, & prop[21], 400},
     {"JAIL", - 1, IN_JAIL, }}
;
char copyright[] = "@(#) Copyright (c) 1980 Regents of the University of California.\n\
 All rights reserved.\n";
static char sccsid[] = "@(#)monop.c	5.7 (Berkeley) 6/1/90";
int main(register int argc, register char * * argv) {
    srand(getpid());
    if (argc > 1) {
        if (!restoreFromFile(argv[1])) restoreGame();
    }
    else {
        getPlayersLoop();
        rollToSeeWhoGoesFirst();
        initializeMonopolies();
    }
    luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
    initializeDecks();
    signal(2, sigquit);
    for (;;) {
        printf("\n%s (%d) (cash $%d) on %s\n", currentPlayer->name, currentPlayerNumber + 1, currentPlayer->money, board[currentPlayer->location].name);
        printTurn();
        fixupPrompt();
        execute(getinp("-- Command: ", commandList));
    }
    return 0;
}
void getPlayersLoop(void) {
    while (!getPlayers());
}
boolean getPlayers(void) {
    register char * sp;
    register int i,
     j;
    char buf[257];
    blew_it:for (;;) {
        if ((numberOfPlayers = getInteger("How many players? ")) <= 0 || numberOfPlayers > MAX_PLAYERS) printf("Sorry. Number must range from 1 to 9\n");
        else break;
    }
    currentPlayer = players = (PLAY * ) calloc(numberOfPlayers, sizeof (PLAY));
    for (i = 0;i < numberOfPlayers;i++) {
        over:printf("Player %d's name: ", i + 1);
        for (sp = buf;( * sp = getchar()) != '\n';sp++) continue;
        if (sp == buf) {
            i--;
            continue;
        }
         * sp++ = '\0';
        strcpy(playerNames[i] = players[i].name = (char * ) calloc(1, sp - buf) , buf);
        players[i].money = 1500;
    }
    playerNames[i++] = "done";
    playerNames[i] = 0;
    for (i = 0;i < numberOfPlayers;i++) for (j = i + 1;j < numberOfPlayers;j++) if (strcasecmp(playerNames[i], playerNames[j]) == 0) {
        if (i != numberOfPlayers - 1) printf("Hey!!! Some of those are IDENTICAL!!  Let's try that again....\n");
        else printf("\"done\" is a reserved word.  Please try again\n");
        for (i = 0;i < numberOfPlayers;i++) cfree(players[i].name);
        cfree(players);
        return false;
    }
    return true;
}
void rollToSeeWhoGoesFirst(void) {
    register int i,
     rl,
     currentMax;
    boolean over;
    int max_pl;
    again:do {
        putchar('\n');
        for (currentMax = i = 0;i < numberOfPlayers;i++) {
            printf("%s (%d) rolls %d\n", players[i].name, i + 1, rl = roll(2, 6));
            if (rl > currentMax) {
                over = false;
                currentMax = rl;
                max_pl = i;
            }
            else if (rl == currentMax) over++;
        }
        if (over) {
            printf("%d people rolled the same thing, so we'll try again\n", over + 1);
            continue;
        }
    }
    while (false);
    currentPlayerNumber = max_pl;
    currentPlayer = & players[max_pl];
    printf("%s (%d) goes first\n", currentPlayer->name, max_pl + 1);
}
void initializeMonopolies(void) {
    register MON * monopoly;
    register int i;
    for (monopoly = monopolies;monopoly < & monopolies[NUMBER_OF_MONOPOLIES];monopoly++) {
        monopoly->name = monopoly->lowercaseColor;
        for (i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i] = & board[monopoly->squareNumbers[i]];
    }
}
extern boolean trading,
 isSpecialCard,
 fixing,
 moneyStatusGiven;
extern char * yesNoChoices[],
 * commandList[],
 * playerNames[],
 * luckyMessages[];
extern int numberOfPlayers,
 currentPlayerNumber,
 numberOfDoubles,
 luckyMessagesCount;
extern void ( * functions[]) ();
extern DECK deck[2];
extern MON monopolies[];
extern PLAY * players,
 * currentPlayer;
extern PROP properties[];
extern RR_S railroads[];
extern SQUARE board[];
extern UTIL_S util[];
boolean fixing,
 trading,
 moneyStatusGiven,
 isSpecialCard;
char * playerNames[MAX_PLAYERS + 2],
 * commandList[] = {
    "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     "mortgage",
     "unmortgage",
     "buy houses",
     "sell houses",
     "card",
     "pay",
     "trade",
     "resign",
     "save",
     "restore",
     "roll",
     "",
     0}
,
 * yesNoChoices[] = {
    "yes",
     "no",
     "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     0}
,
 * luckyMessages[] = {
    "You lucky stiff",
     "You got lucky",
     "What a lucky person!",
     "You must have a 4-leaf clover",
     "My, my!  Aren't we lucky!",
     "Luck smiles upon you",
     "You got lucky this time",
     "Lucky person!",
     "Your karma must certainly be together",
     "How beautifully Cosmic",
     "Wow, you must be really with it"}
;
int currentPlayerNumber,
 numberOfPlayers,
 numberOfDoubles,
 luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
void ( * functions[]) ();
( * functions[]) () = {
    quit_confirm,
     printBoard,
     printPlayerLocations,
     printHoldings,
     promptAndPrintHoldings,
     mortgagePrompt,
     unmortgagePrompt,
     buyHouses,
     sellHouses,
     playGetOutOfJailCard,
     payToGetOut,
     trade,
     resign,
     saveGame,
     restoreGame,
     doMove,
     doMove}
;
DECK deck[2];
PLAY * players,
 * currentPlayer;
RR_S railroads[NUMBER_OF_RAILROADS];
UTIL_S util[2];
MON monopolies[NUMBER_OF_MONOPOLIES] = {
    {0, - 1, 2, 0, 1, "Purple", "PURPLE", {1, 3}},
     {0, - 1, 3, 0, 1, "Lt. Blue", "LT. BLUE", {6, 8, 9}},
     {0, - 1, 3, 0, 2, "Violet", "VIOLET", {11, 13, 14}},
     {0, - 1, 3, 0, 2, "Orange", "ORANGE", {16, 18, 19}},
     {0, - 1, 3, 0, 3, "Red", "RED", {21, 23, 24}},
     {0, - 1, 3, 0, 3, "Yellow", "YELLOW", {26, 27, 29}},
     {0, - 1, 3, 0, 4, "Green", "GREEN", {31, 32, 34}},
     {0, - 1, 2, 0, 4, "Dk. Blue", "DK. BLUE", {37, 39}}}
;
PROP properties[NUMBER_OF_PROPERTIES] = {
    {0, 0, 1, 0, & mon[0], {2, 10, 30, 90, 160, 250}},
     {0, 0, 3, 0, & mon[0], {4, 20, 60, 180, 320, 450}},
     {0, 0, 6, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 7, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 9, 0, & mon[1], {8, 40, 100, 300, 450, 600}},
     {0, 0, 11, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 13, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 14, 0, & mon[2], {12, 60, 180, 500, 700, 900}},
     {0, 0, 16, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 17, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 19, 0, & mon[3], {16, 80, 220, 600, 800, 1000}},
     {0, 0, 21, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 23, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 24, 0, & mon[4], {20, 100, 300, 750, 925, 1100}},
     {0, 0, 26, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 27, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 29, 0, & mon[5], {24, 120, 360, 850, 1025, 1200}},
     {0, 0, 31, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 32, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 34, 0, & mon[6], {28, 150, 450, 1000, 1200, 1400}},
     {0, 0, 37, 0, & mon[7], {35, 175, 500, 1100, 1300, 1500}},
     {0, 0, 39, 0, & mon[7], {50, 200, 600, 1400, 1700, 2000}}}
;
SQUARE board[NUMBER_OF_SQUARES + 1] = {
    {"=== GO ===", - 1, SAFE, 0},
     {"Mediterranean ave. (P)", - 1, PRPTY, & prop[0], 60},
     {"Community Chest i", - 1, CC, },
     {"Baltic ave. (P)", - 1, PRPTY, & prop[1], 60},
     {"Income Tax", - 1, INC_TAX, },
     {"Reading RR", - 1, RR, & rr[0], 200},
     {"Oriental ave. (L)", - 1, PRPTY, & prop[2], 100},
     {"Chance i", - 1, CHANCE, },
     {"Vermont ave. (L)", - 1, PRPTY, & prop[3], 100},
     {"Connecticut ave. (L)", - 1, PRPTY, & prop[4], 120},
     {"Just Visiting", - 1, SAFE, 0},
     {"St. Charles pl. (V)", - 1, PRPTY, & prop[5], 140},
     {"Electric Co.", - 1, UTIL, & util[0], 150},
     {"States ave. (V)", - 1, PRPTY, & prop[6], 140},
     {"Virginia ave. (V)", - 1, PRPTY, & prop[7], 160},
     {"Pennsylvania RR", - 1, RR, & rr[1], 200},
     {"St. James pl. (O)", - 1, PRPTY, & prop[8], 180},
     {"Community Chest ii", - 1, CC, },
     {"Tennessee ave. (O)", - 1, PRPTY, & prop[9], 180},
     {"New York ave. (O)", - 1, PRPTY, & prop[10], 200},
     {"Free Parking", - 1, SAFE, 0},
     {"Kentucky ave. (R)", - 1, PRPTY, & prop[11], 220},
     {"Chance ii", - 1, CHANCE, },
     {"Indiana ave. (R)", - 1, PRPTY, & prop[12], 220},
     {"Illinois ave. (R)", - 1, PRPTY, & prop[13], 240},
     {"B&O RR", - 1, RR, & rr[2], 200},
     {"Atlantic ave. (Y)", - 1, PRPTY, & prop[14], 260},
     {"Ventnor ave. (Y)", - 1, PRPTY, & prop[15], 260},
     {"Water Works", - 1, UTIL, & util[1], 150},
     {"Marvin Gardens (Y)", - 1, PRPTY, & prop[16], 280},
     {"GO TO JAIL", - 1, GOTO_J, },
     {"Pacific ave. (G)", - 1, PRPTY, & prop[17], 300},
     {"N. Carolina ave. (G)", - 1, PRPTY, & prop[18], 300},
     {"Community Chest iii", - 1, CC, },
     {"Pennsylvania ave. (G)", - 1, PRPTY, & prop[19], 320},
     {"Short Line RR", - 1, RR, & rr[3], 200},
     {"Chance iii", - 1, CHANCE, },
     {"Park place (D)", - 1, PRPTY, & prop[20], 350},
     {"Luxury Tax", - 1, LUX_TAX, },
     {"Boardwalk (D)", - 1, PRPTY, & prop[21], 400},
     {"JAIL", - 1, IN_JAIL, }}
;
char copyright[] = "@(#) Copyright (c) 1980 Regents of the University of California.\n" + " All rights reserved.\n";
static char sccsid[] = "@(#)monop.c	5.7 (Berkeley) 6/1/90";
int main(register int argc, register char * * argv) {
    srand(getpid());
    if (argc > 1) {
        if (!restoreFromFile(argv[1])) restoreGame();
    }
    else {
        getPlayersLoop();
        rollToSeeWhoGoesFirst();
        initializeMonopolies();
    }
    luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
    initializeDecks();
    signal(2, sigquit);
    for (;;) {
        printf("\n%s (%d) (cash $%d) on %s\n", currentPlayer->name, currentPlayerNumber + 1, currentPlayer->money, board[currentPlayer->location].name);
        printTurn();
        fixupPrompt();
        execute(getinp("-- Command: ", commandList));
    }
    return 0;
}
void getPlayersLoop(void) {
    while (!getPlayers());
}
boolean getPlayers(void) {
    register char * sp;
    register int i,
     j;
    char buf[257];
    blew_it:for (;;) {
        if ((numberOfPlayers = getInteger("How many players? ")) <= 0 || numberOfPlayers > MAX_PLAYERS) printf("Sorry. Number must range from 1 to 9\n");
        else break;
    }
    currentPlayer = players = (PLAY * ) calloc(numberOfPlayers, sizeof (PLAY));
    for (i = 0;i < numberOfPlayers;i++) {
        over:printf("Player %d's name: ", i + 1);
        for (sp = buf;( * sp = getchar()) != '\n';sp++) continue;
        if (sp == buf) {
            i--;
            continue;
        }
         * sp++ = '\0';
        strcpy(playerNames[i] = players[i].name = (char * ) calloc(1, sp - buf) , buf);
        players[i].money = 1500;
    }
    playerNames[i++] = "done";
    playerNames[i] = 0;
    for (i = 0;i < numberOfPlayers;i++) for (j = i + 1;j < numberOfPlayers;j++) if (strcasecmp(playerNames[i], playerNames[j]) == 0) {
        if (i != numberOfPlayers - 1) printf("Hey!!! Some of those are IDENTICAL!!  Let's try that again....\n");
        else printf("\"done\" is a reserved word.  Please try again\n");
        for (i = 0;i < numberOfPlayers;i++) cfree(players[i].name);
        cfree(players);
        return false;
    }
    return true;
}
void rollToSeeWhoGoesFirst(void) {
    register int i,
     rl,
     currentMax;
    boolean over;
    int max_pl;
    again:do {
        putchar('\n');
        for (currentMax = i = 0;i < numberOfPlayers;i++) {
            printf("%s (%d) rolls %d\n", players[i].name, i + 1, rl = roll(2, 6));
            if (rl > currentMax) {
                over = false;
                currentMax = rl;
                max_pl = i;
            }
            else if (rl == currentMax) over++;
        }
        if (over) {
            printf("%d people rolled the same thing, so we'll try again\n", over + 1);
            continue;
        }
    }
    while (false);
    currentPlayerNumber = max_pl;
    currentPlayer = & players[max_pl];
    printf("%s (%d) goes first\n", currentPlayer->name, max_pl + 1);
}
void initializeMonopolies(void) {
    register MON * monopoly;
    register int i;
    for (monopoly = monopolies;monopoly < & monopolies[NUMBER_OF_MONOPOLIES];monopoly++) {
        monopoly->name = monopoly->lowercaseColor;
        for (i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i] = & board[monopoly->squareNumbers[i]];
    }
}
boolean fixing,
 trading,
 moneyStatusGiven,
 isSpecialCard;
char * playerNames[MAX_PLAYERS + 2],
 * commandList[] = {
    "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     "mortgage",
     "unmortgage",
     "buy houses",
     "sell houses",
     "card",
     "pay",
     "trade",
     "resign",
     "save",
     "restore",
     "roll",
     "",
     0}
,
 * yesNoChoices[] = {
    "yes",
     "no",
     "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     0}
,
 * luckyMessages[] = {
    "You lucky stiff",
     "You got lucky",
     "What a lucky person!",
     "You must have a 4-leaf clover",
     "My, my!  Aren't we lucky!",
     "Luck smiles upon you",
     "You got lucky this time",
     "Lucky person!",
     "Your karma must certainly be together",
     "How beautifully Cosmic",
     "Wow, you must be really with it"}
;
int currentPlayerNumber,
 numberOfPlayers,
 numberOfDoubles,
 luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
void ( * functions[]) ();
( * functions[]) () = {
    quit_confirm,
     printBoard,
     printPlayerLocations,
     printHoldings,
     promptAndPrintHoldings,
     mortgagePrompt,
     unmortgagePrompt,
     buyHouses,
     sellHouses,
     playGetOutOfJailCard,
     payToGetOut,
     trade,
     resign,
     saveGame,
     restoreGame,
     doMove,
     doMove}
;
DECK deck[2];
PLAY * players,
 * currentPlayer;
RR_S railroads[NUMBER_OF_RAILROADS];
UTIL_S util[2];
MON monopolies[NUMBER_OF_MONOPOLIES] = {
    {0, - 1, 2, 0, 1, "Purple", "PURPLE", {1, 3}},
     {0, - 1, 3, 0, 1, "Lt. Blue", "LT. BLUE", {6, 8, 9}},
     {0, - 1, 3, 0, 2, "Violet", "VIOLET", {11, 13, 14}},
     {0, - 1, 3, 0, 2, "Orange", "ORANGE", {16, 18, 19}},
     {0, - 1, 3, 0, 3, "Red", "RED", {21, 23, 24}},
     {0, - 1, 3, 0, 3, "Yellow", "YELLOW", {26, 27, 29}},
     {0, - 1, 3, 0, 4, "Green", "GREEN", {31, 32, 34}},
     {0, - 1, 2, 0, 4, "Dk. Blue", "DK. BLUE", {37, 39}}}
;
PROP properties[NUMBER_OF_PROPERTIES] = {
    {0, 0, 1, 0, & mon[0], {2, 10, 30, 90, 160, 250}},
     {0, 0, 3, 0, & mon[0], {4, 20, 60, 180, 320, 450}},
     {0, 0, 6, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 7, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 9, 0, & mon[1], {8, 40, 100, 300, 450, 600}},
     {0, 0, 11, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 13, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 14, 0, & mon[2], {12, 60, 180, 500, 700, 900}},
     {0, 0, 16, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 17, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 19, 0, & mon[3], {16, 80, 220, 600, 800, 1000}},
     {0, 0, 21, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 23, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 24, 0, & mon[4], {20, 100, 300, 750, 925, 1100}},
     {0, 0, 26, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 27, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 29, 0, & mon[5], {24, 120, 360, 850, 1025, 1200}},
     {0, 0, 31, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 32, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 34, 0, & mon[6], {28, 150, 450, 1000, 1200, 1400}},
     {0, 0, 37, 0, & mon[7], {35, 175, 500, 1100, 1300, 1500}},
     {0, 0, 39, 0, & mon[7], {50, 200, 600, 1400, 1700, 2000}}}
;
SQUARE board[NUMBER_OF_SQUARES + 1] = {
    {"=== GO ===", - 1, SAFE, 0},
     {"Mediterranean ave. (P)", - 1, PRPTY, & prop[0], 60},
     {"Community Chest i", - 1, CC},
     {"Baltic ave. (P)", - 1, PRPTY, & prop[1], 60},
     {"Income Tax", - 1, INC_TAX},
     {"Reading RR", - 1, RR, & rr[0], 200},
     {"Oriental ave. (L)", - 1, PRPTY, & prop[2], 100},
     {"Chance i", - 1, CHANCE},
     {"Vermont ave. (L)", - 1, PRPTY, & prop[3], 100},
     {"Connecticut ave. (L)", - 1, PRPTY, & prop[4], 120},
     {"Just Visiting", - 1, SAFE, 0},
     {"St. Charles pl. (V)", - 1, PRPTY, & prop[5], 140},
     {"Electric Co.", - 1, UTIL, & util[0], 150},
     {"States ave. (V)", - 1, PRPTY, & prop[6], 140},
     {"Virginia ave. (V)", - 1, PRPTY, & prop[7], 160},
     {"Pennsylvania RR", - 1, RR, & rr[1], 200},
     {"St. James pl. (O)", - 1, PRPTY, & prop[8], 180},
     {"Community Chest ii", - 1, CC},
     {"Tennessee ave. (O)", - 1, PRPTY, & prop[9], 180},
     {"New York ave. (O)", - 1, PRPTY, & prop[10], 200},
     {"Free Parking", - 1, SAFE, 0},
     {"Kentucky ave. (R)", - 1, PRPTY, & prop[11], 220},
     {"Chance ii", - 1, CHANCE},
     {"Indiana ave. (R)", - 1, PRPTY, & prop[12], 220},
     {"Illinois ave. (R)", - 1, PRPTY, & prop[13], 240},
     {"B&O RR", - 1, RR, & rr[2], 200},
     {"Atlantic ave. (Y)", - 1, PRPTY, & prop[14], 260},
     {"Ventnor ave. (Y)", - 1, PRPTY, & prop[15], 260},
     {"Water Works", - 1, UTIL, & util[1], 150},
     {"Marvin Gardens (Y)", - 1, PRPTY, & prop[16], 280},
     {"GO TO JAIL", - 1, GOTO_J},
     {"Pacific ave. (G)", - 1, PRPTY, & prop[17], 300},
     {"N. Carolina ave. (G)", - 1, PRPTY, & prop[18], 300},
     {"Community Chest iii", - 1, CC},
     {"Pennsylvania ave. (G)", - 1, PRPTY, & prop[19], 320},
     {"Short Line RR", - 1, RR, & rr[3], 200},
     {"Chance iii", - 1, CHANCE},
     {"Park place (D)", - 1, PRPTY, & prop[20], 350},
     {"Luxury Tax", - 1, LUX_TAX},
     {"Boardwalk (D)", - 1, PRPTY, & prop[21], 400},
     {"JAIL", - 1, IN_JAIL}}
;
char copyright[] = "@(#) Copyright (c) 1980 Regents of the University of California.\n" + " All rights reserved.\n";
static char sccsid[] = "@(#)monop.c	5.7 (Berkeley) 6/1/90";
int main(int argc, char * * argv) {
    srand(getpid());
    if (argc > 1) {
        if (!restoreFromFile(argv[1])) restoreGame();
    }
    else {
        getPlayersLoop();
        rollToSeeWhoGoesFirst();
        initializeMonopolies();
    }
    luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
    initializeDecks();
    signal(2, sigquit);
    while (true) {
        printf("\n%s (%d) (cash $%d) on %s\n", currentPlayer->name, currentPlayerNumber + 1, currentPlayer->money, board[currentPlayer->location].name);
        printTurn();
        fixupPrompt();
        execute(getinp("-- Command: ", commandList));
    }
    return 0;
}
void getPlayersLoop(void) {
    while (!getPlayers());
}
boolean getPlayers(void) {
    char * sp;
    int i,
     j;
    char buf[257];
    blew_it:while (true) {
        if ((numberOfPlayers = getInteger("How many players? ")) <= 0 || numberOfPlayers > MAX_PLAYERS) printf("Sorry. Number must range from 1 to 9\n");
        else break;
    }
    currentPlayer = players = (PLAY * ) calloc(numberOfPlayers, sizeof (PLAY));
    for (i = 0;i < numberOfPlayers;i++) {
        over:printf("Player %d's name: ", i + 1);
        for (sp = buf;( * sp = getchar()) != '\n';sp++) continue;
        if (sp == buf) {
            i--;
            continue;
        }
         * sp++ = '\0';
        strcpy(playerNames[i] = players[i].name = (char * ) calloc(1, sp - buf) , buf);
        players[i].money = 1500;
    }
    playerNames[i++] = "done";
    playerNames[i] = 0;
    for (i = 0;i < numberOfPlayers;i++) for (j = i + 1;j < numberOfPlayers;j++) if (strcasecmp(playerNames[i], playerNames[j]) == 0) {
        if (i != numberOfPlayers - 1) printf("Hey!!! Some of those are IDENTICAL!!  Let's try that again....\n");
        else printf("\"done\" is a reserved word.  Please try again\n");
        for (i = 0;i < numberOfPlayers;i++) cfree(players[i].name);
        cfree(players);
        return false;
    }
    return true;
}
void rollToSeeWhoGoesFirst(void) {
    int i,
     rl,
     currentMax;
    boolean over;
    int max_pl;
    again:do {
        putchar('\n');
        for (currentMax = i = 0;i < numberOfPlayers;i++) {
            printf("%s (%d) rolls %d\n", players[i].name, i + 1, rl = roll(2, 6));
            if (rl > currentMax) {
                over = false;
                currentMax = rl;
                max_pl = i;
            }
            else if (rl == currentMax) over++;
        }
        if (over) {
            printf("%d people rolled the same thing, so we'll try again\n", over + 1);
            continue;
        }
    }
    while (false);
    currentPlayerNumber = max_pl;
    currentPlayer = & players[max_pl];
    printf("%s (%d) goes first\n", currentPlayer->name, max_pl + 1);
}
void initializeMonopolies(void) {
    MON * monopoly;
    int i;
    for (monopoly = monopolies;monopoly < & monopolies[NUMBER_OF_MONOPOLIES];monopoly++) {
        monopoly->name = monopoly->lowercaseColor;
        for (i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i] = & board[monopoly->squareNumbers[i]];
    }
}
boolean fixing,
 trading,
 moneyStatusGiven,
 isSpecialCard;
char * playerNames[MAX_PLAYERS + 2],
 * commandList[] = {
    "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     "mortgage",
     "unmortgage",
     "buy houses",
     "sell houses",
     "card",
     "pay",
     "trade",
     "resign",
     "save",
     "restore",
     "roll",
     "",
     0}
,
 * yesNoChoices[] = {
    "yes",
     "no",
     "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     0}
,
 * luckyMessages[] = {
    "You lucky stiff",
     "You got lucky",
     "What a lucky person!",
     "You must have a 4-leaf clover",
     "My, my!  Aren't we lucky!",
     "Luck smiles upon you",
     "You got lucky this time",
     "Lucky person!",
     "Your karma must certainly be together",
     "How beautifully Cosmic",
     "Wow, you must be really with it"}
;
int currentPlayerNumber,
 numberOfPlayers,
 numberOfDoubles,
 luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
void ( * functions[]) ();
( * functions[]) () = {
    quit_confirm,
     printBoard,
     printPlayerLocations,
     printHoldings,
     promptAndPrintHoldings,
     mortgagePrompt,
     unmortgagePrompt,
     buyHouses,
     sellHouses,
     playGetOutOfJailCard,
     payToGetOut,
     trade,
     resign,
     saveGame,
     restoreGame,
     doMove,
     doMove}
;
CardDeck deck[2];
Player * players,
 * currentPlayer;
Property railroads[NUMBER_OF_RAILROADS];
Property util[2];
Monopoly monopolies[NUMBER_OF_MONOPOLIES] = {
    {0, - 1, 2, 0, 1, "Purple", "PURPLE", {1, 3}},
     {0, - 1, 3, 0, 1, "Lt. Blue", "LT. BLUE", {6, 8, 9}},
     {0, - 1, 3, 0, 2, "Violet", "VIOLET", {11, 13, 14}},
     {0, - 1, 3, 0, 2, "Orange", "ORANGE", {16, 18, 19}},
     {0, - 1, 3, 0, 3, "Red", "RED", {21, 23, 24}},
     {0, - 1, 3, 0, 3, "Yellow", "YELLOW", {26, 27, 29}},
     {0, - 1, 3, 0, 4, "Green", "GREEN", {31, 32, 34}},
     {0, - 1, 2, 0, 4, "Dk. Blue", "DK. BLUE", {37, 39}}}
;
Property properties[NUMBER_OF_PROPERTIES] = {
    {0, 0, 1, 0, & mon[0], {2, 10, 30, 90, 160, 250}},
     {0, 0, 3, 0, & mon[0], {4, 20, 60, 180, 320, 450}},
     {0, 0, 6, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 7, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 9, 0, & mon[1], {8, 40, 100, 300, 450, 600}},
     {0, 0, 11, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 13, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 14, 0, & mon[2], {12, 60, 180, 500, 700, 900}},
     {0, 0, 16, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 17, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 19, 0, & mon[3], {16, 80, 220, 600, 800, 1000}},
     {0, 0, 21, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 23, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 24, 0, & mon[4], {20, 100, 300, 750, 925, 1100}},
     {0, 0, 26, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 27, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 29, 0, & mon[5], {24, 120, 360, 850, 1025, 1200}},
     {0, 0, 31, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 32, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 34, 0, & mon[6], {28, 150, 450, 1000, 1200, 1400}},
     {0, 0, 37, 0, & mon[7], {35, 175, 500, 1100, 1300, 1500}},
     {0, 0, 39, 0, & mon[7], {50, 200, 600, 1400, 1700, 2000}}}
;
Square board[NUMBER_OF_SQUARES + 1] = {
    {"=== GO ===", - 1, SAFE, 0},
     {"Mediterranean ave. (P)", - 1, PRPTY, & prop[0], 60},
     {"Community Chest i", - 1, CC},
     {"Baltic ave. (P)", - 1, PRPTY, & prop[1], 60},
     {"Income Tax", - 1, INC_TAX},
     {"Reading RR", - 1, RR, & rr[0], 200},
     {"Oriental ave. (L)", - 1, PRPTY, & prop[2], 100},
     {"Chance i", - 1, CHANCE},
     {"Vermont ave. (L)", - 1, PRPTY, & prop[3], 100},
     {"Connecticut ave. (L)", - 1, PRPTY, & prop[4], 120},
     {"Just Visiting", - 1, SAFE, 0},
     {"St. Charles pl. (V)", - 1, PRPTY, & prop[5], 140},
     {"Electric Co.", - 1, UTIL, & util[0], 150},
     {"States ave. (V)", - 1, PRPTY, & prop[6], 140},
     {"Virginia ave. (V)", - 1, PRPTY, & prop[7], 160},
     {"Pennsylvania RR", - 1, RR, & rr[1], 200},
     {"St. James pl. (O)", - 1, PRPTY, & prop[8], 180},
     {"Community Chest ii", - 1, CC},
     {"Tennessee ave. (O)", - 1, PRPTY, & prop[9], 180},
     {"New York ave. (O)", - 1, PRPTY, & prop[10], 200},
     {"Free Parking", - 1, SAFE, 0},
     {"Kentucky ave. (R)", - 1, PRPTY, & prop[11], 220},
     {"Chance ii", - 1, CHANCE},
     {"Indiana ave. (R)", - 1, PRPTY, & prop[12], 220},
     {"Illinois ave. (R)", - 1, PRPTY, & prop[13], 240},
     {"B&O RR", - 1, RR, & rr[2], 200},
     {"Atlantic ave. (Y)", - 1, PRPTY, & prop[14], 260},
     {"Ventnor ave. (Y)", - 1, PRPTY, & prop[15], 260},
     {"Water Works", - 1, UTIL, & util[1], 150},
     {"Marvin Gardens (Y)", - 1, PRPTY, & prop[16], 280},
     {"GO TO JAIL", - 1, GOTO_J},
     {"Pacific ave. (G)", - 1, PRPTY, & prop[17], 300},
     {"N. Carolina ave. (G)", - 1, PRPTY, & prop[18], 300},
     {"Community Chest iii", - 1, CC},
     {"Pennsylvania ave. (G)", - 1, PRPTY, & prop[19], 320},
     {"Short Line RR", - 1, RR, & rr[3], 200},
     {"Chance iii", - 1, CHANCE},
     {"Park place (D)", - 1, PRPTY, & prop[20], 350},
     {"Luxury Tax", - 1, LUX_TAX},
     {"Boardwalk (D)", - 1, PRPTY, & prop[21], 400},
     {"JAIL", - 1, IN_JAIL}}
;
char copyright[] = "@(#) Copyright (c) 1980 Regents of the University of California.\n" + " All rights reserved.\n";
static char sccsid[] = "@(#)monop.c	5.7 (Berkeley) 6/1/90";
int main(int argc, char * * argv) {
    srand(getpid());
    if (argc > 1) {
        if (!restoreFromFile(argv[1])) restoreGame();
    }
    else {
        getPlayersLoop();
        rollToSeeWhoGoesFirst();
        initializeMonopolies();
    }
    luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
    initializeDecks();
    signal(2, sigquit);
    while (true) {
        printf("\n%s (%d) (cash $%d) on %s\n", currentPlayer->name, currentPlayerNumber + 1, currentPlayer->money, board[currentPlayer->location].name);
        printTurn();
        fixupPrompt();
        execute(getinp("-- Command: ", commandList));
    }
    return 0;
}
void getPlayersLoop(void) {
    while (!getPlayers());
}
boolean getPlayers(void) {
    char * sp;
    int i,
     j;
    char buf[257];
    blew_it:while (true) {
        if ((numberOfPlayers = getInteger("How many players? ")) <= 0 || numberOfPlayers > MAX_PLAYERS) printf("Sorry. Number must range from 1 to 9\n");
        else break;
    }
    currentPlayer = players = (Player * ) calloc(numberOfPlayers, sizeof (Player));
    for (i = 0;i < numberOfPlayers;i++) {
        over:printf("Player %d's name: ", i + 1);
        for (sp = buf;( * sp = getchar()) != '\n';sp++) continue;
        if (sp == buf) {
            i--;
            continue;
        }
         * sp++ = '\0';
        strcpy(playerNames[i] = players[i].name = (char * ) calloc(1, sp - buf) , buf);
        players[i].money = 1500;
    }
    playerNames[i++] = "done";
    playerNames[i] = 0;
    for (i = 0;i < numberOfPlayers;i++) for (j = i + 1;j < numberOfPlayers;j++) if (strcasecmp(playerNames[i], playerNames[j]) == 0) {
        if (i != numberOfPlayers - 1) printf("Hey!!! Some of those are IDENTICAL!!  Let's try that again....\n");
        else printf("\"done\" is a reserved word.  Please try again\n");
        for (i = 0;i < numberOfPlayers;i++) cfree(players[i].name);
        cfree(players);
        return false;
    }
    return true;
}
void rollToSeeWhoGoesFirst(void) {
    int i,
     rl,
     currentMax;
    boolean over;
    int max_pl;
    again:do {
        putchar('\n');
        for (currentMax = i = 0;i < numberOfPlayers;i++) {
            printf("%s (%d) rolls %d\n", players[i].name, i + 1, rl = roll(2, 6));
            if (rl > currentMax) {
                over = false;
                currentMax = rl;
                max_pl = i;
            }
            else if (rl == currentMax) over++;
        }
        if (over) {
            printf("%d people rolled the same thing, so we'll try again\n", over + 1);
            continue;
        }
    }
    while (false);
    currentPlayerNumber = max_pl;
    currentPlayer = & players[max_pl];
    printf("%s (%d) goes first\n", currentPlayer->name, max_pl + 1);
}
void initializeMonopolies(void) {
    Monopoly * monopoly;
    int i;
    for (monopoly = monopolies;monopoly < & monopolies[NUMBER_OF_MONOPOLIES];monopoly++) {
        monopoly->name = monopoly->lowercaseColor;
        for (i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i] = & board[monopoly->squareNumbers[i]];
    }
}
boolean fixing,
 trading,
 moneyStatusGiven,
 isSpecialCard;
char * playerNames[MAX_PLAYERS + 2],
 * commandList[] = {
    "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     "mortgage",
     "unmortgage",
     "buy houses",
     "sell houses",
     "card",
     "pay",
     "trade",
     "resign",
     "save",
     "restore",
     "roll",
     "",
     0}
,
 * yesNoChoices[] = {
    "yes",
     "no",
     "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     0}
,
 * luckyMessages[] = {
    "You lucky stiff",
     "You got lucky",
     "What a lucky person!",
     "You must have a 4-leaf clover",
     "My, my!  Aren't we lucky!",
     "Luck smiles upon you",
     "You got lucky this time",
     "Lucky person!",
     "Your karma must certainly be together",
     "How beautifully Cosmic",
     "Wow, you must be really with it"}
;
int currentPlayerNumber,
 numberOfPlayers,
 numberOfDoubles,
 luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
String[] functions;
( * functions[]) () = {
    quit_confirm,
     printBoard,
     printPlayerLocations,
     printHoldings,
     promptAndPrintHoldings,
     mortgagePrompt,
     unmortgagePrompt,
     buyHouses,
     sellHouses,
     playGetOutOfJailCard,
     payToGetOut,
     trade,
     resign,
     saveGame,
     restoreGame,
     doMove,
     doMove}
;
CardDeck deck[2];
Player * players,
 * currentPlayer;
Property railroads[NUMBER_OF_RAILROADS];
Property util[2];
Monopoly monopolies[NUMBER_OF_MONOPOLIES] = {
    {0, - 1, 2, 0, 1, "Purple", "PURPLE", {1, 3}},
     {0, - 1, 3, 0, 1, "Lt. Blue", "LT. BLUE", {6, 8, 9}},
     {0, - 1, 3, 0, 2, "Violet", "VIOLET", {11, 13, 14}},
     {0, - 1, 3, 0, 2, "Orange", "ORANGE", {16, 18, 19}},
     {0, - 1, 3, 0, 3, "Red", "RED", {21, 23, 24}},
     {0, - 1, 3, 0, 3, "Yellow", "YELLOW", {26, 27, 29}},
     {0, - 1, 3, 0, 4, "Green", "GREEN", {31, 32, 34}},
     {0, - 1, 2, 0, 4, "Dk. Blue", "DK. BLUE", {37, 39}}}
;
Property properties[NUMBER_OF_PROPERTIES] = {
    {0, 0, 1, 0, & mon[0], {2, 10, 30, 90, 160, 250}},
     {0, 0, 3, 0, & mon[0], {4, 20, 60, 180, 320, 450}},
     {0, 0, 6, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 7, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 9, 0, & mon[1], {8, 40, 100, 300, 450, 600}},
     {0, 0, 11, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 13, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 14, 0, & mon[2], {12, 60, 180, 500, 700, 900}},
     {0, 0, 16, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 17, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 19, 0, & mon[3], {16, 80, 220, 600, 800, 1000}},
     {0, 0, 21, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 23, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 24, 0, & mon[4], {20, 100, 300, 750, 925, 1100}},
     {0, 0, 26, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 27, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 29, 0, & mon[5], {24, 120, 360, 850, 1025, 1200}},
     {0, 0, 31, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 32, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 34, 0, & mon[6], {28, 150, 450, 1000, 1200, 1400}},
     {0, 0, 37, 0, & mon[7], {35, 175, 500, 1100, 1300, 1500}},
     {0, 0, 39, 0, & mon[7], {50, 200, 600, 1400, 1700, 2000}}}
;
Square board[NUMBER_OF_SQUARES + 1] = {
    {"=== GO ===", - 1, SAFE, 0},
     {"Mediterranean ave. (P)", - 1, PRPTY, & prop[0], 60},
     {"Community Chest i", - 1, CC},
     {"Baltic ave. (P)", - 1, PRPTY, & prop[1], 60},
     {"Income Tax", - 1, INC_TAX},
     {"Reading RR", - 1, RR, & rr[0], 200},
     {"Oriental ave. (L)", - 1, PRPTY, & prop[2], 100},
     {"Chance i", - 1, CHANCE},
     {"Vermont ave. (L)", - 1, PRPTY, & prop[3], 100},
     {"Connecticut ave. (L)", - 1, PRPTY, & prop[4], 120},
     {"Just Visiting", - 1, SAFE, 0},
     {"St. Charles pl. (V)", - 1, PRPTY, & prop[5], 140},
     {"Electric Co.", - 1, UTIL, & util[0], 150},
     {"States ave. (V)", - 1, PRPTY, & prop[6], 140},
     {"Virginia ave. (V)", - 1, PRPTY, & prop[7], 160},
     {"Pennsylvania RR", - 1, RR, & rr[1], 200},
     {"St. James pl. (O)", - 1, PRPTY, & prop[8], 180},
     {"Community Chest ii", - 1, CC},
     {"Tennessee ave. (O)", - 1, PRPTY, & prop[9], 180},
     {"New York ave. (O)", - 1, PRPTY, & prop[10], 200},
     {"Free Parking", - 1, SAFE, 0},
     {"Kentucky ave. (R)", - 1, PRPTY, & prop[11], 220},
     {"Chance ii", - 1, CHANCE},
     {"Indiana ave. (R)", - 1, PRPTY, & prop[12], 220},
     {"Illinois ave. (R)", - 1, PRPTY, & prop[13], 240},
     {"B&O RR", - 1, RR, & rr[2], 200},
     {"Atlantic ave. (Y)", - 1, PRPTY, & prop[14], 260},
     {"Ventnor ave. (Y)", - 1, PRPTY, & prop[15], 260},
     {"Water Works", - 1, UTIL, & util[1], 150},
     {"Marvin Gardens (Y)", - 1, PRPTY, & prop[16], 280},
     {"GO TO JAIL", - 1, GOTO_J},
     {"Pacific ave. (G)", - 1, PRPTY, & prop[17], 300},
     {"N. Carolina ave. (G)", - 1, PRPTY, & prop[18], 300},
     {"Community Chest iii", - 1, CC},
     {"Pennsylvania ave. (G)", - 1, PRPTY, & prop[19], 320},
     {"Short Line RR", - 1, RR, & rr[3], 200},
     {"Chance iii", - 1, CHANCE},
     {"Park place (D)", - 1, PRPTY, & prop[20], 350},
     {"Luxury Tax", - 1, LUX_TAX},
     {"Boardwalk (D)", - 1, PRPTY, & prop[21], 400},
     {"JAIL", - 1, IN_JAIL}}
;
char copyright[] = "@(#) Copyright (c) 1980 Regents of the University of California.\n" + " All rights reserved.\n";
static char sccsid[] = "@(#)monop.c	5.7 (Berkeley) 6/1/90";
int main(int argc, char * * argv) {
    srand(getpid());
    if (argc > 1) {
        if (!restoreFromFile(argv[1])) restoreGame();
    }
    else {
        getPlayersLoop();
        rollToSeeWhoGoesFirst();
        initializeMonopolies();
    }
    luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
    initializeDecks();
    signal(2, sigquit);
    while (true) {
        printf("\n%s (%d) (cash $%d) on %s\n", currentPlayer->name, currentPlayerNumber + 1, currentPlayer->money, board[currentPlayer->location].name);
        printTurn();
        fixupPrompt();
        execute(getinp("-- Command: ", commandList));
    }
    return 0;
}
void getPlayersLoop(void) {
    while (!getPlayers());
}
boolean getPlayers(void) {
    char * sp;
    int i,
     j;
    char buf[257];
    blew_it:while (true) {
        if ((numberOfPlayers = getInteger("How many players? ")) <= 0 || numberOfPlayers > MAX_PLAYERS) printf("Sorry. Number must range from 1 to 9\n");
        else break;
    }
    currentPlayer = players = (Player * ) calloc(numberOfPlayers, sizeof (Player));
    for (i = 0;i < numberOfPlayers;i++) {
        over:printf("Player %d's name: ", i + 1);
        for (sp = buf;( * sp = getchar()) != '\n';sp++) continue;
        if (sp == buf) {
            i--;
            continue;
        }
         * sp++ = '\0';
        strcpy(playerNames[i] = players[i].name = (char * ) calloc(1, sp - buf) , buf);
        players[i].money = 1500;
    }
    playerNames[i++] = "done";
    playerNames[i] = 0;
    for (i = 0;i < numberOfPlayers;i++) for (j = i + 1;j < numberOfPlayers;j++) if (strcasecmp(playerNames[i], playerNames[j]) == 0) {
        if (i != numberOfPlayers - 1) printf("Hey!!! Some of those are IDENTICAL!!  Let's try that again....\n");
        else printf("\"done\" is a reserved word.  Please try again\n");
        for (i = 0;i < numberOfPlayers;i++) cfree(players[i].name);
        cfree(players);
        return false;
    }
    return true;
}
void rollToSeeWhoGoesFirst(void) {
    int i,
     rl,
     currentMax;
    boolean over;
    int max_pl;
    again:do {
        putchar('\n');
        for (currentMax = i = 0;i < numberOfPlayers;i++) {
            printf("%s (%d) rolls %d\n", players[i].name, i + 1, rl = roll(2, 6));
            if (rl > currentMax) {
                over = false;
                currentMax = rl;
                max_pl = i;
            }
            else if (rl == currentMax) over++;
        }
        if (over) {
            printf("%d people rolled the same thing, so we'll try again\n", over + 1);
            continue;
        }
    }
    while (false);
    currentPlayerNumber = max_pl;
    currentPlayer = & players[max_pl];
    printf("%s (%d) goes first\n", currentPlayer->name, max_pl + 1);
}
void initializeMonopolies(void) {
    Monopoly * monopoly;
    int i;
    for (monopoly = monopolies;monopoly < & monopolies[NUMBER_OF_MONOPOLIES];monopoly++) {
        monopoly->name = monopoly->lowercaseColor;
        for (i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i] = & board[monopoly->squareNumbers[i]];
    }
}
boolean fixing,
 trading,
 moneyStatusGiven,
 isSpecialCard;
char * playerNames[MAX_PLAYERS + 2],
 * commandList[] = {
    "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     "mortgage",
     "unmortgage",
     "buy houses",
     "sell houses",
     "card",
     "pay",
     "trade",
     "resign",
     "save",
     "restore",
     "roll",
     "",
     0}
,
 * yesNoChoices[] = {
    "yes",
     "no",
     "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     0}
,
 * luckyMessages[] = {
    "You lucky stiff",
     "You got lucky",
     "What a lucky person!",
     "You must have a 4-leaf clover",
     "My, my!  Aren't we lucky!",
     "Luck smiles upon you",
     "You got lucky this time",
     "Lucky person!",
     "Your karma must certainly be together",
     "How beautifully Cosmic",
     "Wow, you must be really with it"}
;
int currentPlayerNumber,
 numberOfPlayers,
 numberOfDoubles,
 luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
String[] functions;
functions = {
    "Misc.quit_confirm",
     "Print.printBoard",
     "Print.printPlayerLocations",
     "Misc.printHoldings",
     "Misc.promptAndPrintHoldings",
     "Mortgage.mortgagePrompt",
     "Mortgage.unmortgagePrompt",
     "Houses.buyHouses",
     "Houses.sellHouses",
     "Jail.playGetOutOfJailCard",
     "Jail.payToGetOut",
     "Trade.trade",
     "Trade.resign",
     "Execute.saveGame",
     "Execute.restoreGame",
     "Execute.doMove",
     "Execute.doMove"}
;
CardDeck deck[2];
Player * players,
 * currentPlayer;
Property railroads[NUMBER_OF_RAILROADS];
Property util[2];
Monopoly monopolies[NUMBER_OF_MONOPOLIES] = {
    {0, - 1, 2, 0, 1, "Purple", "PURPLE", {1, 3}},
     {0, - 1, 3, 0, 1, "Lt. Blue", "LT. BLUE", {6, 8, 9}},
     {0, - 1, 3, 0, 2, "Violet", "VIOLET", {11, 13, 14}},
     {0, - 1, 3, 0, 2, "Orange", "ORANGE", {16, 18, 19}},
     {0, - 1, 3, 0, 3, "Red", "RED", {21, 23, 24}},
     {0, - 1, 3, 0, 3, "Yellow", "YELLOW", {26, 27, 29}},
     {0, - 1, 3, 0, 4, "Green", "GREEN", {31, 32, 34}},
     {0, - 1, 2, 0, 4, "Dk. Blue", "DK. BLUE", {37, 39}}}
;
Property properties[NUMBER_OF_PROPERTIES] = {
    {0, 0, 1, 0, & mon[0], {2, 10, 30, 90, 160, 250}},
     {0, 0, 3, 0, & mon[0], {4, 20, 60, 180, 320, 450}},
     {0, 0, 6, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 7, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 9, 0, & mon[1], {8, 40, 100, 300, 450, 600}},
     {0, 0, 11, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 13, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 14, 0, & mon[2], {12, 60, 180, 500, 700, 900}},
     {0, 0, 16, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 17, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 19, 0, & mon[3], {16, 80, 220, 600, 800, 1000}},
     {0, 0, 21, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 23, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 24, 0, & mon[4], {20, 100, 300, 750, 925, 1100}},
     {0, 0, 26, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 27, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 29, 0, & mon[5], {24, 120, 360, 850, 1025, 1200}},
     {0, 0, 31, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 32, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 34, 0, & mon[6], {28, 150, 450, 1000, 1200, 1400}},
     {0, 0, 37, 0, & mon[7], {35, 175, 500, 1100, 1300, 1500}},
     {0, 0, 39, 0, & mon[7], {50, 200, 600, 1400, 1700, 2000}}}
;
Square board[NUMBER_OF_SQUARES + 1] = {
    {"=== GO ===", - 1, SAFE, 0},
     {"Mediterranean ave. (P)", - 1, PRPTY, & prop[0], 60},
     {"Community Chest i", - 1, CC},
     {"Baltic ave. (P)", - 1, PRPTY, & prop[1], 60},
     {"Income Tax", - 1, INC_TAX},
     {"Reading RR", - 1, RR, & rr[0], 200},
     {"Oriental ave. (L)", - 1, PRPTY, & prop[2], 100},
     {"Chance i", - 1, CHANCE},
     {"Vermont ave. (L)", - 1, PRPTY, & prop[3], 100},
     {"Connecticut ave. (L)", - 1, PRPTY, & prop[4], 120},
     {"Just Visiting", - 1, SAFE, 0},
     {"St. Charles pl. (V)", - 1, PRPTY, & prop[5], 140},
     {"Electric Co.", - 1, UTIL, & util[0], 150},
     {"States ave. (V)", - 1, PRPTY, & prop[6], 140},
     {"Virginia ave. (V)", - 1, PRPTY, & prop[7], 160},
     {"Pennsylvania RR", - 1, RR, & rr[1], 200},
     {"St. James pl. (O)", - 1, PRPTY, & prop[8], 180},
     {"Community Chest ii", - 1, CC},
     {"Tennessee ave. (O)", - 1, PRPTY, & prop[9], 180},
     {"New York ave. (O)", - 1, PRPTY, & prop[10], 200},
     {"Free Parking", - 1, SAFE, 0},
     {"Kentucky ave. (R)", - 1, PRPTY, & prop[11], 220},
     {"Chance ii", - 1, CHANCE},
     {"Indiana ave. (R)", - 1, PRPTY, & prop[12], 220},
     {"Illinois ave. (R)", - 1, PRPTY, & prop[13], 240},
     {"B&O RR", - 1, RR, & rr[2], 200},
     {"Atlantic ave. (Y)", - 1, PRPTY, & prop[14], 260},
     {"Ventnor ave. (Y)", - 1, PRPTY, & prop[15], 260},
     {"Water Works", - 1, UTIL, & util[1], 150},
     {"Marvin Gardens (Y)", - 1, PRPTY, & prop[16], 280},
     {"GO TO JAIL", - 1, GOTO_J},
     {"Pacific ave. (G)", - 1, PRPTY, & prop[17], 300},
     {"N. Carolina ave. (G)", - 1, PRPTY, & prop[18], 300},
     {"Community Chest iii", - 1, CC},
     {"Pennsylvania ave. (G)", - 1, PRPTY, & prop[19], 320},
     {"Short Line RR", - 1, RR, & rr[3], 200},
     {"Chance iii", - 1, CHANCE},
     {"Park place (D)", - 1, PRPTY, & prop[20], 350},
     {"Luxury Tax", - 1, LUX_TAX},
     {"Boardwalk (D)", - 1, PRPTY, & prop[21], 400},
     {"JAIL", - 1, IN_JAIL}}
;
char copyright[] = "@(#) Copyright (c) 1980 Regents of the University of California.\n" + " All rights reserved.\n";
static char sccsid[] = "@(#)monop.c	5.7 (Berkeley) 6/1/90";
int main(int argc, char * * argv) {
    srand(getpid());
    if (argc > 1) {
        if (!restoreFromFile(argv[1])) restoreGame();
    }
    else {
        getPlayersLoop();
        rollToSeeWhoGoesFirst();
        initializeMonopolies();
    }
    luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
    initializeDecks();
    signal(2, sigquit);
    while (true) {
        printf("\n%s (%d) (cash $%d) on %s\n", currentPlayer->name, currentPlayerNumber + 1, currentPlayer->money, board[currentPlayer->location].name);
        printTurn();
        fixupPrompt();
        execute(getinp("-- Command: ", commandList));
    }
    return 0;
}
void getPlayersLoop(void) {
    while (!getPlayers());
}
boolean getPlayers(void) {
    char * sp;
    int i,
     j;
    char buf[257];
    blew_it:while (true) {
        if ((numberOfPlayers = getInteger("How many players? ")) <= 0 || numberOfPlayers > MAX_PLAYERS) printf("Sorry. Number must range from 1 to 9\n");
        else break;
    }
    currentPlayer = players = (Player * ) calloc(numberOfPlayers, sizeof (Player));
    for (i = 0;i < numberOfPlayers;i++) {
        over:printf("Player %d's name: ", i + 1);
        for (sp = buf;( * sp = getchar()) != '\n';sp++) continue;
        if (sp == buf) {
            i--;
            continue;
        }
         * sp++ = '\0';
        strcpy(playerNames[i] = players[i].name = (char * ) calloc(1, sp - buf) , buf);
        players[i].money = 1500;
    }
    playerNames[i++] = "done";
    playerNames[i] = 0;
    for (i = 0;i < numberOfPlayers;i++) for (j = i + 1;j < numberOfPlayers;j++) if (strcasecmp(playerNames[i], playerNames[j]) == 0) {
        if (i != numberOfPlayers - 1) printf("Hey!!! Some of those are IDENTICAL!!  Let's try that again....\n");
        else printf("\"done\" is a reserved word.  Please try again\n");
        for (i = 0;i < numberOfPlayers;i++) cfree(players[i].name);
        cfree(players);
        return false;
    }
    return true;
}
void rollToSeeWhoGoesFirst(void) {
    int i,
     rl,
     currentMax;
    boolean over;
    int max_pl;
    again:do {
        putchar('\n');
        for (currentMax = i = 0;i < numberOfPlayers;i++) {
            printf("%s (%d) rolls %d\n", players[i].name, i + 1, rl = roll(2, 6));
            if (rl > currentMax) {
                over = false;
                currentMax = rl;
                max_pl = i;
            }
            else if (rl == currentMax) over++;
        }
        if (over) {
            printf("%d people rolled the same thing, so we'll try again\n", over + 1);
            continue;
        }
    }
    while (false);
    currentPlayerNumber = max_pl;
    currentPlayer = & players[max_pl];
    printf("%s (%d) goes first\n", currentPlayer->name, max_pl + 1);
}
void initializeMonopolies(void) {
    Monopoly * monopoly;
    int i;
    for (monopoly = monopolies;monopoly < & monopolies[NUMBER_OF_MONOPOLIES];monopoly++) {
        monopoly->name = monopoly->lowercaseColor;
        for (i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i] = & board[monopoly->squareNumbers[i]];
    }
}
boolean fixing;
boolean trading;
boolean moneyStatusGiven;
boolean isSpecialCard;
char * playerNames[MAX_PLAYERS + 2];
char * commandList[] = {
    "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     "mortgage",
     "unmortgage",
     "buy houses",
     "sell houses",
     "card",
     "pay",
     "trade",
     "resign",
     "save",
     "restore",
     "roll",
     "",
     0}
;
char * yesNoChoices[] = {
    "yes",
     "no",
     "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     0}
;
char * luckyMessages[] = {
    "You lucky stiff",
     "You got lucky",
     "What a lucky person!",
     "You must have a 4-leaf clover",
     "My, my!  Aren't we lucky!",
     "Luck smiles upon you",
     "You got lucky this time",
     "Lucky person!",
     "Your karma must certainly be together",
     "How beautifully Cosmic",
     "Wow, you must be really with it"}
;
int currentPlayerNumber;
int numberOfPlayers;
int numberOfDoubles;
int luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
String[] functions;
functions = {
    "Misc.quit_confirm",
     "Print.printBoard",
     "Print.printPlayerLocations",
     "Misc.printHoldings",
     "Misc.promptAndPrintHoldings",
     "Mortgage.mortgagePrompt",
     "Mortgage.unmortgagePrompt",
     "Houses.buyHouses",
     "Houses.sellHouses",
     "Jail.playGetOutOfJailCard",
     "Jail.payToGetOut",
     "Trade.trade",
     "Trade.resign",
     "Execute.saveGame",
     "Execute.restoreGame",
     "Execute.doMove",
     "Execute.doMove"}
;
CardDeck deck[2];
Player * players;
Player * currentPlayer;
Property railroads[NUMBER_OF_RAILROADS];
Property util[2];
Monopoly monopolies[NUMBER_OF_MONOPOLIES] = {
    {0, - 1, 2, 0, 1, "Purple", "PURPLE", {1, 3}},
     {0, - 1, 3, 0, 1, "Lt. Blue", "LT. BLUE", {6, 8, 9}},
     {0, - 1, 3, 0, 2, "Violet", "VIOLET", {11, 13, 14}},
     {0, - 1, 3, 0, 2, "Orange", "ORANGE", {16, 18, 19}},
     {0, - 1, 3, 0, 3, "Red", "RED", {21, 23, 24}},
     {0, - 1, 3, 0, 3, "Yellow", "YELLOW", {26, 27, 29}},
     {0, - 1, 3, 0, 4, "Green", "GREEN", {31, 32, 34}},
     {0, - 1, 2, 0, 4, "Dk. Blue", "DK. BLUE", {37, 39}}}
;
Property properties[NUMBER_OF_PROPERTIES] = {
    {0, 0, 1, 0, & mon[0], {2, 10, 30, 90, 160, 250}},
     {0, 0, 3, 0, & mon[0], {4, 20, 60, 180, 320, 450}},
     {0, 0, 6, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 7, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 9, 0, & mon[1], {8, 40, 100, 300, 450, 600}},
     {0, 0, 11, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 13, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 14, 0, & mon[2], {12, 60, 180, 500, 700, 900}},
     {0, 0, 16, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 17, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 19, 0, & mon[3], {16, 80, 220, 600, 800, 1000}},
     {0, 0, 21, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 23, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 24, 0, & mon[4], {20, 100, 300, 750, 925, 1100}},
     {0, 0, 26, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 27, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 29, 0, & mon[5], {24, 120, 360, 850, 1025, 1200}},
     {0, 0, 31, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 32, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 34, 0, & mon[6], {28, 150, 450, 1000, 1200, 1400}},
     {0, 0, 37, 0, & mon[7], {35, 175, 500, 1100, 1300, 1500}},
     {0, 0, 39, 0, & mon[7], {50, 200, 600, 1400, 1700, 2000}}}
;
Square board[NUMBER_OF_SQUARES + 1] = {
    {"=== GO ===", - 1, SAFE, 0},
     {"Mediterranean ave. (P)", - 1, PRPTY, & prop[0], 60},
     {"Community Chest i", - 1, CC},
     {"Baltic ave. (P)", - 1, PRPTY, & prop[1], 60},
     {"Income Tax", - 1, INC_TAX},
     {"Reading RR", - 1, RR, & rr[0], 200},
     {"Oriental ave. (L)", - 1, PRPTY, & prop[2], 100},
     {"Chance i", - 1, CHANCE},
     {"Vermont ave. (L)", - 1, PRPTY, & prop[3], 100},
     {"Connecticut ave. (L)", - 1, PRPTY, & prop[4], 120},
     {"Just Visiting", - 1, SAFE, 0},
     {"St. Charles pl. (V)", - 1, PRPTY, & prop[5], 140},
     {"Electric Co.", - 1, UTIL, & util[0], 150},
     {"States ave. (V)", - 1, PRPTY, & prop[6], 140},
     {"Virginia ave. (V)", - 1, PRPTY, & prop[7], 160},
     {"Pennsylvania RR", - 1, RR, & rr[1], 200},
     {"St. James pl. (O)", - 1, PRPTY, & prop[8], 180},
     {"Community Chest ii", - 1, CC},
     {"Tennessee ave. (O)", - 1, PRPTY, & prop[9], 180},
     {"New York ave. (O)", - 1, PRPTY, & prop[10], 200},
     {"Free Parking", - 1, SAFE, 0},
     {"Kentucky ave. (R)", - 1, PRPTY, & prop[11], 220},
     {"Chance ii", - 1, CHANCE},
     {"Indiana ave. (R)", - 1, PRPTY, & prop[12], 220},
     {"Illinois ave. (R)", - 1, PRPTY, & prop[13], 240},
     {"B&O RR", - 1, RR, & rr[2], 200},
     {"Atlantic ave. (Y)", - 1, PRPTY, & prop[14], 260},
     {"Ventnor ave. (Y)", - 1, PRPTY, & prop[15], 260},
     {"Water Works", - 1, UTIL, & util[1], 150},
     {"Marvin Gardens (Y)", - 1, PRPTY, & prop[16], 280},
     {"GO TO JAIL", - 1, GOTO_J},
     {"Pacific ave. (G)", - 1, PRPTY, & prop[17], 300},
     {"N. Carolina ave. (G)", - 1, PRPTY, & prop[18], 300},
     {"Community Chest iii", - 1, CC},
     {"Pennsylvania ave. (G)", - 1, PRPTY, & prop[19], 320},
     {"Short Line RR", - 1, RR, & rr[3], 200},
     {"Chance iii", - 1, CHANCE},
     {"Park place (D)", - 1, PRPTY, & prop[20], 350},
     {"Luxury Tax", - 1, LUX_TAX},
     {"Boardwalk (D)", - 1, PRPTY, & prop[21], 400},
     {"JAIL", - 1, IN_JAIL}}
;
char copyright[] = "@(#) Copyright (c) 1980 Regents of the University of California.\n" + " All rights reserved.\n";
static char sccsid[] = "@(#)monop.c	5.7 (Berkeley) 6/1/90";
int main(int argc, char * * argv) {
    srand(getpid());
    if (argc > 1) {
        if (!restoreFromFile(argv[1])) restoreGame();
    }
    else {
        getPlayersLoop();
        rollToSeeWhoGoesFirst();
        initializeMonopolies();
    }
    luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
    initializeDecks();
    signal(2, sigquit);
    while (true) {
        printf("\n%s (%d) (cash $%d) on %s\n", currentPlayer->name, currentPlayerNumber + 1, currentPlayer->money, board[currentPlayer->location].name);
        printTurn();
        fixupPrompt();
        execute(getinp("-- Command: ", commandList));
    }
    return 0;
}
void getPlayersLoop(void) {
    while (!getPlayers());
}
boolean getPlayers(void) {
    char * sp;
    int i;
    int j;
    char buf[257];
    blew_it:while (true) {
        if ((numberOfPlayers = getInteger("How many players? ")) <= 0 || numberOfPlayers > MAX_PLAYERS) printf("Sorry. Number must range from 1 to 9\n");
        else break;
    }
    currentPlayer = players = (Player * ) calloc(numberOfPlayers, sizeof (Player));
    for (i = 0;i < numberOfPlayers;i++) {
        over:printf("Player %d's name: ", i + 1);
        for (sp = buf;( * sp = getchar()) != '\n';sp++) continue;
        if (sp == buf) {
            i--;
            continue;
        }
         * sp++ = '\0';
        strcpy(playerNames[i] = players[i].name = (char * ) calloc(1, sp - buf) , buf);
        players[i].money = 1500;
    }
    playerNames[i++] = "done";
    playerNames[i] = 0;
    for (i = 0;i < numberOfPlayers;i++) for (j = i + 1;j < numberOfPlayers;j++) if (strcasecmp(playerNames[i], playerNames[j]) == 0) {
        if (i != numberOfPlayers - 1) printf("Hey!!! Some of those are IDENTICAL!!  Let's try that again....\n");
        else printf("\"done\" is a reserved word.  Please try again\n");
        for (i = 0;i < numberOfPlayers;i++) cfree(players[i].name);
        cfree(players);
        return false;
    }
    return true;
}
void rollToSeeWhoGoesFirst(void) {
    int i;
    int rl;
    int currentMax;
    boolean over;
    int max_pl;
    again:do {
        putchar('\n');
        for (currentMax = i = 0;i < numberOfPlayers;i++) {
            printf("%s (%d) rolls %d\n", players[i].name, i + 1, rl = roll(2, 6));
            if (rl > currentMax) {
                over = false;
                currentMax = rl;
                max_pl = i;
            }
            else if (rl == currentMax) over++;
        }
        if (over) {
            printf("%d people rolled the same thing, so we'll try again\n", over + 1);
            continue;
        }
    }
    while (false);
    currentPlayerNumber = max_pl;
    currentPlayer = & players[max_pl];
    printf("%s (%d) goes first\n", currentPlayer->name, max_pl + 1);
}
void initializeMonopolies(void) {
    Monopoly * monopoly;
    int i;
    for (monopoly = monopolies;monopoly < & monopolies[NUMBER_OF_MONOPOLIES];monopoly++) {
        monopoly->name = monopoly->lowercaseColor;
        for (i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i] = & board[monopoly->squareNumbers[i]];
    }
}
boolean fixing;
boolean trading;
boolean moneyStatusGiven;
boolean isSpecialCard;
char * playerNames[MAX_PLAYERS + 2];
char * commandList[] = {
    "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     "mortgage",
     "unmortgage",
     "buy houses",
     "sell houses",
     "card",
     "pay",
     "trade",
     "resign",
     "save",
     "restore",
     "roll",
     "",
     0}
;
char * yesNoChoices[] = {
    "yes",
     "no",
     "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     0}
;
char * luckyMessages[] = {
    "You lucky stiff",
     "You got lucky",
     "What a lucky person!",
     "You must have a 4-leaf clover",
     "My, my!  Aren't we lucky!",
     "Luck smiles upon you",
     "You got lucky this time",
     "Lucky person!",
     "Your karma must certainly be together",
     "How beautifully Cosmic",
     "Wow, you must be really with it"}
;
int currentPlayerNumber;
int numberOfPlayers;
int numberOfDoubles;
int luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
String[] functions;
functions = {
    "Misc.quit_confirm",
     "Print.printBoard",
     "Print.printPlayerLocations",
     "Misc.printHoldings",
     "Misc.promptAndPrintHoldings",
     "Mortgage.mortgagePrompt",
     "Mortgage.unmortgagePrompt",
     "Houses.buyHouses",
     "Houses.sellHouses",
     "Jail.playGetOutOfJailCard",
     "Jail.payToGetOut",
     "Trade.trade",
     "Trade.resign",
     "Execute.saveGame",
     "Execute.restoreGame",
     "Execute.doMove",
     "Execute.doMove"}
;
CardDeck deck[2];
Player * players;
Player * currentPlayer;
Property railroads[NUMBER_OF_RAILROADS];
Property util[2];
Monopoly monopolies[NUMBER_OF_MONOPOLIES] = {
    {0, - 1, 2, 0, 1, "Purple", "PURPLE", {1, 3}},
     {0, - 1, 3, 0, 1, "Lt. Blue", "LT. BLUE", {6, 8, 9}},
     {0, - 1, 3, 0, 2, "Violet", "VIOLET", {11, 13, 14}},
     {0, - 1, 3, 0, 2, "Orange", "ORANGE", {16, 18, 19}},
     {0, - 1, 3, 0, 3, "Red", "RED", {21, 23, 24}},
     {0, - 1, 3, 0, 3, "Yellow", "YELLOW", {26, 27, 29}},
     {0, - 1, 3, 0, 4, "Green", "GREEN", {31, 32, 34}},
     {0, - 1, 2, 0, 4, "Dk. Blue", "DK. BLUE", {37, 39}}}
;
Property properties[NUMBER_OF_PROPERTIES] = {
    {0, 0, 1, 0, & mon[0], {2, 10, 30, 90, 160, 250}},
     {0, 0, 3, 0, & mon[0], {4, 20, 60, 180, 320, 450}},
     {0, 0, 6, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 7, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 9, 0, & mon[1], {8, 40, 100, 300, 450, 600}},
     {0, 0, 11, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 13, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 14, 0, & mon[2], {12, 60, 180, 500, 700, 900}},
     {0, 0, 16, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 17, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 19, 0, & mon[3], {16, 80, 220, 600, 800, 1000}},
     {0, 0, 21, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 23, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 24, 0, & mon[4], {20, 100, 300, 750, 925, 1100}},
     {0, 0, 26, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 27, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 29, 0, & mon[5], {24, 120, 360, 850, 1025, 1200}},
     {0, 0, 31, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 32, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 34, 0, & mon[6], {28, 150, 450, 1000, 1200, 1400}},
     {0, 0, 37, 0, & mon[7], {35, 175, 500, 1100, 1300, 1500}},
     {0, 0, 39, 0, & mon[7], {50, 200, 600, 1400, 1700, 2000}}}
;
Square board[NUMBER_OF_SQUARES + 1] = {
    {"=== GO ===", - 1, SAFE, 0},
     {"Mediterranean ave. (P)", - 1, PRPTY, & prop[0], 60},
     {"Community Chest i", - 1, CC},
     {"Baltic ave. (P)", - 1, PRPTY, & prop[1], 60},
     {"Income Tax", - 1, INC_TAX},
     {"Reading RR", - 1, RR, & rr[0], 200},
     {"Oriental ave. (L)", - 1, PRPTY, & prop[2], 100},
     {"Chance i", - 1, CHANCE},
     {"Vermont ave. (L)", - 1, PRPTY, & prop[3], 100},
     {"Connecticut ave. (L)", - 1, PRPTY, & prop[4], 120},
     {"Just Visiting", - 1, SAFE, 0},
     {"St. Charles pl. (V)", - 1, PRPTY, & prop[5], 140},
     {"Electric Co.", - 1, UTIL, & util[0], 150},
     {"States ave. (V)", - 1, PRPTY, & prop[6], 140},
     {"Virginia ave. (V)", - 1, PRPTY, & prop[7], 160},
     {"Pennsylvania RR", - 1, RR, & rr[1], 200},
     {"St. James pl. (O)", - 1, PRPTY, & prop[8], 180},
     {"Community Chest ii", - 1, CC},
     {"Tennessee ave. (O)", - 1, PRPTY, & prop[9], 180},
     {"New York ave. (O)", - 1, PRPTY, & prop[10], 200},
     {"Free Parking", - 1, SAFE, 0},
     {"Kentucky ave. (R)", - 1, PRPTY, & prop[11], 220},
     {"Chance ii", - 1, CHANCE},
     {"Indiana ave. (R)", - 1, PRPTY, & prop[12], 220},
     {"Illinois ave. (R)", - 1, PRPTY, & prop[13], 240},
     {"B&O RR", - 1, RR, & rr[2], 200},
     {"Atlantic ave. (Y)", - 1, PRPTY, & prop[14], 260},
     {"Ventnor ave. (Y)", - 1, PRPTY, & prop[15], 260},
     {"Water Works", - 1, UTIL, & util[1], 150},
     {"Marvin Gardens (Y)", - 1, PRPTY, & prop[16], 280},
     {"GO TO JAIL", - 1, GOTO_J},
     {"Pacific ave. (G)", - 1, PRPTY, & prop[17], 300},
     {"N. Carolina ave. (G)", - 1, PRPTY, & prop[18], 300},
     {"Community Chest iii", - 1, CC},
     {"Pennsylvania ave. (G)", - 1, PRPTY, & prop[19], 320},
     {"Short Line RR", - 1, RR, & rr[3], 200},
     {"Chance iii", - 1, CHANCE},
     {"Park place (D)", - 1, PRPTY, & prop[20], 350},
     {"Luxury Tax", - 1, LUX_TAX},
     {"Boardwalk (D)", - 1, PRPTY, & prop[21], 400},
     {"JAIL", - 1, IN_JAIL}}
;
char copyright[] = "@(#) Copyright (c) 1980 Regents of the University of California.\n" + " All rights reserved.\n";
static char sccsid[] = "@(#)monop.c	5.7 (Berkeley) 6/1/90";
int main(int argc, char * * argv) {
    srand(getpid());
    if (argc > 1) {
        if (!restoreFromFile(argv[1])) restoreGame();
    }
    else {
        getPlayersLoop();
        rollToSeeWhoGoesFirst();
        initializeMonopolies();
    }
    luckyMessagesCount = sizeof luckyMessages / sizeof (char * );
    initializeDecks();
    signal(2, sigquit);
    while (true) {
        printf("\n%s (%d) (cash $%d) on %s\n", currentPlayer->name, currentPlayerNumber + 1, currentPlayer->money, board[currentPlayer->location].name);
        printTurn();
        fixupPrompt();
        execute(getinp("-- Command: ", commandList));
    }
    return 0;
}
void getPlayersLoop(void) {
    while (!getPlayers());
}
boolean getPlayers(void) {
    char * sp;
    int i;
    int j;
    char buf[257];
    blew_it:while (true) {
        if ((numberOfPlayers = getInteger("How many players? ")) <= 0 || numberOfPlayers > MAX_PLAYERS) printf("Sorry. Number must range from 1 to 9\n");
        else break;
    }
    currentPlayer = players = (player * ) calloc(numberOfPlayers, sizeof (player));
    for (i = 0;i < numberOfPlayers;i++) {
        over:printf("Player %d's name: ", i + 1);
        for (sp = buf;( * sp = getchar()) != '\n';sp++) continue;
        if (sp == buf) {
            i--;
            continue;
        }
         * sp++ = '\0';
        strcpy(playerNames[i] = players[i].name = (char * ) calloc(1, sp - buf) , buf);
        players[i].money = 1500;
    }
    playerNames[i++] = "done";
    playerNames[i] = 0;
    for (i = 0;i < numberOfPlayers;i++) for (j = i + 1;j < numberOfPlayers;j++) if (strcasecmp(playerNames[i], playerNames[j]) == 0) {
        if (i != numberOfPlayers - 1) printf("Hey!!! Some of those are IDENTICAL!!  Let's try that again....\n");
        else printf("\"done\" is a reserved word.  Please try again\n");
        for (i = 0;i < numberOfPlayers;i++) cfree(players[i].name);
        cfree(players);
        return false;
    }
    return true;
}
void rollToSeeWhoGoesFirst(void) {
    int i;
    int rl;
    int currentMax;
    boolean over;
    int max_pl;
    again:do {
        putchar('\n');
        for (currentMax = i = 0;i < numberOfPlayers;i++) {
            printf("%s (%d) rolls %d\n", players[i].name, i + 1, rl = roll(2, 6));
            if (rl > currentMax) {
                over = false;
                currentMax = rl;
                max_pl = i;
            }
            else if (rl == currentMax) over++;
        }
        if (over) {
            printf("%d people rolled the same thing, so we'll try again\n", over + 1);
            continue;
        }
    }
    while (false);
    currentPlayerNumber = max_pl;
    currentPlayer = & players[max_pl];
    printf("%s (%d) goes first\n", currentPlayer->name, max_pl + 1);
}
void initializeMonopolies(void) {
    Monopoly * monopoly;
    int i;
    for (monopoly = monopolies;monopoly < & monopolies[NUMBER_OF_MONOPOLIES];monopoly++) {
        monopoly->name = monopoly->lowercaseColor;
        for (i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i] = & board[monopoly->squareNumbers[i]];
    }
}
boolean fixing;
boolean trading;
boolean moneyStatusGiven;
boolean isSpecialCard;
char * playerNames[MAX_PLAYERS + 2];
char * commandList[] = {
    "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     "mortgage",
     "unmortgage",
     "buy houses",
     "sell houses",
     "card",
     "pay",
     "trade",
     "resign",
     "save",
     "restore",
     "roll",
     "",
     0}
;
char * yesNoChoices[] = {
    "yes",
     "no",
     "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     0}
;
char * luckyMessages[] = {
    "You lucky stiff",
     "You got lucky",
     "What a lucky person!",
     "You must have a 4-leaf clover",
     "My, my!  Aren't we lucky!",
     "Luck smiles upon you",
     "You got lucky this time",
     "Lucky person!",
     "Your karma must certainly be together",
     "How beautifully Cosmic",
     "Wow, you must be really with it"}
;
int currentPlayerNumber;
int numberOfPlayers;
int numberOfDoubles;
int luckyMessagesCount = sizeof () / sizeof ();
String[] functions;
functions = {
    "Misc.quit_confirm",
     "Print.printBoard",
     "Print.printPlayerLocations",
     "Misc.printHoldings",
     "Misc.promptAndPrintHoldings",
     "Mortgage.mortgagePrompt",
     "Mortgage.unmortgagePrompt",
     "Houses.buyHouses",
     "Houses.sellHouses",
     "Jail.playGetOutOfJailCard",
     "Jail.payToGetOut",
     "Trade.trade",
     "Trade.resign",
     "Execute.saveGame",
     "Execute.restoreGame",
     "Execute.doMove",
     "Execute.doMove"}
;
CardDeck deck[2];
Player * players;
Player * currentPlayer;
Property railroads[NUMBER_OF_RAILROADS];
Property util[2];
Monopoly monopolies[NUMBER_OF_MONOPOLIES] = {
    {0, - 1, 2, 0, 1, "Purple", "PURPLE", {1, 3}},
     {0, - 1, 3, 0, 1, "Lt. Blue", "LT. BLUE", {6, 8, 9}},
     {0, - 1, 3, 0, 2, "Violet", "VIOLET", {11, 13, 14}},
     {0, - 1, 3, 0, 2, "Orange", "ORANGE", {16, 18, 19}},
     {0, - 1, 3, 0, 3, "Red", "RED", {21, 23, 24}},
     {0, - 1, 3, 0, 3, "Yellow", "YELLOW", {26, 27, 29}},
     {0, - 1, 3, 0, 4, "Green", "GREEN", {31, 32, 34}},
     {0, - 1, 2, 0, 4, "Dk. Blue", "DK. BLUE", {37, 39}}}
;
Property properties[NUMBER_OF_PROPERTIES] = {
    {0, 0, 1, 0, & mon[0], {2, 10, 30, 90, 160, 250}},
     {0, 0, 3, 0, & mon[0], {4, 20, 60, 180, 320, 450}},
     {0, 0, 6, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 7, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 9, 0, & mon[1], {8, 40, 100, 300, 450, 600}},
     {0, 0, 11, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 13, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 14, 0, & mon[2], {12, 60, 180, 500, 700, 900}},
     {0, 0, 16, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 17, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 19, 0, & mon[3], {16, 80, 220, 600, 800, 1000}},
     {0, 0, 21, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 23, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 24, 0, & mon[4], {20, 100, 300, 750, 925, 1100}},
     {0, 0, 26, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 27, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 29, 0, & mon[5], {24, 120, 360, 850, 1025, 1200}},
     {0, 0, 31, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 32, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 34, 0, & mon[6], {28, 150, 450, 1000, 1200, 1400}},
     {0, 0, 37, 0, & mon[7], {35, 175, 500, 1100, 1300, 1500}},
     {0, 0, 39, 0, & mon[7], {50, 200, 600, 1400, 1700, 2000}}}
;
Square board[NUMBER_OF_SQUARES + 1] = {
    {"=== GO ===", - 1, SAFE, 0},
     {"Mediterranean ave. (P)", - 1, PRPTY, & prop[0], 60},
     {"Community Chest i", - 1, CC},
     {"Baltic ave. (P)", - 1, PRPTY, & prop[1], 60},
     {"Income Tax", - 1, INC_TAX},
     {"Reading RR", - 1, RR, & rr[0], 200},
     {"Oriental ave. (L)", - 1, PRPTY, & prop[2], 100},
     {"Chance i", - 1, CHANCE},
     {"Vermont ave. (L)", - 1, PRPTY, & prop[3], 100},
     {"Connecticut ave. (L)", - 1, PRPTY, & prop[4], 120},
     {"Just Visiting", - 1, SAFE, 0},
     {"St. Charles pl. (V)", - 1, PRPTY, & prop[5], 140},
     {"Electric Co.", - 1, UTIL, & util[0], 150},
     {"States ave. (V)", - 1, PRPTY, & prop[6], 140},
     {"Virginia ave. (V)", - 1, PRPTY, & prop[7], 160},
     {"Pennsylvania RR", - 1, RR, & rr[1], 200},
     {"St. James pl. (O)", - 1, PRPTY, & prop[8], 180},
     {"Community Chest ii", - 1, CC},
     {"Tennessee ave. (O)", - 1, PRPTY, & prop[9], 180},
     {"New York ave. (O)", - 1, PRPTY, & prop[10], 200},
     {"Free Parking", - 1, SAFE, 0},
     {"Kentucky ave. (R)", - 1, PRPTY, & prop[11], 220},
     {"Chance ii", - 1, CHANCE},
     {"Indiana ave. (R)", - 1, PRPTY, & prop[12], 220},
     {"Illinois ave. (R)", - 1, PRPTY, & prop[13], 240},
     {"B&O RR", - 1, RR, & rr[2], 200},
     {"Atlantic ave. (Y)", - 1, PRPTY, & prop[14], 260},
     {"Ventnor ave. (Y)", - 1, PRPTY, & prop[15], 260},
     {"Water Works", - 1, UTIL, & util[1], 150},
     {"Marvin Gardens (Y)", - 1, PRPTY, & prop[16], 280},
     {"GO TO JAIL", - 1, GOTO_J},
     {"Pacific ave. (G)", - 1, PRPTY, & prop[17], 300},
     {"N. Carolina ave. (G)", - 1, PRPTY, & prop[18], 300},
     {"Community Chest iii", - 1, CC},
     {"Pennsylvania ave. (G)", - 1, PRPTY, & prop[19], 320},
     {"Short Line RR", - 1, RR, & rr[3], 200},
     {"Chance iii", - 1, CHANCE},
     {"Park place (D)", - 1, PRPTY, & prop[20], 350},
     {"Luxury Tax", - 1, LUX_TAX},
     {"Boardwalk (D)", - 1, PRPTY, & prop[21], 400},
     {"JAIL", - 1, IN_JAIL}}
;
char copyright[] = "@(#) Copyright (c) 1980 Regents of the University of California.\n" + " All rights reserved.\n";
static char sccsid[] = "@(#)monop.c	5.7 (Berkeley) 6/1/90";
int main(int argc, char * * argv) {
    srand(getpid());
    if (argc > 1) {
        if (!restoreFromFile(argv[1])) restoreGame();
    }
    else {
        getPlayersLoop();
        rollToSeeWhoGoesFirst();
        initializeMonopolies();
    }
    luckyMessagesCount = sizeof () / sizeof ();
    initializeDecks();
    signal(2, sigquit);
    while (true) {
        printf("\n%s (%d) (cash $%d) on %s\n", currentPlayer->name, currentPlayerNumber + 1, currentPlayer->money, board[currentPlayer->location].name);
        printTurn();
        fixupPrompt();
        execute(getinp("-- Command: ", commandList));
    }
    return 0;
}
void getPlayersLoop(void) {
    while (!getPlayers());
}
boolean getPlayers(void) {
    char * sp;
    int i;
    int j;
    char buf[257];
    blew_it:while (true) {
        if ((numberOfPlayers = getInteger("How many players? ")) <= 0 || numberOfPlayers > MAX_PLAYERS) printf("Sorry. Number must range from 1 to 9\n");
        else break;
    }
    currentPlayer = players = (player * ) calloc(numberOfPlayers, sizeof ());
    for (i = 0;i < numberOfPlayers;i++) {
        over:printf("Player %d's name: ", i + 1);
        for (sp = buf;( * sp = getchar()) != '\n';sp++) continue;
        if (sp == buf) {
            i--;
            continue;
        }
         * sp++ = '\0';
        strcpy(playerNames[i] = players[i].name = (char * ) calloc(1, sp - buf) , buf);
        players[i].money = 1500;
    }
    playerNames[i++] = "done";
    playerNames[i] = 0;
    for (i = 0;i < numberOfPlayers;i++) for (j = i + 1;j < numberOfPlayers;j++) if (strcasecmp(playerNames[i], playerNames[j]) == 0) {
        if (i != numberOfPlayers - 1) printf("Hey!!! Some of those are IDENTICAL!!  Let's try that again....\n");
        else printf("\"done\" is a reserved word.  Please try again\n");
        for (i = 0;i < numberOfPlayers;i++) cfree(players[i].name);
        cfree(players);
        return false;
    }
    return true;
}
void rollToSeeWhoGoesFirst(void) {
    int i;
    int rl;
    int currentMax;
    boolean over;
    int max_pl;
    again:do {
        putchar('\n');
        for (currentMax = i = 0;i < numberOfPlayers;i++) {
            printf("%s (%d) rolls %d\n", players[i].name, i + 1, rl = roll(2, 6));
            if (rl > currentMax) {
                over = false;
                currentMax = rl;
                max_pl = i;
            }
            else if (rl == currentMax) over++;
        }
        if (over) {
            printf("%d people rolled the same thing, so we'll try again\n", over + 1);
            continue;
        }
    }
    while (false);
    currentPlayerNumber = max_pl;
    currentPlayer = & players[max_pl];
    printf("%s (%d) goes first\n", currentPlayer->name, max_pl + 1);
}
void initializeMonopolies(void) {
    Monopoly * monopoly;
    int i;
    for (monopoly = monopolies;monopoly < & monopolies[NUMBER_OF_MONOPOLIES];monopoly++) {
        monopoly->name = monopoly->lowercaseColor;
        for (i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i] = & board[monopoly->squareNumbers[i]];
    }
}
boolean fixing;
boolean trading;
boolean moneyStatusGiven;
boolean isSpecialCard;
String[MAX_PLAYERS + 2] playerNames;
String[] commandList = {
    "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     "mortgage",
     "unmortgage",
     "buy houses",
     "sell houses",
     "card",
     "pay",
     "trade",
     "resign",
     "save",
     "restore",
     "roll",
     "",
     0}
;
String[] yesNoChoices = {
    "yes",
     "no",
     "quit",
     "print",
     "where",
     "own holdings",
     "holdings",
     0}
;
String[] luckyMessages = {
    "You lucky stiff",
     "You got lucky",
     "What a lucky person!",
     "You must have a 4-leaf clover",
     "My, my!  Aren't we lucky!",
     "Luck smiles upon you",
     "You got lucky this time",
     "Lucky person!",
     "Your karma must certainly be together",
     "How beautifully Cosmic",
     "Wow, you must be really with it"}
;
int currentPlayerNumber;
int numberOfPlayers;
int numberOfDoubles;
int luckyMessagesCount = sizeof () / sizeof ();
String[] functions;
functions = {
    "Misc.quit_confirm",
     "Print.printBoard",
     "Print.printPlayerLocations",
     "Misc.printHoldings",
     "Misc.promptAndPrintHoldings",
     "Mortgage.mortgagePrompt",
     "Mortgage.unmortgagePrompt",
     "Houses.buyHouses",
     "Houses.sellHouses",
     "Jail.playGetOutOfJailCard",
     "Jail.payToGetOut",
     "Trade.trade",
     "Trade.resign",
     "Execute.saveGame",
     "Execute.restoreGame",
     "Execute.doMove",
     "Execute.doMove"}
;
CardDeck[2] deck;
Player * players;
Player * currentPlayer;
Property[NUMBER_OF_RAILROADS] railroads;
Property[2] util;
Monopoly[NUMBER_OF_MONOPOLIES] monopolies = {
    {0, - 1, 2, 0, 1, "Purple", "PURPLE", {1, 3}},
     {0, - 1, 3, 0, 1, "Lt. Blue", "LT. BLUE", {6, 8, 9}},
     {0, - 1, 3, 0, 2, "Violet", "VIOLET", {11, 13, 14}},
     {0, - 1, 3, 0, 2, "Orange", "ORANGE", {16, 18, 19}},
     {0, - 1, 3, 0, 3, "Red", "RED", {21, 23, 24}},
     {0, - 1, 3, 0, 3, "Yellow", "YELLOW", {26, 27, 29}},
     {0, - 1, 3, 0, 4, "Green", "GREEN", {31, 32, 34}},
     {0, - 1, 2, 0, 4, "Dk. Blue", "DK. BLUE", {37, 39}}}
;
Property[NUMBER_OF_PROPERTIES] properties = {
    {0, 0, 1, 0, & mon[0], {2, 10, 30, 90, 160, 250}},
     {0, 0, 3, 0, & mon[0], {4, 20, 60, 180, 320, 450}},
     {0, 0, 6, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 7, 0, & mon[1], {6, 30, 90, 270, 400, 550}},
     {0, 0, 9, 0, & mon[1], {8, 40, 100, 300, 450, 600}},
     {0, 0, 11, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 13, 0, & mon[2], {10, 50, 150, 450, 625, 750}},
     {0, 0, 14, 0, & mon[2], {12, 60, 180, 500, 700, 900}},
     {0, 0, 16, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 17, 0, & mon[3], {14, 70, 200, 550, 750, 950}},
     {0, 0, 19, 0, & mon[3], {16, 80, 220, 600, 800, 1000}},
     {0, 0, 21, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 23, 0, & mon[4], {18, 90, 250, 700, 875, 1050}},
     {0, 0, 24, 0, & mon[4], {20, 100, 300, 750, 925, 1100}},
     {0, 0, 26, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 27, 0, & mon[5], {22, 110, 330, 800, 975, 1150}},
     {0, 0, 29, 0, & mon[5], {24, 120, 360, 850, 1025, 1200}},
     {0, 0, 31, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 32, 0, & mon[6], {26, 130, 390, 900, 1100, 1275}},
     {0, 0, 34, 0, & mon[6], {28, 150, 450, 1000, 1200, 1400}},
     {0, 0, 37, 0, & mon[7], {35, 175, 500, 1100, 1300, 1500}},
     {0, 0, 39, 0, & mon[7], {50, 200, 600, 1400, 1700, 2000}}}
;
Square[NUMBER_OF_SQUARES + 1] board = {
    {"=== GO ===", - 1, SAFE, 0},
     {"Mediterranean ave. (P)", - 1, PRPTY, & prop[0], 60},
     {"Community Chest i", - 1, CC},
     {"Baltic ave. (P)", - 1, PRPTY, & prop[1], 60},
     {"Income Tax", - 1, INC_TAX},
     {"Reading RR", - 1, RR, & rr[0], 200},
     {"Oriental ave. (L)", - 1, PRPTY, & prop[2], 100},
     {"Chance i", - 1, CHANCE},
     {"Vermont ave. (L)", - 1, PRPTY, & prop[3], 100},
     {"Connecticut ave. (L)", - 1, PRPTY, & prop[4], 120},
     {"Just Visiting", - 1, SAFE, 0},
     {"St. Charles pl. (V)", - 1, PRPTY, & prop[5], 140},
     {"Electric Co.", - 1, UTIL, & util[0], 150},
     {"States ave. (V)", - 1, PRPTY, & prop[6], 140},
     {"Virginia ave. (V)", - 1, PRPTY, & prop[7], 160},
     {"Pennsylvania RR", - 1, RR, & rr[1], 200},
     {"St. James pl. (O)", - 1, PRPTY, & prop[8], 180},
     {"Community Chest ii", - 1, CC},
     {"Tennessee ave. (O)", - 1, PRPTY, & prop[9], 180},
     {"New York ave. (O)", - 1, PRPTY, & prop[10], 200},
     {"Free Parking", - 1, SAFE, 0},
     {"Kentucky ave. (R)", - 1, PRPTY, & prop[11], 220},
     {"Chance ii", - 1, CHANCE},
     {"Indiana ave. (R)", - 1, PRPTY, & prop[12], 220},
     {"Illinois ave. (R)", - 1, PRPTY, & prop[13], 240},
     {"B&O RR", - 1, RR, & rr[2], 200},
     {"Atlantic ave. (Y)", - 1, PRPTY, & prop[14], 260},
     {"Ventnor ave. (Y)", - 1, PRPTY, & prop[15], 260},
     {"Water Works", - 1, UTIL, & util[1], 150},
     {"Marvin Gardens (Y)", - 1, PRPTY, & prop[16], 280},
     {"GO TO JAIL", - 1, GOTO_J},
     {"Pacific ave. (G)", - 1, PRPTY, & prop[17], 300},
     {"N. Carolina ave. (G)", - 1, PRPTY, & prop[18], 300},
     {"Community Chest iii", - 1, CC},
     {"Pennsylvania ave. (G)", - 1, PRPTY, & prop[19], 320},
     {"Short Line RR", - 1, RR, & rr[3], 200},
     {"Chance iii", - 1, CHANCE},
     {"Park place (D)", - 1, PRPTY, & prop[20], 350},
     {"Luxury Tax", - 1, LUX_TAX},
     {"Boardwalk (D)", - 1, PRPTY, & prop[21], 400},
     {"JAIL", - 1, IN_JAIL}}
;
char[] copyright = "@(#) Copyright (c) 1980 Regents of the University of California.\n" + " All rights reserved.\n";
static char[] sccsid = "@(#)monop.c	5.7 (Berkeley) 6/1/90";
int main(int argc, char * * argv) {
    srand(getpid());
    if (argc > 1) {
        if (!restoreFromFile(argv[1])) restoreGame();
    }
    else {
        getPlayersLoop();
        rollToSeeWhoGoesFirst();
        initializeMonopolies();
    }
    luckyMessagesCount = sizeof () / sizeof ();
    initializeDecks();
    signal(2, sigquit);
    while (true) {
        printf("\n%s (%d) (cash $%d) on %s\n", currentPlayer->name, currentPlayerNumber + 1, currentPlayer->money, board[currentPlayer->location].name);
        printTurn();
        fixupPrompt();
        execute(getinp("-- Command: ", commandList));
    }
    return 0;
}
void getPlayersLoop(void) {
    while (!getPlayers());
}
boolean getPlayers(void) {
    char * sp;
    int i;
    int j;
    char[257] buf;
    blew_it:while (true) {
        if ((numberOfPlayers = getInteger("How many players? ")) <= 0 || numberOfPlayers > MAX_PLAYERS) printf("Sorry. Number must range from 1 to 9\n");
        else break;
    }
    currentPlayer = players = (player * ) calloc(numberOfPlayers, sizeof ());
    for (i = 0;i < numberOfPlayers;i++) {
        over:printf("Player %d's name: ", i + 1);
        for (sp = buf;( * sp = getchar()) != '\n';sp++) continue;
        if (sp == buf) {
            i--;
            continue;
        }
         * sp++ = '\0';
        strcpy(playerNames[i] = players[i].name = (char * ) calloc(1, sp - buf) , buf);
        players[i].money = 1500;
    }
    playerNames[i++] = "done";
    playerNames[i] = 0;
    for (i = 0;i < numberOfPlayers;i++) for (j = i + 1;j < numberOfPlayers;j++) if (strcasecmp(playerNames[i], playerNames[j]) == 0) {
        if (i != numberOfPlayers - 1) printf("Hey!!! Some of those are IDENTICAL!!  Let's try that again....\n");
        else printf("\"done\" is a reserved word.  Please try again\n");
        for (i = 0;i < numberOfPlayers;i++) cfree(players[i].name);
        cfree(players);
        return false;
    }
    return true;
}
void rollToSeeWhoGoesFirst(void) {
    int i;
    int rl;
    int currentMax;
    boolean over;
    int max_pl;
    again:do {
        putchar('\n');
        for (currentMax = i = 0;i < numberOfPlayers;i++) {
            printf("%s (%d) rolls %d\n", players[i].name, i + 1, rl = roll(2, 6));
            if (rl > currentMax) {
                over = false;
                currentMax = rl;
                max_pl = i;
            }
            else if (rl == currentMax) over++;
        }
        if (over) {
            printf("%d people rolled the same thing, so we'll try again\n", over + 1);
            continue;
        }
    }
    while (false);
    currentPlayerNumber = max_pl;
    currentPlayer = & players[max_pl];
    printf("%s (%d) goes first\n", currentPlayer->name, max_pl + 1);
}
void initializeMonopolies(void) {
    Monopoly * monopoly;
    int i;
    for (monopoly = monopolies;monopoly < & monopolies[NUMBER_OF_MONOPOLIES];monopoly++) {
        monopoly->name = monopoly->lowercaseColor;
        for (i = 0;i < monopoly->housesInMonopoly;i++) monopoly->squares[i] = & board[monopoly->squareNumbers[i]];
    }
}
boolean fixing;
boolean trading;
boolean moneyStatusGiven;
boolean isSpecialCard;
String[MAX_PLAYER