this is pascal:
program e;
uses wincrt;
procedure game;
var
c1:integer; {c1 is the number if counters player one is taking away}
c2:integer; {c2 is the number if counters player two is taking away}
tnc:integer; {number of counters at the start of the game (Total Number of Counters)}
i:integer; {loop counter for counters}
rem:integer; {remaining counters}
p1:string; {player one's name}
p2:string; {player two's name}
begin {begin game procedure}
Clrscr;
write('please enter your name player one? .... '); {requesting name for player one}
readln(p1); {reading player one's name}
write('please enter your name player two? .... '); {requesting name for player two}
readln(p2); {reading player two's name}
write('how many counters are there?.... '); {requesting the number of counters to be used in the game}
readln(tnc); {reading the number of counters to be used in the game}
if (tnc<20) or (tnc>30) then {validating the number entered}
begin
repeat
writeln(' !THE VALUE YOU HAVE ENTERED IS NOT BETWEEN 20 AND 30! Please enter an apropreate value');
readln(tnc);
until (tnc>=20) and (tnc<=30);
end;
clrscr; {end of validation}
writeln;
writeln;
writeln;
writeln;
writeln;
for i:= 1 to tnc do {loop to produce the counters}
begin
write('* ');
end; {end of counter production}
writeln;
rem:=tnc;
{setting the number of remaining counters to the number of counters chosen for the start of the game}
repeat
write('how many counters do you want to take away ',p1,' .... ');
{requesting the number of counters player one wishes to remove}
readln(c1); {reading the number of counters player one wishes to remove}
if (c1<1) or (c1>4) then {validating the number of counters player one wishes to remove}
begin
repeat
writeln(' !THE VALUE YOU HAVE ENTERED IS NOT BETWEEN 1 AND 4! Please enter an apropreate value');
readln(c1);
until (c1>=1) and (c1<=4);
end;
if (c1>rem) then
begin
repeat
writeln(' !THE VALUE YOU HAVE ENTERED IS LARGER THAN THE NUMBER OF COUNTERS LEFT ! Please enter an apropreate value');
readln(c1);
until (c1>=1) and (c1<=rem);
end; {end of validation}
rem:=rem-c1;
clrscr; {producing counters}
writeln;
writeln;
writeln;
writeln;
writeln;
for i:=1 to rem do
begin
write('* ');
end; {end of counter production}
writeln;
if (rem<1) then {deciding if game is one}
begin {If winner then declares winner}
writeln(p1,' is the winner');
Writeln('press enter to return to the main menu');
readln;
clrscr;
exit; {exits the game and returns to main menu if player one wins}
end;
write('how many counters do you want to take away ',p2,' .... ');
{requesting the number of counters player two wishes to remove}
readln(c2); {reading the number of counters player two wishes to remove}
if (c2<1) or (c2>4) then {validating the number of counters player one wishes to remove}
begin
repeat
writeln(' !THE VALUE YOU HAVE ENTERED IS NOT BETWEEN 1 AND 4! Please enter an apropreate value');
readln(c2);
until (c2>=1) and (c2<=4);
end;
if (c2>rem) then
begin
repeat
writeln(' !THE VALUE YOU HAVE ENTERED IS LARGER THAN THE NUMBER OF COUNTERS LEFT ! Please enter an apropreate value');
readln(c2);
until (c2>=1) and (c2<=rem);
end; {end of validation}
rem:=rem-c2;
clrscr;
writeln;
writeln;
writeln;
writeln;
writeln;
for i:=1 to rem do
begin
write('* ');
end;
writeln;
if (rem<1) then
begin
writeln(p2,' is the winner');
end;
until (rem<1);
writeln('press enter to rerturn to the main menu');
readln;
clrscr;
end;
procedure rules;
begin
clrscr;
writeln;
writeln;
writeln;
writeln('This is a 2 player game where there a number of counters between 20 and 30,');
writeln('(set by the players)');
writeln('the two players must enter thier names,');
writeln('then they take it in turns to take away between 3 and 4 counters at a time.');
writeln('the player who takes away the last counters is the winner, good luck,');
writeln;
writeln('press enter to return to the main menu');
readln;
clrscr;
end;
procedure menu;
var
choice:integer;
begin {begin menu procedure}
repeat
writeln;
writeln;
writeln;
writeln;
writeln(' ':6,'**MAIN MENU**');
writeln;
writeln('please enter a choice, what do you want to do?');
writeln('1-game');
writeln('2-instructions');
writeln('3-exit');
readln(choice);
case choice of
1:game;
2:rules;
3:begin
clrscr;
writeln ('press enter to end program');
readln;
donewincrt;
end;
else
writeln ('invalid choice please try again');
end;
until (choice=3);
end;
begin
menu;
end.
i wrote it for a school assesment in bordland's turbo pascal
http://www.larinar.tk
AMD athlon thoroughbred 2200, 512Mb ram, 40Gb HD, ati saphire radeon 9600 atlantis w/128mb ddr ram, good creative-labs soundcard, cd-rw + dvd drives.