06-04-2010
Bash Script for "simple" racing game.
Hello All,
I was wondering if it would be possible to create a "racing" game in script. The game play would be as follows. Script will read the following input:
Start
|b| | | | |
|r| | | | |
First player (b) will roll a die to see how many spaces to move. This is will continue until the player reaches the end.
Roll a 2
| | |b| | |
|r| | | | |
I thought I could read user input, to tell "b" or "r" how much to move. This can be done using "read." I originally wanted to use the awk command to first grab the string and then move it to the next column. To do this, I would have to delete what is in column one, and then write to column three. I figured I could then append/write this to an output file and then use cat to display results.
Any suggestions?
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
------------------------------
$x=" hi";
$tabspace=0;
while ($x =~ /\t/g )
{
$tabspace++;
}
print $tabspace;
---------------------------------
1.)when i tried it without "g" ($x = ~/\t/ )... when i run the script it utilizes around 95% cpu and system hangs and i did "End process"... (0 Replies)
Discussion started by: sekar sundaram
0 Replies
2. Shell Programming and Scripting
Hi,
For my bash script, terminal with bash is generate an OK output and program works right.
already,
terminal with ash have "line 48: syntax error: Bad substitution" output and program don't work.
:confused: (0 Replies)
Discussion started by: s. murat
0 Replies
3. Shell Programming and Scripting
Input file:
2 aux003.net3.com error12
6 awn0117.net1.com error13
84 aux008 error14
29 aux001.ha.ux.isd.com error12
209 aux002.vm.ux.isd.com error34
21 alx0027.vm.net2.com error12
227 dux001.net5.com error123
22 us008.dot.net2.com error121
13 us009.net2.com error129Expected Output:
2... (4 Replies)
Discussion started by: sQew
4 Replies
4. Shell Programming and Scripting
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Discussion started by: shis100
7 Replies
5. Shell Programming and Scripting
Well, this is a very crazy issue, and I'm scratching my head to find a solution.
This is a simple code to tranfer a file, in my main script I need to add a conditional statement (IF/THEN) like the below example:
#!/bin/bash
if ; then
ftp -inv "192.168.1.10" << EOFTP
user... (8 Replies)
Discussion started by: Lord Spectre
8 Replies
6. UNIX for Dummies Questions & Answers
Hi All,
I'm completely new to bash scripting and still learning my way through albeit vey slowly.
I need to know where to insert my server names', my ip address numbers through out the script alas to no avail.
I'm also searching on how to save .sh (bash shell) script properly.... (25 Replies)
Discussion started by: profileuser
25 Replies
7. Shell Programming and Scripting
Ladies & Gents,
Can one of you gurus please show me a very simple "expect" script to change the password in Solaris in a script, please? Nothing fancy, no error checking, no nothing. Just to change the password of a new user, it's all.
Many thanks in advance. U guys have honestly earned my... (1 Reply)
Discussion started by: Hiroshi
1 Replies
8. Shell Programming and Scripting
I've found this script part on the stackoverflow:
if ; then
sudo bash "$0" "$@";
exit "$?";
fi
I realized that sudo bash "$0" "$@"; is the only needed for me.
But the strange thing happens when I move this line outside the IF statement:
sudo bash "$0" "$@"; stops the... (9 Replies)
Discussion started by: boqsc
9 Replies
9. Shell Programming and Scripting
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
LEARN ABOUT SUSE
backgammon
BACKGAMMON(6) BSD Games Manual BACKGAMMON(6)
NAME
backgammon -- the game of backgammon
teachgammon -- learn to play backgammon
SYNOPSIS
backgammon [-] [-nrwb] [-pr] [-pw] [-pb] [-t term] [-s file]
teachgammon
DESCRIPTION
This program lets you play backgammon against the computer or against a "friend". All commands are only one letter, so you don't need to
type a carriage return, except at the end of a move. The program is mostly self-explanatory, so that a question mark (?) will usually get
some help. If you answer `y' when the program asks if you want the rules, you will get text explaining the rules of the game, some hints on
strategy, instructions on how to use the program, and a tutorial consisting of a practice game against the computer. A description of how to
use the program can be obtained by answering `y' when it asks if you want instructions.
The possible arguments for backgammon (most are unnecessary but some are very convenient) consist of:
-n don't ask for rules or instructions
-r player is red (implies n)
-w player is white (implies n)
-b two players, red and white (implies n)
-pr print the board before red's turn
-pw print the board before white's turn
-pb print the board before both player's turn
-t term
terminal is type term, uses /usr/share/misc/termcap
-s file
recover previously saved game from file
Any unrecognized arguments are ignored. An argument of a lone `-' gets a description of possible arguments.
If term has capabilities for direct cursor movement (see termcap(5)) backgammon ``fixes'' the board after each move, so the board does not
need to be reprinted, unless the screen suffers some horrendous malady. Also, any `p' option will be ignored. (The `t' option is not neces-
sary unless the terminal type does not match the entry in the /usr/share/misc/termcap data base.)
QUICK REFERENCE
When the program prompts by typing only your color, type a space or carriage return to roll, or
d to double
p to print the board
q to quit
s to save the game for later
When the program prompts with 'Move:', type
p to print the board
q to quit
s to save the game
or a move, which is a sequence of
s-f move from s to f
s/r move one man on s the roll r separated by commas or spaces and ending with a newline. Available abbreviations are
s-f1-f2
means s-f1,f1-f2
s/r1r2 means s/r1,s/r2
Use b for bar and h for home, or 0 or 25 as appropriate.
AUTHOR
Alan Char
FILES
/usr/games/teachgammon rules and tutorial
/usr/share/misc/termcap terminal capabilities
BUGS
The program's strategy needs much work.
BSD
May 31, 1993 BSD