Friday, April 25, 2008

Displaying chess board on the screen


Small Chess Board


#!/bin/bash
# SCRIPT : smallchessboard.sh
# PURPOSE : Prints small chess board on the screen.

clear
for (( i=1 ; i<=8 ; i++ ))
do

for (( j=1 ; j<=8 ; j++ ))
do

if [ `expr $(($i+$j)) % 2` -eq 0 ]
then
echo -e -n "\033[47m " # White background
else
echo -e -n "\033[40m " # Black background
fi

done
echo # move to next line

done

echo -e "\033[0m" # Restores color settings.


OUTPUT:


Big Chess Board


#!/bin/bash
# SCRIPT : bigchessboard.sh
# PURPOSE : Prints big chess board on the screen.

clear
a=4

for (( i=1 ; i<=8; i++ ))
do

for (( j=1 ;j<=2; j++ )) # prints same line twice
do
tput cup $a 15 # moves cursor to LINE COLUMN

for (( k=1 ; k<=8; k++ ))
do

c=`expr $((i+k)) % 2`

if [ $c -eq 0 ]
then
echo -e -n "\033[40m " # Black background
else
echo -e -n "\033[47m " # White background
fi

done
let a=a+1

done

done

echo -e "\033[0m" # Restores color settings
read key # Waits for enter


OUTPUT:


14 comments:

  1. nice one...
    but still change are better.



    #!/bin/sh

    for m in `seq 8` ### Outer for loop ###
    do
    for n in `seq 8` ### Inner for loop ###
    do
    T=`expr $m + $n`
    S=`expr $T % 2`
    if [ $S -eq 0 ]; then
    echo -e -n "\033[47m " ### white ###
    else
    echo -e -n "\033[40m " ### black ###
    fi
    done
    echo -e -n "\033[40m" #### background colour=black ###
    echo "" #### printing new line ###
    done

    ReplyDelete
  2. Can you please anybody explain clearly. I am unable to write it.

    ReplyDelete
  3. In this article I'm going to uncover abilities essential for Internet showcasing achievement, including what to keep away from. Effective Internet advertising isn't just about the "do"s." It's likewise about the don'ts. I will examine both in connection to how to profit on the web, beneath. http://www.mordocrosswords.com/2016/09/chessboard-piece.html

    ReplyDelete
  4. Wonderful article,does chess improve programming skills thanks for putting this together! This is obviously one great post. Thanks for the valuable information and insights you have so provided here.

    ReplyDelete
  5. Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for. chess sets

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.
    big-data-hadoop-training-institute-in-bangalore

    ReplyDelete
  8. I prefer to read the quality content. I like it.

    ReplyDelete
  9. I got too much interesting stuff on your blog. I guess I am not the only one having all the enjoyment here! Keep up the good work. Best Glass Chess Sets

    ReplyDelete
  10. DevOps career opportunities are thriving worldwide. DevOps was featured as one of the 11 best jobs in America for 2017, according to CBS News, and data from Payscale.com shows that DevOps Managers earn as much as $122,234 per year, with DevOps engineers making as much as $151,461. DevOps jobs are the third-highest tech role ranked by employer demand on Indeed.com but have the second-highest talent deficit

    Are you seeing DevOps in your future? Perhaps you are already exploring where to start learning DevOps, choose myTectra the market leader in Devops training.
    CHAPTER 2: UNDERSTAND COMMON INFRASTRUCTURE SERVERS
    CHAPTER 3: IMPLEMENT AUTOMATED INSTALLATIONS AND DEPLOYMENTS
    CHAPTER 4: UNDERSTAND PERFORMANCE TUNING ASPECTS AND BASIC SECURITY FOR INFRASTRUCTURE
    CHAPTER 5: INSTALLATION & CONFIGURATION OF JENKINS AND PUPPET
    CHAPTER 6: INTRODUCTION TO AUTOMATION WITH ANSIBLE AND SALTSTACK
    CHAPTER 7: AUTOMATION WITH CHEF
    CHAPTER 8: MONITORING, LOGGING, TOMCAT AND SYSTEM TOOLS

    ReplyDelete
  11. Really your post is really very good and I appreciate it. It’s hard to sort the good from the bad sometimes.You definitely put a new spin on a topic thats been written about for years.
    webnovel

    ReplyDelete