Sponsored Content
Full Discussion: Snake and ladder game
Top Forums Shell Programming and Scripting Snake and ladder game Post 302837783 by Don Cragun on Friday 26th of July 2013 05:24:02 PM
Old 07-26-2013
Quote:
Originally Posted by rbatte1
... ... ...

How are you planing to roll the dice? Might I suggest something like:-
Code:
rndm_num=$RANDOM                     # Only refer to this once.
((test_val=$rndm_num/6))             # Will truncate to integer
((test_val=$test_val*6))             # Will give nearest lower multiple of 6
((dice_val=$rndm_num-$test_val+1))   # Will give score between 1 & 6

... ... ...

Robin
A slightly simpler way to do that is:
Code:
((dice_val = $RANDOM % 6 + 1))

This User Gave Thanks to Don Cragun For This Post:
 

4 More Discussions You Might Find Interesting

1. What is on Your Mind?

Game: Name this person

Simple rules... 1. Guess who it is, the first person to get it posts the next picture, post your guess as a reply to this thread. 2. Wait for the person who posted the picture to confirm that you are correct before posting a new picture. 3. If the person who posted the picture does not answer... (268 Replies)
Discussion started by: reborg
268 Replies

2. Programming

Tetris Game in C++

Open Source Project: https://github.com/yongye/cpp Ported from the shell: Shell (0 Replies)
Discussion started by: complex.invoke
0 Replies

3. What is on Your Mind?

Snake game challenge in UNIX

Hey Guys, I have made this basic snake game but it a little bit different from conventional snake game. Learned some basics of Unix. Hope you enjoy playing it. Please download and run on your machine and suggest any changes i can make. and let me know if someone could score 1000 points ;) ... (2 Replies)
Discussion started by: amit14august
2 Replies

4. UNIX for Beginners Questions & Answers

Word ladder Problem

Perl - Script Rules In a Word Ladder: Players get a starting word and an ending word Starting and ending words must be the same length (PIG and HOG, or CAT and DOG) Players change one letter at a time, attempting to move from the starting word to the ending word Each intermediate step... (1 Reply)
Discussion started by: asak
1 Replies
IRSEND(1)								FSF								 IRSEND(1)

NAME
irsend - basic LIRC program to send infra-red commands SYNOPSIS
irsend [options] DIRECTIVE REMOTE CODE [CODE...] DESCRIPTION
Asks the lircd daemon to send one or more CIR (Consumer Infra-Red) commands. This is intended for remote control of electronic devices such as TV boxes, HiFi sets, etc. DIRECTIVE can be: SEND_ONCE - send CODE [CODE ...] once SEND_START - start repeating CODE SEND_STOP - stop repeating CODE LIST - list configured remote items SET_TRANSMITTERS - set transmitters NUM [NUM ...] SIMULATE - simulate IR event REMOTE is the name of a remote, as described in the lircd configuration file. CODE is the name of a remote control key of REMOTE, as it appears in the lircd configuration file. NUM is the transmitter number of the hardware device. For the LIST DIRECTIVE, REMOTE and/or CODE can be empty: LIST "" "" - list all configured remote names LIST REMOTE "" - list all codes of REMOTE LIST REMOTE CODE - list only CODE of REMOTE The SIMULATE command only works if it has been explicitly enabled in lircd. -h --help display usage summary -v --version display version -d --device use given lircd socket [/var/run/lirc/lircd] -a --address=host[:port] connect to lircd at this address -# --count=n send command n times EXAMPLES
irsend LIST DenonTuner "" irsend SEND_ONCE DenonTuner PROG-SCAN irsend SEND_ONCE OnkyoAmpli VOL-UP VOL-UP VOL-UP VOL-UP irsend SEND_START OnkyoAmpli VOL-DOWN ; sleep 3 irsend SEND_STOP OnkyoAmpli VOL-DOWN irsend SET_TRANSMITTERS 1 irsend SET_TRANSMITTERS 1 3 4 irsend SIMULATE "0000000000000476 00 OK TECHNISAT_ST3004S" FILES
/etc/lirc/lircd.conf Default lircd configuration file. It should contain all the remotes, their infra-red codes and the corresponding timing and wave- form details. DIAGNOSTICS
If lircd is not running (or /var/run/lirc/lircd lacks write permissions) irsend aborts with the following diagnostics: "irsend: could not connect to socket" "irsend: Connection refused" (or "Permission denied"). SEE ALSO
The documentation for lirc is maintained as html pages. They are located under html/ in the documentation directory. lircd(8), mode2(1), smode2(1), xmode2(1), irrecord(1), irw(1), http://www.lirc.org. irsend 0.8.7pre1 May 2010 IRSEND(1)
All times are GMT -4. The time now is 10:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy