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
96_Word/README.md Normal file
View File

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

163
96_Word/csharp/Program.cs Normal file
View File

@@ -0,0 +1,163 @@
using System;
using System.Linq;
using System.Text;
namespace word
{
class Word
{
// Here's the list of potential words that could be selected
// as the winning word.
private string[] words = { "DINKY", "SMOKE", "WATER", "GRASS", "TRAIN", "MIGHT", "FIRST",
"CANDY", "CHAMP", "WOULD", "CLUMP", "DOPEY" };
/// <summary>
/// Outputs the instructions of the game.
/// </summary>
private void intro()
{
Console.WriteLine("WORD".PadLeft(37));
Console.WriteLine("CREATIVE COMPUTING MORRISTOWN, NEW JERSEY".PadLeft(59));
Console.WriteLine("I am thinking of a word -- you guess it. I will give you");
Console.WriteLine("clues to help you get it. Good luck!!");
}
/// <summary>
/// This allows the user to enter a guess - doing some basic validation
/// on those guesses.
/// </summary>
/// <returns>The guess entered by the user</returns>
private string get_guess()
{
string guess = "";
while (guess.Length == 0)
{
Console.WriteLine($"{Environment.NewLine}Guess a five letter word. ");
guess = Console.ReadLine().ToUpper();
if ((guess.Length != 5) || (guess.Equals("?")) || (!guess.All(char.IsLetter)))
{
guess = "";
Console.WriteLine("You must guess a give letter word. Start again.");
}
}
return guess;
}
/// <summary>
/// This checks the user's guess against the target word - capturing
/// any letters that match up between the two as well as the specific
/// letters that are correct.
/// </summary>
/// <param name="guess">The user's guess</param>
/// <param name="target">The 'winning' word</param>
/// <param name="progress">A string showing which specific letters have already been guessed</param>
/// <returns>The integer value showing the number of character matches between guess and target</returns>
private int check_guess(string guess, string target, StringBuilder progress)
{
// Go through each letter of the guess and see which
// letters match up to the target word.
// For each position that matches, update the progress
// to reflect the guess
int matches = 0;
string common_letters = "";
for (int ctr = 0; ctr < 5; ctr++)
{
// First see if this letter appears anywhere in the target
// and, if so, add it to the common_letters list.
if (target.Contains(guess[ctr]))
{
common_letters.Append(guess[ctr]);
}
// Then see if this specific letter matches the
// same position in the target. And, if so, update
// the progress tracker
if (guess[ctr].Equals(target[ctr]))
{
progress[ctr] = guess[ctr];
matches++;
}
}
Console.WriteLine($"There were {matches} matches and the common letters were... {common_letters}");
Console.WriteLine($"From the exact letter matches, you know......... {progress}");
return matches;
}
/// <summary>
/// This plays one full game.
/// </summary>
private void play_game()
{
string guess_word, target_word;
StringBuilder guess_progress = new StringBuilder("-----");
Random rand = new Random();
int count = 0;
Console.WriteLine("You are starting a new game...");
// Randomly select a word from the list of words
target_word = words[rand.Next(words.Length)];
// Just run as an infinite loop until one of the
// endgame conditions are met.
while (true)
{
// Ask the user for their guess
guess_word = get_guess();
count++;
// If they enter a question mark, then tell them
// the answer and quit the game
if (guess_word.Equals("?"))
{
Console.WriteLine($"The secret word is {target_word}");
return;
}
// Otherwise, check the guess against the target - noting progress
if (check_guess(guess_word, target_word, guess_progress) == 0)
{
Console.WriteLine("If you give up, type '?' for your next guess.");
}
// Once they've guess the word, end the game.
if (guess_progress.Equals(guess_word))
{
Console.WriteLine($"You have guessed the word. It took {count} guesses!");
return;
}
}
}
/// <summary>
/// The main entry point for the class - just keeps
/// playing the game until the user decides to quit.
/// </summary>
public void play()
{
intro();
bool keep_playing = true;
while (keep_playing)
{
play_game();
Console.WriteLine($"{Environment.NewLine}Want to play again? ");
keep_playing = Console.ReadLine().StartsWith("y", StringComparison.CurrentCultureIgnoreCase);
}
}
}
class Program
{
static void Main(string[] args)
{
new Word().play();
}
}
}

