100 REM MARKET - SIMULATION OF MARKET COMPETITION BETWEEN 2 COMPANIES
105 REM DEVELOPED BY S. FINKELSTEIN, J. MCGRATH, I. STAW, D. SOBIN 
110 REM ALSO DEVELOPED BY D. KLASSEN - PROGRAMMED BY D. SOBIN
115 REM LATEST REVISION 8-29-72
120 REM COPYRIGHT 1972 - STATE UNIVERSITY OF NEW YORK
125 DEF FNR(X)=.01*INT(100*X+.5)
130 DIM C(2),I(2),T(2),A(2),L(2),D(2),P(2),V(2),W(2),B(2),E(5)
135 PRINT "DO YOU WANT INSTRUCTIONS(TYPE 1 FOR YES, 0 FOR NO)";
140 INPUT H
145 READ K2,N,K,K3,C(1),C(2),I(1),I(2),F,U,R,G1,G2,G3,M1,K4
150 LET Q=0
155 PRINT 
160 IF H=0 THEN 200 
165 PRINT "MARKET SIMULATES THE COMPETITION BETWEEN TWO COMPANIES"
170 PRINT "SELLING A PRODUCT DIFFERENTIATED BY BRAND ADVERTISING."
175 PRINT "THE QUANTITY EACH COMPANY SELLS IS DEPENDENT UPON PRICE"
180 PRINT "AND ADVERTISING BUDGET. THE GAME ENDS WHEN ONE "
185 PRINT "COMPANY GOES BANKRUPT OR REACHES ";1.00000E-03*M1;" MILLION IN"
190 PRINT "TOTAL ASSETS."
195 PRINT 
200 PRINT "ARE YOU BEGINNING THE GAME OR CONTINUING"
205 PRINT "(TYPE 1 FOR BEGINNING, 2 FOR CONTINUING)";
210 INPUT A
215 PRINT 
220 IF A=1 THEN 270 
225 FOR J=1 TO 2
230 PRINT "COMPANY "J;"ENTER PREVIOUS CASH ON HAND,PREVIOUS INVENTORY";
235 INPUT C(J),I(J)
240 PRINT 
245 NEXT J
250 PRINT "ENTER VARIABLE PRODUCTION COST";
255 INPUT U
260 PRINT "ENTEP QUARTER NUMBER";
265 INPUT Q
270 PRINT 
275 PRINT "FIXED PRODUCTION COST=$";F*1000;"/ QUARTER"
280 PRINT "VARIABLE PRODUCTION COST=$";U;"/UNIT"
285 PRINT "WITH NO ADVERTISING AND A SELLING PRICE OF $50/UNIT"
290 PRINT "A COMPANY WILL SELL ";K2*500;" UNITS (PRINTED AS ";K2/2;")"
295 PRINT "WAREHOUSE  CHARGE FOR INVENTORY="R*100;" PER CENT"
300 PRINT "INTEREST CHARGE ON BORROWED MONEY="K3*100;" PER CENT"
305 PRINT 
310 PRINT 
315 RANDOMIZE
320 PRINT 
325 PRINT 
330 PRINT "UNITS AND DOLLARS BELOW ARE IN THOUSANDS "
335 PRINT 
340 PRINT 
345 FOR J=1 TO 5
350 LET E(J)=0
355 NEXT J
360 LET P4=0
365 GOSUB 875 
370 FOR J=1 TO 2
375 LET W(J)=0
380 LET D(J)=0
385 LET T(J)=0
390 LET B(J)=U*I(J)+C(J)
395 GOSUB 900 
400 NEXT J
405 PRINT 
410 LET Q=Q+1
415 GOSUB 1060 
420 GOSUB 675 
425 GOSUB 865 
430 REM COMPUTE DEMAND 
435 FOR J=1 TO 2
440 LET D(J)=(1-E(5))*.5*(K2+2*V(J)*D1)/(P(J)/50)^N
445 NEXT J
450 GOSUB 1000 
455 FOR J=1 TO 2
460 IF D(J)>I(J) THEN 475 
465 LET T(J)=D(J)
470 GO TO 480 
475 LET T(J)=I(J)
480 LET T(J)=INT(T(J))
485 LET C(J)=C(J)+T(J)*P(J)
490 LET I(J)=I(J)-T(J)
495 NEXT J
500 FOR J=1 TO 2
505 LET C(J)=C(J)-R*I(J)*U-K3*C(J)*(SGN(C(J))-SGN(C(J))^2)/2
510 LET C(J)=INT(C(J))
515 IF E(5)=0 THEN 530 
520 LET W(J)=0
525 GO TO 540 
530 IF T(1)+T(2)=0 THEN 520 
535 LET W(J)=INT(10000*T(J)/(T(1)+T(2)))/100
540 NEXT J
545 FOR J=1 TO 2
550 GOSUB 900 
555 LET B(J)=C(J)+U*I(J)
560 IF B(J)>0 THEN 580 
565 PRINT 
570 GOSUB 975 
575 PRINT 
580 IF B(J)<M1 THEN 620 
585 IF B(J)<=C(3-J)+U*I(3-J) THEN 620 
590 LET P4=17
595 PRINT 
600 PRINT TAB(14);"********************"
605 PRINT "COMPANY ";J;" YOU HAVE REACHED "1.00000E-03*M1;" MILLION AND WON"
610 PRINT TAB(14);"********************"
615 PRINT 
620 NEXT J
625 PRINT 
630 IF P4<>17 THEN 410 
635 PRINT 
640 PRINT "DO YOU WANT TO PLAY AGAIN(TYPE 1 FOR YES, 0 FOR NO)";
645 INPUT H
650 IF H=0 THEN 670 
655 RESTORE 
660 PRINT 
665 GO TO 135 
670 STOP
675 PRINT 
680 FOR J=1 TO 2
685 PRINT 
690 PRINT 
695 PRINT "COMPANY ";J
700 IF E(2)<>1 THEN 715 
705 PRINT "NO PRODUCTION POSSIBLE DUE TO STRIKE"
710 GO TO 730 
715 PRINT "PRODUCTION LEVEL";
720 INPUT L(J)
725 IF L(J)<0 THEN 715 
730 PRINT "ADVERTISING BUDGET";
735 INPUT A(J)
740 IF A(J)<0 THEN 730 
745 LET C(J)=C(J)-F-L(J)*U-A(J)
750 IF E(2)=1 THEN 760 
755 LET I(J)=I(J)+L(J)
760 PRINT "UNIT PRICE";
765 INPUT A
770 IF E(1)<>1 THEN 800 
775 IF A<=P(J) THEN 800 
780 PRINT 
785 PRINT "YOU MAY NOT RAISE PRICES DURING THE WAGE-PRICE FREEZE"
790 PRINT 
795 GO TO 760 
800 LET P(J)=A
805 IF A>200 THEN 760 
810 IF P(J)<=0 THEN 760 
815 NEXT J
820 LET A2=A(1)+A(2)
825 IF A2>0 THEN 845 
830 LET V(1)=0
835 LET V(2)=0
840 GO TO 855 
845 LET V(1)=A(1)/A2
850 LET V(2)=A(2)/A2
855 LET D1=(K2-K2*EXP(-K*A2))*K4
860 RETURN
865 PRINT 
870 PRINT 
875 PRINT "QUARTER ";Q
880 PRINT 
885 PRINT "PROFIT  MARKET SHARE  CASH ON HAND  NUMBER SOLD  ";
890 PRINT "INVENTORY  ASSETS"
895 RETURN
900 PRINT U*I(J)+C(J)-B(J);TAB(9);W(J);TAB(23);C(J);TAB(37);
905 PRINT T(J);TAB(50);I(J);TAB(61);U*I(J)+C(J)
910 RETURN
915 DATA 50
920 DATA 2
925 DATA 1.00000E-03
930 DATA .05
935 DATA 5000,5000
940 DATA 100,100
945 DATA 250
950 DATA 20
955 DATA .05
960 DATA .2,.4,.4
965 DATA 12000
970 DATA 1.5
975 PRINT TAB(7);"********************"
980 PRINT "COMPANY "J;" YOU HAVE GONE BANKRUPT"
985 PRINT TAB(7);"********************"
990 LET P4=17
995 RETURN
1000 IF P(1)<P(2) THEN 1015 
1005 LET M=2
1010 GO TO 1020 
1015 LET M=1
1020 LET G4=(P(3-M)-P(M))/P(3-M)
1025 IF G4<=G1 THEN 1055 
1030 IF G4<G2 THEN 1040 
1035 LET G4=G2
1040 LET G5=D(3-M)*((G4-G1)/(G2-G1))*G3
1045 LET D(3-M)=D(3-M)-G5
1050 LET D(M)=D(M)+G5
1055 RETURN
1060 IF Q<6 THEN 1230 
1065 IF RND(1)<.1 THEN 1090 
1070 IF RND(1)<.1 THEN 1115 
1075 IF RND(1)<.1 THEN 1165 
1080 IF RND(1)<.1 THEN 1200 
1085 GO TO 1230 
1090 IF E(1)>0 THEN 1070 
1095 GOSUB 1300 
1100 LET E(1)=1
1105 LET Q1=Q
1110 GO TO 1070 
1115 LET I=INT(RND(1)+1.5)
1120 IF Q-W2<=2 THEN 1075 
1125 IF C(I)<0 THEN 1075 
1130 IF C(I)>200 THEN 1145 
1135 LET C(I)=.75*C(I)
1140 GO TO 1150 
1145 LET C(I)=C(I)-200
1150 GOSUB 1325 
1155 LET W2=Q
1160 GO TO 1075 
1165 LET J=INT(RND(1)+1.5)
1170 IF Q-W3<=2 THEN 1080 
1175 GOSUB 1350 
1180 LET C(J)=C(J)+U*I(J)*.75
1185 LET I(J)=0
1190 LET W3=Q
1195 GO TO 1080 
1200 IF E(1)=1 THEN 1230 
1205 IF Q-W4<=2 THEN 1230 
1210 LET W4=Q
1215 GOSUB 1375 
1220 LET E(5)=1
1225 LET Q2=Q
1230 IF INT((Q-1)/4)*4<>Q-1 THEN 1425 
1235 IF Q=1 THEN 1425 
1240 IF E(1)=1 THEN 1425 
1245 IF RND(1)>.25 THEN 1280 
1250 IF Q<6 THEN 1280 
1255 GOSUB 1400 
1260 LET E(2)=1
1265 LET U=INT(U*(1.1+.1*RND(1)))
1270 LET Q3=Q
1275 GO TO 1425 
1280 LET U=INT(U*(1.05+.1*RND(1)))
1285 PRINT "NEW LABOR CONTRACT - VARIABLE PRODUCTION COST NOW=";
1290 PRINT " $";U;"/UNIT"
1295 GO TO 1425 
1300 PRINT "THE PRESIDENT HAS JUST IMPOSED A WAGE-PRICE FREEZE ON THE"
1305 PRINT "ECONOMY, AND YOU MAY NOT RAISE THE PRICE OF YOUR PRODUCT"
1310 PRINT "OVER THE NEXT 2 QUARTERS."
1315 PRINT 
1320 RETURN
1325 PRINT "COMPANY ";I;"HAS BEEN THE VICTIM OF EMBEZZLEMENT BY THE"
1330 PRINT "VICE PRESIDENT OF THE COMPANY. YOUR CASH ON HAND IS NOW ";
1335 PRINT "$";C(I)
1340 PRINT 
1345 RETURN
1350 PRINT "COMPANY";J;" HAS SUFFERED FIRE DAMAGE IN ITS WAREHOUSE"
1355 PRINT "ALL UNITS WERE DESTROYED. YOUR INSURANCE WILL REIMBURSE YOU"
1360 PRINT "IN THE AMOUNT OF $";INT(U*I(J)*.75);" FOR THESE UNITS"
1365 PRINT 
1370 RETURN
1375 PRINT "A TRANSPORTATION STRIKE HAS OCCURED, AND YOU ARE UNABLE TO"
1380 PRINT "MOVE YOUR GOODS TO THE DISTRIBUTORS. NEGOTIATIONS HAVE"
1385 PRINT "BEGUN, BUT HOPE OF A SETTLEMENT LOOKS DIM."
1390 PRINT 
1395 RETURN
1400 PRINT "THERE HAS BEEN A STRIKE AND YOUR PRODUCTION HAS BEEN"
1405 PRINT "HALTED. NEGOTIATIONS HAVE BEEN STARTED, BUT HOPE OF"
1410 PRINT "A SETTLEMENT LOOKS DIM."
1415 PRINT 
1420 RETURN
1425 IF E(1)<>1 THEN 1450 
1430 IF Q<Q1+2 THEN 1450 
1435 LET E(1)=2
1440 PRINT "THE WAGE-PRICE FREEZE HAS ENDED"
1445 PRINT 
1450 IF E(5)<>1 THEN 1475 
1455 IF Q2=Q THEN 1475 
1460 LET E(5)=0
1465 PRINT "TRANSPORTATION STRIKE SETTLED. NORMAL DELIVERIES RESUMED"
1470 PRINT 
1475 IF E(2)<>1 THEN 1505 
1480 IF Q3=Q THEN 1505 
1485 PRINT "STRIKE SETTLED. NORMAL PRODUCTION RESUMED"
1490 PRINT "NEW VARIABLE COST=$";U;" / UNIT DUE TO INCREASED WAGES"
1495 PRINT 
1500 LET E(2)=0
1505 RETURN
1510 END
