In the 1980s I spent my time writing code on my 8-bit ZX81 and Atari computers. I learnt everything I know about programming from copying and modifying printed code listings from books with computer games. The games in these books are mostly simple text-based games, but the authors gave them enticing names, often imaginatively illustrated to visualise the virtual world they represent. A line and a dot become a game of tennis, and a computer that was able to play Tic Tac Toe seemed like your machine had come alive.
The old books by Usborne publishing are unique because it contains several versions of each program to ensure compatibility with some of the many dialects of the BASIC language. I first entered this code into the atari800 emulator to test what it does, after which I converted it to the R language.
Let’s step into the creepy world of computer games as imagined by Usborne Publishing.
Reynold, Colin and McCaig, Rob, Creepy Computer Games (Usborne, London).
Gravedigger
Gravedigger by Alan Ramsey is a typical example of the games listed in the books of the early days of home computing. You can download the original book for free from the publisher ‘s Google drive. The Gravedigger listing starts on page 10. The lyrical description of the game provides the instructions:
It’s dark and windy—not the kind of night to be lost in a graveyard, but that’s where you are. You have until midnight to find your way out. Skeletons lurk in the shadows waiting to scare you to death should you come to close. You can dig holes to help keep them away but digging is tiring work and you cannot manage more than five in one game. You have to be careful not to fall down the holes you have dug. Grave stones (marked
+
) and the walls of the graveyard (marked
:
) block your way. The holes you digs are marked
O
, you are
*
and the skeletons are
X
. See if you can escape.Partial page of the Gravedigger game in BASIC.
I translated the BASIC code as close to the original as possible. This game is not pretty code, but it works. Some of the variable names have been changed because, in BASIC, single variables and vectors can have the same name and names of character vectors end in $. A future version of this game could use graphics as I did in the Tic Tac Toe game.
The game is quite tricky, and I have only managed to escape the graveyard once. It looks like the likelihood of success very much depends on the random distribution of the graves. Perhaps we need some machine learning to optimise strategy.
You can view the code below, or download it from GitHub. I leave it up to you to deconstruct the program and safely work your way through the graveyard.
Happy Halloween!
## Creepy Computer Games
## Reynold, Colin and McCaig, Rob, Creepy Computer Games (Usborne, London).
## https://archive.org/details/Creepy_Computer_Games_1983_Usborne_Publishing/
## Gravedigger by Alan Ramsey
## Initiate board
A <- matrix(ncol = 20, nrow = 10)
A[,] <- " "
## Starting variables
W <- 0 # Move number
X <- 5 # Remaining holes
death <- 0
## Initiate pieces
Y <- "*"
B <- "+"
C <- "O"
D <- ":"
E <- "X"
Z <- " "
## Draw board
## Add borders
A[c(1, 10), ] <- D
A[10, ] <- D
A[, 1] <- D
A[1:8, 20] <- D
## Add graves
for (i in 1:20){
A[floor(runif(1) * 7 + 2), floor(runif(1) * 15 + 3)] <- B
}
## Starting positions
## Player
M <- 2
N <- 2
## Skeletons
S <- c(4, 19, 3, 19, 2, 19)
## Game play
repeat{
## Position player
A[N, M] <- Y
## Position skeletons
for (J in seq(1, 5, by = 2)) {
A[S[J], S[J + 1]] <- J
}
W <- W + 1 ## Move counter
if (W > 60) {
print("The clock's struck midnight")
print("Aghhhhh!!!!")
break
}
## Clear screen
#cat(rep("\n", 50))
## Print board
v <- paste(as.vector(t(A)), collapse = "")
for (i in 1:10)
print(substr(v, (i - 1) * 20 + 1, (i - 1) * 20 + 20))
## Enter move
A1 <- toupper(readline(paste0("Enter move ", W, " (You can go N, S, E or W): ")))
## Move player
T <- N
U <- M
if (A1 == "N") {
T <- N - 1
}
if (A1 == "E") {
U <- M + 1
}
if (A1 == "S") {
T <- N + 1
}
if (A1 == "W") {
U <- M - 1
}
## Collission detection
if (A[T, U] == D | A[T, U] == B) { # Edge or grave
print("That way's blocked")
}
if (A[T, U] == C) { # Hole
print("You've fallen into one of your own holes")
break
}
if (A[T, U] == E) { # Skeleton
death <- 1
}
if (T == 9 & U == 20) { # Escaped
print("You're free!")
print(paste0("Your performance rating is ",
floor((60 - W) / 60 * (96 + X)), "%"))
break
}
## Move player and dig hole
if (A[T, U] == Z) { # Move into empty space
A [N, M] <- Z
if (X != 0) {
B1 <- toupper(readline("Would you like to dig a hole (Y or N): "))
if (B1 == "Y") {
X <- X - 1
A[N, M] <- C
}
}
N <- T
M <- U
}
## Move skeletons
for (J in seq(1, 5, by = 2)) {
T <- S[J]
U <- S[J + 1]
## Collision detection
if (any(c(A[T, U + 1], A[T, U - 1], A[T - 1, U], A[T + 1, U]) %in% Y)) {
death <- 1
}
if (A1 == "S" & A[T + 1, U] == Z){
S[J] <- S[J] + 1 # Follow player
}
if (A1 == "N" & A[T - 1, U] == Z){
S[J] <- S[J] - 1 # Follow player
}
if (A1 == "E" & A[T, U - 1] == Z & M < U){
S[J + 1] <- S[J + 1] - 1 # Move towards player
}
if (A1 == "E" & A[T, U + 1] == Z & M > U) {
S[J + 1] <- S[J + 1] + 1 # Reverse direction
}
if (A1 %in% c("S", "N", "E")) {
A[T, U] <- Z
}
}
if (death == 1) {
print("Urk! You've been scared to death by a skeleton.")
break
}
}
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie
Duration
Description
cookielawinfo-checkbox-analytics
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional
11 months
The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy
11 months
The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.