3
96_Word/csharp/README.md Normal file
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,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</Project>

25
96_Word/csharp/word.sln Normal file
View File

@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31321.278
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "word", "word.csproj", "{E2CF183B-EBC3-497C-8D34-32EBEE4E2B73}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E2CF183B-EBC3-497C-8D34-32EBEE4E2B73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2CF183B-EBC3-497C-8D34-32EBEE4E2B73}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2CF183B-EBC3-497C-8D34-32EBEE4E2B73}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2CF183B-EBC3-497C-8D34-32EBEE4E2B73}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B4D37881-6972-406B-978F-C1B60BA42638}
EndGlobalSection
EndGlobal

3
96_Word/java/README.md Normal file
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/)

223
96_Word/java/Word.java Normal file
View File

@@ -0,0 +1,223 @@
import java.util.Arrays;
import java.util.Scanner;
/**
* Game of Word
* <p>
* Based on the BASIC game of Word here
* https://github.com/coding-horror/basic-computer-games/blob/main/96%20Word/word.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 Word {
private final static String[] WORDS = {
"DINKY", "SMOKE", "WATER", "GRASS", "TRAIN", "MIGHT",
"FIRST", "CANDY", "CHAMP", "WOULD", "CLUMP", "DOPEY"
};
private final Scanner scan; // For user input
private enum Step {
INITIALIZE, MAKE_GUESS, USER_WINS
}
public Word() {
scan = new Scanner(System.in);
} // End of constructor Word
public void play() {
showIntro();
startGame();
} // End of method play
private void showIntro() {
System.out.println(" ".repeat(32) + "WORD");
System.out.println(" ".repeat(14) + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY");
System.out.println("\n\n");
System.out.println("I AM THINKING OF A WORD -- YOU GUESS IT. I WILL GIVE YOU");
System.out.println("CLUES TO HELP YOU GET IT. GOOD LUCK!!");
System.out.println("\n");
} // End of method showIntro
private void startGame() {
char[] commonLetters = new char[8];
char[] exactLetters = new char[8];
int commonIndex = 0;
int ii = 0; // Loop iterator
int jj = 0; // Loop iterator
int numGuesses = 0;
int numMatches = 0;
int wordIndex = 0;
Step nextStep = Step.INITIALIZE;
String commonString = "";
String exactString = "";
String guessWord = "";
String secretWord = "";
String userResponse = "";
// Begin outer while loop
while (true) {
switch (nextStep) {
case INITIALIZE:
System.out.println("\n");
System.out.println("YOU ARE STARTING A NEW GAME...");
// Select a secret word from the list
wordIndex = (int) (Math.random() * WORDS.length);
secretWord = WORDS[wordIndex];
numGuesses = 0;
Arrays.fill(exactLetters, 1, 6, '-');
Arrays.fill(commonLetters, 1, 6, '\0');
nextStep = Step.MAKE_GUESS;
break;
case MAKE_GUESS:
System.out.print("GUESS A FIVE LETTER WORD? ");
guessWord = scan.nextLine().toUpperCase();
numGuesses++;
// Win condition
if (guessWord.equals(secretWord)) {
nextStep = Step.USER_WINS;
continue;
}
Arrays.fill(commonLetters, 1, 8, '\0');
// Surrender condition
if (guessWord.equals("?")) {
System.out.println("THE SECRET WORD IS " + secretWord);
System.out.println("");
nextStep = Step.INITIALIZE; // Play again
continue;
}
// Check for valid input
if (guessWord.length() != 5) {
System.out.println("YOU MUST GUESS A 5 LETTER WORD. START AGAIN.");
numGuesses--;
nextStep = Step.MAKE_GUESS; // Guess again
continue;
}
numMatches = 0;
commonIndex = 1;
for (ii = 1; ii <= 5; ii++) {
for (jj = 1; jj <= 5; jj++) {
if (secretWord.charAt(ii - 1) != guessWord.charAt(jj - 1)) {
continue;
}
// Avoid out of bounds errors
if (commonIndex <= 5) {
commonLetters[commonIndex] = guessWord.charAt(jj - 1);
commonIndex++;
}
if (ii == jj) {
exactLetters[jj] = guessWord.charAt(jj - 1);
}
// Avoid out of bounds errors
if (numMatches < 5) {
numMatches++;
}
}
}
exactString = "";
commonString = "";
// Build the exact letters string
for (ii = 1; ii <= 5; ii++) {
exactString += exactLetters[ii];
}
// Build the common letters string
for (ii = 1; ii <= numMatches; ii++) {
commonString += commonLetters[ii];
}
System.out.println("THERE WERE " + numMatches + " MATCHES AND THE COMMON LETTERS WERE..."
+ commonString);
System.out.println("FROM THE EXACT LETTER MATCHES, YOU KNOW................" + exactString);
// Win condition
if (exactString.equals(secretWord)) {
nextStep = Step.USER_WINS;
continue;
}
// No matches
if (numMatches <= 1) {
System.out.println("");
System.out.println("IF YOU GIVE UP, TYPE '?' FOR YOUR NEXT GUESS.");
}
System.out.println("");
nextStep = Step.MAKE_GUESS;
break;
case USER_WINS:
System.out.println("YOU HAVE GUESSED THE WORD. IT TOOK " + numGuesses + " GUESSES!");
System.out.println("");
System.out.print("WANT TO PLAY AGAIN? ");
userResponse = scan.nextLine();
if (userResponse.toUpperCase().equals("YES")) {
nextStep = Step.INITIALIZE; // Play again
} else {
return; // Quit game
}
break;
default:
System.out.println("INVALID STEP");
break;
}
} // End outer while loop
} // End of method startGame
public static void main(String[] args) {
Word word = new Word();
word.play();
} // End of method main
} // End of class Word

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>WORD</title>
</head>
<body>
<pre id="output" style="font-size: 12pt;"></pre>
<script src="word.js"></script>
</body>
</html>

150
96_Word/javascript/word.js Normal file
View File

@@ -0,0 +1,150 @@
// WORD
//
// 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 words = ["DINKY", "SMOKE", "WATER", "GLASS", "TRAIN",
"MIGHT", "FIRST", "CANDY", "CHAMP", "WOULD",
"CLUMP", "DOPEY"];
var s = [];
var a = [];
var l = [];
var d = [];
var p = [];
// Main control section
async function main()
{
print(tab(33) + "WORD\n");
print(tab(15) + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n");
print("\n");
print("\n");
print("\n");
print("I AM THINKING OF A WORD -- YOU GUESS IT. I WILL GIVE YOU\n");
print("CLUE TO HELP YO GET IT. GOOD LUCK!!\n");
print("\n");
print("\n");
while (1) {
print("\n");
print("\n");
print("YOU ARE STARTING A NEW GAME...\n");
n = words.length;
ss = words[Math.floor(Math.random() * n)];
g = 0;
s[0] = ss.length;
for (i = 1; i <= ss.length; i++)
s[i] = ss.charCodeAt(i - 1);
for (i = 1; i <= 5; i++)
a[i] = 45;
for (j = 1; j <= 5; j++)
p[j] = 0;
while (1) {
print("GUESS A FIVE LETTER WORD");
ls = await input();
g++;
if (ss == ls)
break;
for (i = 1; i <= 7; i++)
p[i] = 0;
l[0] = ls.length;
for (i = 1; i <= ls.length; i++) {
l[i] = ls.charCodeAt(i - 1);
}
if (l[1] == 63) {
print("THE SECRET WORD IS " + ss + "\n");
print("\n");
break;
}
if (l[0] != 5) {
print("YOU MUST GUESS A 5 LETTER WORD. START AGAIN.\n");
print("\n");
g--;
continue;
}
m = 0;
q = 1;
for (i = 1; i <= 5; i++) {
for (j = 1; j <= 5; j++) {
if (s[i] == l[j]) {
p[q] = l[j];
q++;
if (i == j)
a[j] = l[j];
m++;
}
}
}
a[0] = 5;
p[0] = m;
as = "";
for (i = 1; i <= a[0]; i++)
as += String.fromCharCode(a[i]);
ps = "";
for (i = 1; i <= p[0]; i++)
ps += String.fromCharCode(p[i]);
print("THERE WERE " + m + " MATCHES AND THE COMMON LETTERS WERE... " + ps + "\n");
print("FROM THE EXACT LETTER MATCHES, YOU KNOW............ " + as + "\n");
if (as == ss) {
ls = as;
break;
}
if (m <= 1) {
print("\n");
print("IF YOU GIVE UP, TYPE '?' FOR YOUR NEXT GUESS.\n");
print("\n");
}
}
if (ss == ls) {
print("YOU HAVE GUESSED THE WORD. IT TOOK " + g + " GUESSES!\n");
print("\n");
} else {
continue;
}
print("WANT TO PLAY AGAIN");
qs = await input();
if (qs != "YES")
break;
}
}
main();

3
96_Word/pascal/README.md Normal file
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))

3
96_Word/perl/README.md Normal file
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/)

3
96_Word/python/README.md Normal file
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/)

71
96_Word/python/word.py Normal file
View File

@@ -0,0 +1,71 @@
#!/usr/bin/env python3
# WORD
#
# Converted from BASIC to Python by Trevor Hobson
import random
words = ["DINKY", "SMOKE", "WATER", "GRASS", "TRAIN", "MIGHT", "FIRST",
"CANDY", "CHAMP", "WOULD", "CLUMP", "DOPEY"]
def play_game():
"""Play one round of the game"""
random.shuffle(words)
target_word = words[0]
guess_count = 0
guess_progress = ["-"] * 5
print("You are starting a new game...")
while True:
guess_word = ""
while guess_word == "":
guess_word = input("\nGuess a five letter word. ").upper()
if guess_word == "?":
break
elif not guess_word.isalpha() or len(guess_word) != 5:
guess_word = ""
print("You must guess a five letter word. Start again.")
guess_count += 1
if guess_word == "?":
print("The secret word is", target_word)
break
else:
common_letters = ""
matches = 0
for i in range(5):
for j in range(5):
if guess_word[i] == target_word[j]:
matches += 1
common_letters = common_letters + guess_word[i]
if i == j:
guess_progress[j] = guess_word[i]
print("There were", matches,
"matches and the common letters were... " + common_letters)
print(
"From the exact letter matches, you know............ " + "".join(guess_progress))
if "".join(guess_progress) == guess_word:
print("\nYou have guessed the word. It took",
guess_count, "guesses!")
break
elif matches == 0:
print("\nIf you give up, type '?' for you next guess.")
def main():
print(" " * 33 + "WORD")
print(" " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n")
print("I am thinking of a word -- you guess it. I will give you")
print("clues to help you get it. Good luck!!\n")
keep_playing = True
while keep_playing:
play_game()
keep_playing = input(
"\nWant to play again? ").lower().startswith("y")
if __name__ == "__main__":
main()

3
96_Word/ruby/README.md Normal file
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/)

66
96_Word/ruby/word.rb Normal file
View File

@@ -0,0 +1,66 @@
#!/usr/bin/env ruby
# WORD
#
# Converted from BASIC to Ruby
WORDS = ["DINKY", "SMOKE", "WATER", "GRASS", "TRAIN", "MIGHT",
"FIRST","CANDY", "CHAMP", "WOULD", "CLUMP", "DOPEY"]
def game_loop
target_word = WORDS.sample.downcase
guess_count = 0
guess_progress = ["-"] * 5
puts "You are starting a new game..."
while true
guess_word = ""
while guess_word == ""
puts "Guess a five letter word. "
guess_word = gets.chomp
if guess_word == "?"
break
elsif !guess_word.match(/^[[:alpha:]]+$/) || guess_word.length != 5
guess_word = ""
puts "You must guess a five letter word. Start again."
end
end
guess_count += 1
if guess_word == "?"
puts "The secret word is #{target_word}"
break
else
common_letters = ""
matches = 0
5.times do |i|
5.times do |j|
if guess_word[i] == target_word[j]
matches += 1
common_letters = common_letters + guess_word[i]
guess_progress[j] = guess_word[i] if i == j
end
end
end
puts "There were #{matches} matches and the common letters were... #{common_letters}"
puts "From the exact letter matches, you know............ #{guess_progress.join}"
if guess_progress.join == guess_word
puts "You have guessed the word. It took #{guess_count} guesses!"
break
elsif matches < 2
puts "If you give up, type '?' for you next guess."
end
end
end
end
puts " " * 33 + "WORD"
puts " " * 15 + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n"
puts "I am thinking of a word -- you guess it. I will give you"
puts "clues to help you get it. Good luck!!\n"
keep_playing = true
while keep_playing
game_loop
puts "\n Want to play again? "
keep_playing = gets.chomp.downcase.index("y") == 0
end

145
96_Word/vbnet/Program.vb Normal file
View File

@@ -0,0 +1,145 @@
Imports System
Imports System.Text
Imports System.Text.RegularExpressions
Module Word
' Here's the list of potential words that could be selected
' as the winning word.
Dim words As String() = {"DINKY", "SMOKE", "WATER", "GRASS", "TRAIN", "MIGHT", "FIRST",
"CANDY", "CHAMP", "WOULD", "CLUMP", "DOPEY"}
' <summary>
' Outputs the instructions of the game.
' </summary>
Private Sub intro()
Console.WriteLine("WORD".PadLeft(37))
Console.WriteLine("CREATIVE COMPUTING MORRISTOWN, NEW JERSEY".PadLeft(59))
Console.WriteLine("I am thinking of a word -- you guess it. I will give you")
Console.WriteLine("clues to help you get it. Good luck!!")
End Sub
' <summary>
' This allows the user to enter a guess - doing some basic validation
' on those guesses.
' </summary>
' <returns>The guess entered by the user</returns>
Private Function get_guess() As String
Dim guess As String = ""
While (guess.Length = 0)
Console.WriteLine($"{Environment.NewLine}Guess a five letter word. ")
guess = Console.ReadLine().ToUpper()
If ((guess.Length <> 5) Or guess.Equals("?") Or Not Regex.IsMatch(guess, "^[A-Z]+$")) Then
guess = ""
Console.WriteLine("You must guess a give letter word. Start again.")
End If
End While
Return guess
End Function
' <summary>
' This checks the user's guess against the target word - capturing
' any letters that match up between the two as well as the specific
' letters that are correct.
' </summary>
' <param name="guess">The user's guess</param>
' <param name="target">The 'winning' word</param>
' <param name="progress">A string showing which specific letters have already been guessed</param>
' <returns>The integer value showing the number of character matches between guess and target</returns>
Private Function check_guess(guess As String, target As String, progress As StringBuilder) As Integer
' Go through each letter of the guess And see which
' letters match up to the target word.
' For each position that matches, update the progress
' to reflect the guess
Dim matches As Integer = 0
Dim common_letters As String = ""
For ctr As Integer = 0 To 4
' First see if this letter appears anywhere in the target
' And, if so, add it to the common_letters list.
If (target.Contains(guess(ctr))) Then
common_letters.Append(guess(ctr))
End If
' Then see if this specific letter matches the
' same position in the target. And, if so, update
' the progress tracker
If (guess(ctr).Equals(target(ctr))) Then
progress(ctr) = guess(ctr)
matches += 1
End If
Next
Console.WriteLine($"There were {matches} matches and the common letters were... {common_letters}")
Console.WriteLine($"From the exact letter matches, you know......... {progress}")
Return matches
End Function
' <summary>
' This plays one full game.
' </summary>
Private Sub play_game()
Dim guess_word As String, target_word As String
Dim guess_progress As StringBuilder = New StringBuilder("-----")
Dim rand As Random = New Random()
Dim count As Integer = 0
Console.WriteLine("You are starting a new game...")
' Randomly select a word from the list of words
target_word = words(rand.Next(words.Length))
' Just run as an infinite loop until one of the
' endgame conditions are met.
While (True)
' Ask the user for their guess
guess_word = get_guess()
count += 1
' If they enter a question mark, then tell them
' the answer and quit the game
If (guess_word.Equals("?")) Then
Console.WriteLine($"The secret word is {target_word}")
Return
End If
' Otherwise, check the guess against the target - noting progress
If (check_guess(guess_word, target_word, guess_progress) = 0) Then
Console.WriteLine("If you give up, type '?' for your next guess.")
End If
' Once they've guess the word, end the game.
If (guess_progress.Equals(guess_word)) Then
Console.WriteLine($"You have guessed the word. It took {count} guesses!")
Return
End If
End While
End Sub
' <summary>
' The main entry point for the class - just keeps
' playing the game until the user decides to quit.
' </summary>
Public Sub play()
intro()
Dim keep_playing As Boolean = True
While (keep_playing)
play_game()
Console.WriteLine($"{Environment.NewLine}Want to play again? ")
keep_playing = Console.ReadLine().StartsWith("y", StringComparison.CurrentCultureIgnoreCase)
End While
End Sub
End Module
Module Program
Sub Main(args As String())
Word.play()
End Sub
End Module

3
96_Word/vbnet/README.md Normal file
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)

25
96_Word/vbnet/word.sln Normal file
View File

@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31321.278
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "word", "word.vbproj", "{F0D2422C-983F-4DF3-9D17-D2480839DF07}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F0D2422C-983F-4DF3-9D17-D2480839DF07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F0D2422C-983F-4DF3-9D17-D2480839DF07}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0D2422C-983F-4DF3-9D17-D2480839DF07}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0D2422C-983F-4DF3-9D17-D2480839DF07}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {179D39EB-C497-4336-B795-49CC799929BB}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<RootNamespace>word</RootNamespace>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</Project>

65
96_Word/word.bas Normal file
View File

@@ -0,0 +1,65 @@
2 PRINT TAB(33);"WORD"
3 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
4 PRINT: PRINT: PRINT
5 DIM S(7),A(7),L(7),D(7),P(7)
10 PRINT "I AM THINKING OF A WORD -- YOU GUESS IT. I WILL GIVE YOU"
15 PRINT "CLUES TO HELP YOU GET IT. GOOD LUCK!!": PRINT: PRINT
20 REM
30 PRINT: PRINT: PRINT "YOU ARE STARTING A NEW GAME..."
35 RESTORE
40 READ N
50 C=INT(RND(1)*N+1)
60 FOR I=1 TO C
70 READ S$
80 NEXT I
90 G=0
95 S(0)=LEN(S$)
100 FOR I=1 TO LEN(S$): S(I)=ASC(MID$(S$,I,1)): NEXT I
110 FOR I=1 TO 5
120 A(I)=45
130 NEXT I
140 FOR J=1 TO 5
144 P(J)=0
146 NEXT J
150 PRINT "GUESS A FIVE LETTER WORD";
160 INPUT L$
170 G=G+1
172 IF S$=L$ THEN 500
173 FOR I=1 TO 7: P(I)=0: NEXT I
175 L(0)=LEN(L$)
180 FOR I=1 TO LEN(L$): L(I)=ASC(MID$(L$,I,1)): NEXT I
190 IF L(1)=63 THEN 300
200 IF L(0)<>5 THEN 400
205 M=0: Q=1
210 FOR I=1 TO 5
220 FOR J=1 TO 5
230 IF S(I)<>L(J) THEN 260
231 P(Q)=L(J)
232 Q=Q+1
233 IF I<>J THEN 250
240 A(J)=L(J)
250 M=M+1
260 NEXT J
265 NEXT I
270 A(0)=5
272 P(0)=M
275 A$="": FOR I=1 TO A(0): A$=A$+CHR$(A(I)): NEXT I
277 P$="": FOR I=1 TO P(0): P$=P$+CHR$(P(I)): NEXT I
280 PRINT "THERE WERE";M;"MATCHES AND THE COMMON LETTERS WERE...";P$
285 PRINT "FROM THE EXACT LETTER MATCHES, YOU KNOW................";A$
286 IF A$=S$ THEN 500
287 IF M>1 THEN 289
288 PRINT: PRINT "IF YOU GIVE UP, TYPE '?' FOR YOUR NEXT GUESS."
289 PRINT
290 GOTO 150
300 S$="": FOR I=1 TO 7: S$=S$+CHR$(S(I)): NEXT I
310 PRINT "THE SECRET WORD IS ";S$: PRINT
320 GOTO 30
400 PRINT "YOU MUST GUESS A 5 LETTER WORD. START AGAIN."
410 PRINT: G=G-1: GOTO 150
500 PRINT "YOU HAVE GUESSED THE WORD. IT TOOK";G;"GUESSES!": PRINT
510 INPUT "WANT TO PLAY AGAIN";Q$
520 IF Q$="YES" THEN 30
530 DATA 12,"DINKY","SMOKE","WATER","GRASS","TRAIN","MIGHT","FIRST"
540 DATA "CANDY","CHAMP","WOULD","CLUMP","DOPEY"
999 END