mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-25 20:34:32 -08:00
MAINT: Apply pre-commit
Remove byte-order-marker pre-commit check as there would be many adjustments necessary
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
30 PRINT:PRINT:PRINT
|
||||
40 DIM A(10,10)
|
||||
100 REM *** THE GAME OF CHOMP *** COPYRIGHT PCC 1973 ***
|
||||
110 PRINT
|
||||
110 PRINT
|
||||
120 PRINT "THIS IS THE GAME OF CHOMP (SCIENTIFIC AMERICAN, JAN 1973)"
|
||||
130 PRINT "DO YOU WANT THE RULES (1=YES, 0=NO!)";
|
||||
140 INPUT R
|
||||
@@ -25,16 +25,16 @@
|
||||
300 PRINT "(INCLUDING THAT SQUARE, TOO) DISAPPEAR -- CHOMP!!"
|
||||
310 PRINT "NO FAIR CHOMPING SQUARES THAT HAVE ALREADY BEEN CHOMPED,"
|
||||
320 PRINT "OR THAT ARE OUTSIDE THE ORIGINAL DIMENSIONS OF THE COOKIE."
|
||||
330 PRINT
|
||||
330 PRINT
|
||||
340 PRINT "HERE WE GO..."
|
||||
350 REM
|
||||
350 REM
|
||||
360 F=0
|
||||
370 FOR I=1 TO 10
|
||||
372 FOR J=1 TO 10
|
||||
375 A(I,J)=0
|
||||
377 NEXT J
|
||||
379 NEXT I
|
||||
380 PRINT
|
||||
380 PRINT
|
||||
390 PRINT "HOW MANY PLAYERS";
|
||||
400 INPUT P
|
||||
410 I1=0
|
||||
@@ -48,7 +48,7 @@
|
||||
490 IF C <= 9 THEN 530
|
||||
500 PRINT "TOO MANY COLUMNS (9 IS MAXIMUM). NOW, ";
|
||||
510 GOTO 470
|
||||
530 PRINT
|
||||
530 PRINT
|
||||
540 FOR I=1 TO R
|
||||
550 FOR J=1 TO C
|
||||
560 A(I,J)=1
|
||||
@@ -56,7 +56,7 @@
|
||||
580 NEXT I
|
||||
590 A(1,1)=-1
|
||||
600 REM PRINT THE BOARD
|
||||
610 PRINT
|
||||
610 PRINT
|
||||
620 PRINT TAB(7);"1 2 3 4 5 6 7 8 9"
|
||||
630 FOR I=1 TO R
|
||||
640 PRINT I;TAB(7);
|
||||
@@ -67,11 +67,11 @@
|
||||
690 GOTO 710
|
||||
700 PRINT "P ";
|
||||
710 NEXT J
|
||||
720 PRINT
|
||||
720 PRINT
|
||||
730 NEXT I
|
||||
740 PRINT
|
||||
740 PRINT
|
||||
750 IF F=0 THEN 770
|
||||
760 RETURN
|
||||
760 RETURN
|
||||
770 REM GET CHOMPS FOR EACH PLAYER IN TURN
|
||||
780 LET I1=I1+1
|
||||
790 LET P1=I1-INT(I1/P)*P
|
||||
@@ -97,7 +97,7 @@
|
||||
990 GOTO 610
|
||||
1000 REM END OF GAME DETECTED IN LINE 900
|
||||
1010 PRINT "YOU LOSE, PLAYER";P1
|
||||
1020 PRINT
|
||||
1020 PRINT
|
||||
1030 PRINT "AGAIN (1=YES, 0=NO!)";
|
||||
1040 INPUT R
|
||||
1050 IF R=1 THEN 340
|
||||
|
||||
@@ -88,7 +88,7 @@ public class Chomp{
|
||||
|
||||
private void move(int player){
|
||||
System.out.println(String.format("Player %d",(player+1)));
|
||||
|
||||
|
||||
String input;
|
||||
String [] coordinates;
|
||||
int x=-1,y=-1;
|
||||
|
||||
@@ -12,10 +12,10 @@ function input()
|
||||
{
|
||||
var input_element;
|
||||
var input_str;
|
||||
|
||||
|
||||
return new Promise(function (resolve) {
|
||||
input_element = document.createElement("INPUT");
|
||||
|
||||
|
||||
print("? ");
|
||||
input_element.setAttribute("type", "text");
|
||||
input_element.setAttribute("length", "50");
|
||||
|
||||
@@ -13,7 +13,7 @@ sub main {
|
||||
}
|
||||
|
||||
sub game_play {
|
||||
|
||||
|
||||
# the initial game set up
|
||||
&print_intro;
|
||||
my ($players,$rows,$cols) = &get_user_info;
|
||||
@@ -24,7 +24,7 @@ sub game_play {
|
||||
|
||||
# continuous loop until the poison pill is swallowed
|
||||
until ($game_over == 1) {
|
||||
if ($player > ($players-1)) { #checks to make sure we're just looping thru valid players
|
||||
if ($player > ($players-1)) { #checks to make sure we're just looping thru valid players
|
||||
$player = 0;
|
||||
}
|
||||
$player++;
|
||||
@@ -39,7 +39,7 @@ sub game_play {
|
||||
&modify_gameboard($rows,$cols,$user_row,$user_col);
|
||||
&print_gameboard($rows,$cols);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
sub get_player_row_col {
|
||||
@@ -136,7 +136,7 @@ sub modify_gameboard {
|
||||
my ($rows,$cols,$user_row,$user_col) = @_;
|
||||
foreach my $row ($user_row..($rows)) {
|
||||
foreach my $col ($user_col..($cols)) {
|
||||
$cookie[$row][$col]=" ";
|
||||
$cookie[$row][$col]=" ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
|
||||
class Canvas:
|
||||
""" For drawing the cookie """
|
||||
"""For drawing the cookie"""
|
||||
|
||||
def __init__(self, width=9, height=9, fill="*"):
|
||||
self._buffer = []
|
||||
@@ -83,8 +83,12 @@ def play_game():
|
||||
player_column = -1
|
||||
while player_row == -1 or player_column == -1:
|
||||
try:
|
||||
coordinates = [int(item) for item in input(
|
||||
"Coordinates of chomp (Row, Column) ").split(",")]
|
||||
coordinates = [
|
||||
int(item)
|
||||
for item in input("Coordinates of chomp (Row, Column) ").split(
|
||||
","
|
||||
)
|
||||
]
|
||||
player_row = coordinates[0]
|
||||
player_column = coordinates[1]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user