Removed spaces from top-level directory names.

Spaces tend to cause annoyances in a Unix-style shell environment.
This change fixes that.
This commit is contained in:
Chris Reuter
2021-11-21 18:30:21 -05:00
parent df2e7426eb
commit d26dbf036a
1725 changed files with 0 additions and 0 deletions

7
67_One_Check/README.md Normal file
View File

@@ -0,0 +1,7 @@
### One Check
As published in Basic Computer Games (1978)
https://www.atariarchives.org/basicgames/showpage.php?page=122
Downloaded from Vintage Basic at
http://www.vintage-basic.net/games.html

View File

@@ -0,0 +1,3 @@
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
Conversion to [Microsoft C#](https://docs.microsoft.com/en-us/dotnet/csharp/)

View File

@@ -0,0 +1,252 @@
import java.util.Arrays;
import java.util.Scanner;
/**
* Game of One Check
* <p>
* Based on the BASIC game of One Check here
* https://github.com/coding-horror/basic-computer-games/blob/main/67%20One%20Check/onecheck.bas
* <p>
* Note: The idea was to create a version of the 1970's BASIC game in Java, without introducing
* new features - no additional text, error checking, etc has been added.
*
* Converted from BASIC to Java by Darren Cardenas.
*/
public class OneCheck {
private final Scanner scan; // For user input
private enum Step {
SHOW_INSTRUCTIONS, SHOW_BOARD, GET_MOVE, GET_SUMMARY, QUERY_RETRY
}
public OneCheck() {
scan = new Scanner(System.in);
} // End of constructor OneCheck
public void play() {
showIntro();
startGame();
} // End of method play
private static void showIntro() {
System.out.println(" ".repeat(29) + "ONE CHECK");
System.out.println(" ".repeat(14) + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY");
System.out.println("\n\n");
} // End of method showIntro
private void startGame() {
int fromSquare = 0;
int numJumps = 0;
int numPieces = 0;
int square = 0;
int startPosition = 0;
int toSquare = 0;
// Move legality test variables
int fromTest1 = 0;
int fromTest2 = 0;
int toTest1 = 0;
int toTest2 = 0;
int[] positions = new int[65];
Step nextStep = Step.SHOW_INSTRUCTIONS;
String lineContent = "";
String userResponse = "";
// Begin outer while loop
while (true) {
// Begin switch
switch (nextStep) {
case SHOW_INSTRUCTIONS:
System.out.println("SOLITAIRE CHECKER PUZZLE BY DAVID AHL\n");
System.out.println("48 CHECKERS ARE PLACED ON THE 2 OUTSIDE SPACES OF A");
System.out.println("STANDARD 64-SQUARE CHECKERBOARD. THE OBJECT IS TO");
System.out.println("REMOVE AS MANY CHECKERS AS POSSIBLE BY DIAGONAL JUMPS");
System.out.println("(AS IN STANDARD CHECKERS). USE THE NUMBERED BOARD TO");
System.out.println("INDICATE THE SQUARE YOU WISH TO JUMP FROM AND TO. ON");
System.out.println("THE BOARD PRINTED OUT ON EACH TURN '1' INDICATES A");
System.out.println("CHECKER AND '0' AN EMPTY SQUARE. WHEN YOU HAVE NO");
System.out.println("POSSIBLE JUMPS REMAINING, INPUT A '0' IN RESPONSE TO");
System.out.println("QUESTION 'JUMP FROM ?'\n");
System.out.println("HERE IS THE NUMERICAL BOARD:\n");
nextStep = Step.SHOW_BOARD;
break;
case SHOW_BOARD:
// Begin loop through all squares
for (square = 1; square <= 57; square += 8) {
lineContent = String.format("% -4d%-4d%-4d%-4d%-4d%-4d%-4d%-4d", square, square + 1, square + 2,
square + 3, square + 4, square + 5, square + 6, square + 7);
System.out.println(lineContent);
} // End loop through all squares
System.out.println("");
System.out.println("AND HERE IS THE OPENING POSITION OF THE CHECKERS.");
System.out.println("");
Arrays.fill(positions, 1);
// Begin generating start positions
for (square = 19; square <= 43; square += 8) {
for (startPosition = square; startPosition <= square + 3; startPosition++) {
positions[startPosition] = 0;
}
} // End generating start positions
numJumps = 0;
printBoard(positions);
nextStep = Step.GET_MOVE;
break;
case GET_MOVE:
System.out.print("JUMP FROM? ");
fromSquare = scan.nextInt();
scan.nextLine(); // Discard newline
// User requested summary
if (fromSquare == 0) {
nextStep = Step.GET_SUMMARY;
break;
}
System.out.print("TO? ");
toSquare = scan.nextInt();
scan.nextLine(); // Discard newline
System.out.println("");
// Check legality of move
fromTest1 = (int) Math.floor((fromSquare - 1.0) / 8.0);
fromTest2 = fromSquare - 8 * fromTest1;
toTest1 = (int) Math.floor((toSquare - 1.0) / 8.0);
toTest2 = toSquare - 8 * toTest1;
if ((fromTest1 > 7) ||
(toTest1 > 7) ||
(fromTest2 > 8) ||
(toTest2 > 8) ||
(Math.abs(fromTest1 - toTest1) != 2) ||
(Math.abs(fromTest2 - toTest2) != 2) ||
(positions[(toSquare + fromSquare) / 2] == 0) ||
(positions[fromSquare] == 0) ||
(positions[toSquare] == 1)) {
System.out.println("ILLEGAL MOVE. TRY AGAIN...");
nextStep = Step.GET_MOVE;
break;
}
positions[toSquare] = 1;
positions[fromSquare] = 0;
positions[(toSquare + fromSquare) / 2] = 0;
numJumps++;
printBoard(positions);
nextStep = Step.GET_MOVE;
break;
case GET_SUMMARY:
numPieces = 0;
// Count remaining pieces
for (square = 1; square <= 64; square++) {
numPieces += positions[square];
}
System.out.println("");
System.out.println("YOU MADE " + numJumps + " JUMPS AND HAD " + numPieces + " PIECES");
System.out.println("REMAINING ON THE BOARD.\n");
nextStep = Step.QUERY_RETRY;
break;
case QUERY_RETRY:
while (true) {
System.out.print("TRY AGAIN? ");
userResponse = scan.nextLine();
System.out.println("");
if (userResponse.toUpperCase().equals("YES")) {
nextStep = Step.SHOW_BOARD;
break;
}
else if (userResponse.toUpperCase().equals("NO")) {
System.out.println("O.K. HOPE YOU HAD FUN!!");
return;
}
else {
System.out.println("PLEASE ANSWER 'YES' OR 'NO'.");
}
}
break;
default:
System.out.println("INVALID STEP");
nextStep = Step.QUERY_RETRY;
break;
} // End of switch
} // End outer while loop
} // End of method startGame
public void printBoard(int[] positions) {
int column = 0;
int row = 0;
String lineContent = "";
// Begin loop through all rows
for (row = 1; row <= 57; row += 8) {
// Begin loop through all columns
for (column = row; column <= row + 7; column++) {
lineContent += " " + positions[column];
} // End loop through all columns
System.out.println(lineContent);
lineContent = "";
} // End loop through all rows
System.out.println("");
} // End of method printBoard
public static void main(String[] args) {
OneCheck game = new OneCheck();
game.play();
} // End of method main
} // End of class OneCheck

View File

@@ -0,0 +1,3 @@
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
Conversion to [Oracle Java](https://openjdk.java.net/)

View File

@@ -0,0 +1,3 @@
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
Conversion to [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Shells)

View File

@@ -0,0 +1,9 @@
<html>
<head>
<title>ONE CHECK</title>
</head>
<body>
<pre id="output" style="font-size: 12pt;"></pre>
<script src="onecheck.js"></script>
</body>
</html>

View File

@@ -0,0 +1,151 @@
// ONE CHECK
//
// Converted from BASIC to Javascript by Oscar Toledo G. (nanochess)
//
function print(str)
{
document.getElementById("output").appendChild(document.createTextNode(str));
}
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");
document.getElementById("output").appendChild(input_element);
input_element.focus();
input_str = undefined;
input_element.addEventListener("keydown", function (event) {
if (event.keyCode == 13) {
input_str = input_element.value;
document.getElementById("output").removeChild(input_element);
print(input_str);
print("\n");
resolve(input_str);
}
});
});
}
function tab(space)
{
var str = "";
while (space-- > 0)
str += " ";
return str;
}
var a = [];
// Main program
async function main()
{
print(tab(30) + "ONE CHECK\n");
print(tab(15) + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n");
print("\n");
print("\n");
print("\n");
for (i = 0; i <= 64; i++)
a[i] = 0;
print("SOLITAIRE CHECKER PUZZLE BY DAVID AHL\n");
print("\n");
print("48 CHECKERS ARE PLACED ON THE 2 OUTSIDE SPACES OF A\n");
print("STANDARD 64-SQUARE CHECKERBOARD. THE OBJECT IS TO\n");
print("REMOVE AS MANY CHECKERS AS POSSIBLE BY DIAGONAL JUMPS\n");
print("(AS IN STANDARD CHECKERS). USE THE NUMBERED BOARD TO\n");
print("INDICATE THE SQUARE YOU WISH TO JUMP FROM AND TO. ON\n");
print("THE BOARD PRINTED OUT ON EACH TURN '1' INDICATES A\n");
print("CHECKER AND '0' AN EMPTY SQUARE. WHEN YOU HAVE NO\n");
print("POSSIBLE JUMPS REMAINING, INPUT A '0' IN RESPONSE TO\n");
print("QUESTION 'JUMP FROM ?'\n");
print("\n");
print("HERE IS THE NUMERICAL BOARD:\n");
print("\n");
while (1) {
for (j = 1; j <= 57; j += 8) {
str = "";
for (i = 0; i <= 7; i++) {
while (str.length < 4 * i)
str += " ";
str += " " + (j + i);
}
print(str + "\n");
}
print("\n");
print("AND HERE IS THE OPENING POSITION OF THE CHECKERS.\n");
print("\n");
for (j = 1; j <= 64; j++)
a[j] = 1;
for (j = 19; j <= 43; j += 8)
for (i = j; i <= j + 3; i++)
a[i] = 0;
m = 0;
while (1) {
// Print board
for (j = 1; j <= 57; j += 8) {
str = "";
for (i = j; i <= j + 7; i++) {
str += " " + a[i] + " ";
}
print(str + "\n");
}
print("\n");
while (1) {
print("JUMP FROM");
f = parseInt(await input());
if (f == 0)
break;
print("TO");
t = parseInt(await input());
print("\n");
// Check legality of move
f1 = Math.floor((f - 1) / 8);
f2 = f - 8 * f1;
t1 = Math.floor((t - 1) / 8);
t2 = t - 8 * t1;
if (f1 > 7 || t1 > 7 || f2 > 8 || t2 > 8 || Math.abs(f1 - t1) != 2 || Math.abs(f2 - t2) != 2 || a[(t + f) / 2] == 0 || a[f] == 0 || a[t] == 1) {
print("ILLEGAL MOVE. TRY AGAIN...\n");
continue;
}
break;
}
if (f == 0)
break;
// Update board
a[t] = 1;
a[f] = 0;
a[(t + f) / 2] = 0;
m++;
}
// End game summary
s = 0;
for (i = 1; i <= 64; i++)
s += a[i];
print("\n");
print("YOU MADE " + m + " JUMPS AND HAD " + s + " PIECES\n");
print("REMAINING ON THE BOARD.\n");
print("\n");
while (1) {
print("TRY AGAIN");
str = await input();
if (str == "YES")
break;
if (str == "NO")
break;
print("PLEASE ANSWER 'YES' OR 'NO'.\n");
}
if (str == "NO")
break;
}
print("\n");
print("O.K. HOPE YOU HAD FUN!!\n");
}
main();

86
67_One_Check/onecheck.bas Normal file
View File

@@ -0,0 +1,86 @@
2 PRINT TAB(30);"ONE CHECK"
4 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
6 PRINT: PRINT: PRINT
8 DIM A(64)
10 PRINT "SOLITAIRE CHECKER PUZZLE BY DAVID AHL"
15 PRINT
20 PRINT "48 CHECKERS ARE PLACED ON THE 2 OUTSIDE SPACES OF A"
25 PRINT "STANDARD 64-SQUARE CHECKERBOARD. THE OBJECT IS TO"
30 PRINT "REMOVE AS MANY CHECKERS AS POSSIBLE BY DIAGONAL JUMPS"
35 PRINT "(AS IN STANDARD CHECKERS). USE THE NUMBERED BOARD TO"
40 PRINT "INDICATE THE SQUARE YOU WISH TO JUMP FROM AND TO. ON"
45 PRINT "THE BOARD PRINTED OUT ON EACH TURN '1' INDICATES A"
50 PRINT "CHECKER AND '0' AN EMPTY SQUARE. WHEN YOU HAVE NO"
55 PRINT "POSSIBLE JUMPS REMAINING, INPUT A '0' IN RESPONSE TO"
60 PRINT "QUESTION 'JUMP FROM ?'"
62 PRINT
63 PRINT "HERE IS THE NUMERICAL BOARD:"
66 PRINT
70 FOR J=1 TO 57 STEP 8
74 PRINT J;TAB(4);J+1;TAB(8);J+2;TAB(12);J+3;TAB(16);J+4;TAB(20);J+5;
75 PRINT TAB(24);J+6;TAB(28);J+7
76 NEXT J
77 PRINT
78 PRINT "AND HERE IS THE OPENING POSITION OF THE CHECKERS."
79 PRINT
80 FOR J=1 TO 64
82 A(J)=1
84 NEXT J
86 FOR J=19 TO 43 STEP 8
88 FOR I=J TO J+3
90 A(I)=0
92 NEXT I
94 NEXT J
96 M=0
98 GOTO 340
100 INPUT "JUMP FROM";F
105 IF F=0 THEN 500
110 INPUT "TO";T
112 PRINT
118 REM *** CHECK LEGALITY OF MOVE
120 F1=INT((F-1)/8)
130 F2=F-8*F1
140 T1=INT((T-1)/8)
150 T2=T-8*T1
160 IF F1>7 THEN 230
170 IF T1>7 THEN 230
180 IF F2>8 THEN 230
190 IF T2>8 THEN 230
200 IF ABS(F1-T1)<>2 THEN 230
210 IF ABS(F2-T2)<>2 THEN 230
212 IF A((T+F)/2)=0 THEN 230
215 IF A(F)=0 THEN 230
220 IF A(T)=1 THEN 230
225 GOTO 250
230 PRINT "ILLEGAL MOVE. TRY AGAIN..."
240 GOTO 100
245 REM *** UPDATE BOARD
250 A(T)=1
260 A(F)=0
270 A((T+F)/2)=0
290 M=M+1
310 REM *** PRINT BOARD
340 FOR J=1 TO 57 STEP 8
350 FOR I=J TO J+7
360 PRINT A(I);
370 NEXT I
380 PRINT
390 NEXT J
400 PRINT
410 GOTO 100
490 REM *** END GAME SUMMARY
500 S=0
510 FOR I=1 TO 64
520 S=S+A(I)
530 NEXT I
540 PRINT:PRINT "YOU MADE";M;"JUMPS AND HAD";S;"PIECES"
550 PRINT "REMAINING ON THE BOARD."
560 PRINT
562 INPUT "TRY AGAIN";A$
570 IF A$="YES" THEN 70
575 IF A$="NO" THEN 600
580 PRINT "PLEASE ANSWER 'YES' OR 'NO'."
590 GOTO 562
600 PRINT
610 PRINT "O.K. HOPE YOU HAD FUN!!"
999 END

View File

@@ -0,0 +1,3 @@
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
Conversion to [Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language))

View File

@@ -0,0 +1,3 @@
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
Conversion to [Perl](https://www.perl.org/)

View File

@@ -0,0 +1,3 @@
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
Conversion to [Python](https://www.python.org/about/)

View File

@@ -0,0 +1,3 @@
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
Conversion to [Ruby](https://www.ruby-lang.org/en/)

View File

@@ -0,0 +1,3 @@
Original BASIC source [downloaded from Vintage Basic](http://www.vintage-basic.net/games.html)
Conversion to [Visual Basic .NET](https://en.wikipedia.org/wiki/Visual_Basic_.NET)