How can I show the elephant's path in the chess by c++

Jun 18, 2008 at 7:01am
Hello
How can I show the elephant's path in the chess by c++, but the user enters the coordinates of elephant.
thank you.
Jun 18, 2008 at 10:45am
What's the Elephant's path?

int main
Jun 18, 2008 at 6:50pm
It's the path the elephant takes :P
How does the existence of this elephant relate to chess?
Jun 18, 2008 at 6:58pm
I've been googling this off and on all day, and AFAIKT the word "elephant" is some sort of insider joke with AI people...

? :-\
Jun 18, 2008 at 7:00pm
Really? I'd hate to break this to you; but it's actually a quite large land mammal. Lives in Africa, India and the likes. http://en.wikipedia.org/wiki/Elephant

:P
Jun 18, 2008 at 7:41pm
Oh.

Are they any good at chess? :-P
Jun 18, 2008 at 7:44pm
I don't know, Never played one. They must be fairly good if they want to track their movement/path through a game though.
Jun 18, 2008 at 8:04pm
closed account (z05DSL3A)
Surly the path would be easy to see, just look for the blumin' big foot prints.
Jun 18, 2008 at 8:26pm
At least two different chess pieces could be referred to as an elephant. A piece that got to be called bishop was represented as an elephant in ancient chess and is still called so in Persian (pīl) and Russian (slon). Modern Hindi uses elephant (haathi) for a rook.

http://en.wikipedia.org/wiki/Bishop_%28chess%29
http://en.wikipedia.org/wiki/Descriptive_chess_notation
Jun 18, 2008 at 9:44pm
Spoil Sport :P

ramishama: http://www.cplusplus.com/forum/articles/1295/
I suggest you read that, and alter, or re-post your question.
Jun 19, 2008 at 12:04am
Whew. I was wondering what would happen if the elephant lost. :-)
Jun 19, 2008 at 3:12am
this is a picture to show how the elephant walk at the chess board.
the squire in any color is the elephant position and the lines in the same colors is its path.
not that the chess board is 8*8.
http://www.khadoori.com/forum/uploaded/3_01213849287.jpg



and this is the program :
but it need complete
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void main()
{
int x,y;
cout<<"Enter the position of the elephant in the chess:\nX-axis: ";
cin>>x
cout<<"\nY-axis: ";
cin>>y;
if (x<0 || x>8 || y<0 || y>8)
cout<<"Erorr!!!";
else
{



}

}
Last edited on Jun 19, 2008 at 3:14am
Jun 19, 2008 at 8:44am
Ah, so the Elephant is what we call the Bishop.

You'll have to watch your bounds on line 8. The chessboard, from the user's point of view, is 1..8, not 0..8. Once you get the input, then transform the input to 0..7 to match your 'computer chessboard'.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
int main()
  {
  int x, y;
  // Get (x,y) from user
  cout << "Enter the position of the elephant in the chess:\nX-axis (1-8): ";
  cin >> x;
  cout << "\nY-axis (1-8): ";
  cin >> y;

  // Make sure (x,y) are correct.
  if (x<1 || x>8 || y<1 || y>8)
    {
    cout << "Error!!!\n";
    return 0;
    }

  // Adjust (x,y) to fit in range [0,7]
  x = x-1;
  y = y-1;

  // Now, the chess board is 0..7, 0..7
  //   0 1 2 3 4 5 6 7
  // 0 . . . . . . . .
  // 1 . . . . . . . *  'E' is the position of the Elephant if the user entered 6,4 --> 5,3  
  // 2 * . . . . . * .  '*' is where it can move
  // 3 . * . . . * . .
  // 4 . . * . * . . .
  // 5 . . . E . . . .  So, how do you want to display this information?
  // 6 . . * . * . . .
  // 7 . * . . . * . .

  return 0;
  }
Last edited on Jun 19, 2008 at 8:44am
Jun 20, 2008 at 12:59pm
Thank you,
Now I need program to print in the screen this:
the screen:

1
2
3
4
5
6
7
              *
*           *  
  *       *    
    *   *      
      *        
    *   *      
  *       *         

Last edited on Jun 20, 2008 at 1:00pm
Jun 20, 2008 at 5:59pm
Use a couple of loops. One for each line, and a loop inside that one for the column.
1
2
3
4
5
6
7
8
9
10
11
for (int row = 0; row < 8; row++)
  {
  // do stuff here?

  for (int column = 0; column < 8; column++)
    {
    // do stuff here?
    }

  // do stuff here?
  }


Good luck!
Jun 20, 2008 at 6:18pm
I know thats i have to use this type of loops, but how can i make the stuff??
Jun 20, 2008 at 9:59pm
Don't demand.

At this point, you'll have to figure it out yourself. We won't just give you the answer.

It helps to get out a piece of graph paper and a pencil and pretend you are the computer filling in the squares (or characters).

Good luck!
Jul 27, 2008 at 3:13am
Not to obstreperously resurrect old threads, but I learned why those elephants are so hard to track down.

http://www.netspace.org/~dmacks/pub/lists/catching-elephants.html

:-)
Topic archived. No new replies allowed.