Sponsored Content
Full Discussion: Snake game challenge in UNIX
The Lounge What is on Your Mind? Snake game challenge in UNIX Post 302996301 by wisecracker on Monday 24th of April 2017 04:16:21 AM
Old 04-24-2017
Hi amit14august...
You must be using a bash version 4.x.x as it cannot be used on anything previous.
On OSX 10.12.4, DEFAULT bash terminal below occurs...
Code:
Last login: Sun Apr 23 09:13:49 on ttys000
AMIGA:amiga~> bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)
Copyright (C) 2007 Free Software Foundation, Inc.
AMIGA:amiga~> cd Desktop/Code/Shell
AMIGA:amiga~/Desktop/Code/Shell> ./snakegame.sh






Your green snake must stay away from pink ones

control : I = UP  J = LEFT  K = DOWN  L = RIGHT

 Game will start in 3 seconds


your score is : 1      top score is 1000
./snakegame.sh: line 283: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
                                             
                                             
                                             
                                             
                                             
                                             
@@@@@                                        
                                             
                                             
                        ***                  
                                             
                                             
                                             
                                             
                                             
./snakegame.sh: line 221: init_snake: bad array subscript
./snakegame.sh: line 222: init_snake: bad array subscript
./snakegame.sh: line 167: read: .025: invalid timeout specification
./snakegame.sh: line 88: [: -eq: unary operator expected
./snakegame.sh: line 95: init_helper_one: bad array subscript
./snakegame.sh: line 96: init_helper_one: bad array subscript
./snakegame.sh: line 100: 1 -  : syntax error: operand expected (error token is " ")
AMIGA:amiga~/Desktop/Code/Shell> _

So it is not backwards compatible.
To find your bash version:-
Code:
Last login: Mon Apr 24 07:15:34 on console
AMIGA:amiga~> bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)
Copyright (C) 2007 Free Software Foundation, Inc.
AMIGA:amiga~> _

It is not easy to include users who do not have versions of languages that you write for and possibly unable to upgrade to. So be aware when you write your code to state which version of language you are using as that helps the user to decide whether or not to run your code.
We all learn the hard way.
Good luck and keep up with the programming learning curve.
We look forwards to seeing more from you...

Bazza.
This User Gave Thanks to wisecracker For This Post:
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Loaded question - anyone up to the challenge?

Hello everyone. I am new to these forums and also new to Unix. And by saying "new to Unix" I mean I have never used it and 10 minutes ago was asked to start learning. So here I am. I was wondering if anyone could help me find out how long it would take to write code in Unix that will do the... (1 Reply)
Discussion started by: idesaj
1 Replies

2. UNIX for Dummies Questions & Answers

UNIX 'adventure'/game.

Hi there.. I know this is a kind low question, but do anyone know where I can find some hints and or clues for the "adventure" game on UNIX ? ( /usr/games/adventure ). I already searched on this forum but didnt find the answer to my question. Thanks a lot.... (3 Replies)
Discussion started by: TARFU
3 Replies

3. UNIX for Advanced & Expert Users

safeword challenge

Hi, there are some servers here at work which issue a Safeword challenge after I login. Can anyone tell me exactly how the challenge/response system works? In particular, how are the valid keys decided? (2 Replies)
Discussion started by: blowtorch
2 Replies

4. Shell Programming and Scripting

AWK Challenge

I have the following text Microsoft iSCSI Initiator version 2.0 Build 3497 Targets List: iqn.2001-05.com.equallogic:0-8a0906-daef43402-138000002a4477ba-grsrv12-extra iqn.2001-05.com.equallogic:0-8a0906-986f43402-520000002b447951-exchange ... (9 Replies)
Discussion started by: netmedic
9 Replies

5. Shell Programming and Scripting

regex challenge

Here's a regex substitution operation that has stumped me with sed: How do you convert lines like this: first.key ?{x.y.z} second.key ?{xa.ys.zz.s} third.key ?{xa.k} to: first.key ?{x_y_z} second.key ?{xa_ys_zz_s} third.key ?{xa_k} So i'm basically converting all the... (11 Replies)
Discussion started by: neked
11 Replies

6. Shell Programming and Scripting

PS1 challenge

Ok then i Have a challenge for you : Give me PS1 so that it always display the least 2 levels of directory (except if i am above of course) I want it this way : so if i go to / /home/ /home/user /home/user/whatever /home/user/whatever1/whatever2 my PS1 should respectively... (12 Replies)
Discussion started by: ctsgnb
12 Replies

7. UNIX for Dummies Questions & Answers

Touch Challenge

I've been given a directory full of subdirectories full of logfiles of the same name: /logfiles/day1/file1/blockednodes.csv day1-14 file1-48 The above is the actual directory structure for 14 days worth of a logfile that is generated every 30 minutes. It's been done this way to preserve the... (15 Replies)
Discussion started by: Cludgie
15 Replies

8. Shell Programming and Scripting

Snake and ladder game

Hi, I am designing snake and ladder game in unix. I am writing my script in bash shell in Solaris version. This game is designed by me for which I would like to give access to two players. When these players execute the game, there should be communication between the three participants(game... (7 Replies)
Discussion started by: ayarlaga
7 Replies

9. Shell Programming and Scripting

Anyone like a challenge?

I have searched through google, and this forum to try and find the answer, but alas, nothing quite hits the whole answer. I am trying to read the last line (or lines) of some log files. I do this often. The files are named sequentially, using the date as part of the file name, and appending... (18 Replies)
Discussion started by: BatterBits
18 Replies
DM.CONF(5)						      BSD File Formats Manual							DM.CONF(5)

NAME
dm.conf -- dungeon master configuration file DESCRIPTION
The dm.conf file is the configuration file for the dm(8) program. It consists of lines beginning with one of three keywords, badtty, game, and time. All other lines are ignored. Any tty listed after the keyword badtty may not have games played on it. Entries consist of two white-space separated fields: the string badtty and the ttyname as returned by ttyname(3). For example, to keep the uucp dialout, ``tty19'', from being used for games, the entry would be: badtty /dev/tty19 Any day/hour combination listed after the keyword time will disallow games during those hours. Entries consist of four white-space separated fields: the string time, the unabbreviated day of the week and the beginning and ending time of a period of the day when games may not be played. The time fields are in a 0 based, 24-hour clock. For example, the following entry allows games playing before 8AM and after 5PM on Mondays: time Monday 8 17 Any game listed after the keyword game will set parameters for a specific game. Entries consist of five white-space separated fields: the keyword game, the name of a game, the highest system load average at which the game may be played, the maximum users allowed if the game is to be played, and the priority at which the game is to be run. Any of these fields may start with a non-numeric character, resulting in no game limitation or priority based on that field. The game default controls the settings for any game not otherwise listed, and must be the last game entry in the file. Priorities may not be negative. For example, the following entries limits the game ``hack'' to running only when the system has 10 or less users and a load aver- age of 5 or less; all other games may be run any time the system has 15 or less users. game hack 5 10 * game default * 15 * FILES
/etc/dm.conf The dm(8) configuration file. SEE ALSO
setpriority(2), ttyname(3), dm(8) BSD
May 31, 1993 BSD
All times are GMT -4. The time now is 12:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy