Author Topic: Chess Game...  (Read 1972 times)

0 Members and 1 Guest are viewing this topic.

Offline jamortTopic starter

  • Supreme Robot
  • *****
  • Posts: 375
  • Helpful? 2
Chess Game...
« on: June 27, 2009, 02:04:55 AM »
I'm in the middle of making and AI chess program in c++ and thought if you can program a chess game to beat a world chess champion what would happen if two computers play each other... with the same software... would they eventually crash?
my english teacher once said, "dont talk about what you dont know in public...."

so I replied the truth, " Exactly why I dont ever talk about English."

Offline SmAsH

  • Supreme Robot
  • *****
  • Posts: 3,959
  • Helpful? 75
  • SoR's Locale Electronics Nut.
Re: Chess Game...
« Reply #1 on: June 27, 2009, 02:11:31 AM »
maybe, you would guess they would keep going and going and maybe just get into a stalemate?
Howdy

Offline jamortTopic starter

  • Supreme Robot
  • *****
  • Posts: 375
  • Helpful? 2
Re: Chess Game...
« Reply #2 on: June 27, 2009, 02:27:34 AM »
I would think that if one were to get put into check it would keep processing looking for a way out and i know if you do a forever loop it can cause a computer to crash... it would be an interesting thing to see.. id google it but im busy coding
my english teacher once said, "dont talk about what you dont know in public...."

so I replied the truth, " Exactly why I dont ever talk about English."

Offline SmAsH

  • Supreme Robot
  • *****
  • Posts: 3,959
  • Helpful? 75
  • SoR's Locale Electronics Nut.
Re: Chess Game...
« Reply #3 on: June 27, 2009, 02:40:21 AM »
maybe, but probably unlikely to crash...
Howdy

Offline jamortTopic starter

  • Supreme Robot
  • *****
  • Posts: 375
  • Helpful? 2
Re: Chess Game...
« Reply #4 on: June 27, 2009, 06:27:30 AM »
I would think it would get over ran with data... because it would probably keep processing the same things over and over again
my english teacher once said, "dont talk about what you dont know in public...."

so I replied the truth, " Exactly why I dont ever talk about English."

Offline SmAsH

  • Supreme Robot
  • *****
  • Posts: 3,959
  • Helpful? 75
  • SoR's Locale Electronics Nut.
Re: Chess Game...
« Reply #5 on: June 27, 2009, 06:28:56 AM »
most microcontrollers do this anyway... similar to a loop?
Howdy

Offline jamortTopic starter

  • Supreme Robot
  • *****
  • Posts: 375
  • Helpful? 2
Re: Chess Game...
« Reply #6 on: June 27, 2009, 06:50:18 AM »
yeah a loop that will never b tre so it keeps backing up data and i think it could cause a computer to crash IF left long enough.... because its like having this (not sure if you know c++

Code: [Select]
#include <iostream>

using namespace std;

int main()
{
    int n;
    for(n = 0; n < 100; n--){
          cout<< n << "\n";
}
}
its not a lot of data at first but with time it would start to get to be a lot
my english teacher once said, "dont talk about what you dont know in public...."

so I replied the truth, " Exactly why I dont ever talk about English."

Offline chelmi

  • Supreme Robot
  • *****
  • Posts: 496
  • Helpful? 15
Re: Chess Game...
« Reply #7 on: June 27, 2009, 09:25:34 AM »
yeah a loop that will never b tre so it keeps backing up data and i think it could cause a computer to crash IF left long enough.... because its like having this (not sure if you know c++

Code: [Select]
#include <iostream>

using namespace std;

int main()
{
    int n;
    for(n = 0; n < 100; n--){
          cout<< n << "\n";
}
}
its not a lot of data at first but with time it would start to get to be a lot


Depends on what you call a crash. To me a crash is a hardware exception, a trap...
This is just a strange loop: you start at 0 and decrement. Since n is an integer, it will be negative first. The loop condition is still valid until you hit -2^(32-1) and then it will be positive and equal to (2^32)-1. The condition will be invalid and the loop will stop.

Anyway, an infinite loop by itself is not a problem. Most of your code on a microcontroller is probably inside an infinite loop. What is bad is an "out of control" loop. Like a loop that allocates memory without freeing it, or a loop that write outside the boundaries of an array and trash data everywhere, ... this will eventually cause a crash.

Regarding your initial question, it really depends on the kind of algorithm you use. I am neither a chess player nor an AI specialist, but I would guess that they would reach a point where none of them can win (is it possible with chess?) and the will continue to repeat the same pattern of move forever (called a livelock in computer science). Even if they reach a livelock, and if your program is well designed (I'm sure it is ;) ), it should not crash! Another possibility would be that who wins will only depend on who was the first to move a piece.

Actually, I guess you will have to take a decision a some point in the game, like choose between several moves that are all valid and appear to be equally "clever" at this stage of the game. If you take a random choice in this case then on of your AI could choose a "not so clever" and lose the game. If you always take the same choice it could lead to the situations I mentioned above.

Hope this help!

Chelmi.

Offline jamortTopic starter

  • Supreme Robot
  • *****
  • Posts: 375
  • Helpful? 2
Re: Chess Game...
« Reply #8 on: June 27, 2009, 01:33:37 PM »
yeah i got an example of one that will crash a computer... its batch coding if you just but say open file and but a label and goto command that will make a computer crash...
I'm still in a lot of the pseudo code stages... and brushing up on classes and so forth never really used that will robotic AI
my english teacher once said, "dont talk about what you dont know in public...."

so I replied the truth, " Exactly why I dont ever talk about English."

Offline mdmedlin

  • Full Member
  • ***
  • Posts: 73
  • Helpful? 1
Re: Chess Game...
« Reply #9 on: June 28, 2009, 04:05:00 AM »
I think that a smart program would be one with a recursive algorithm.  One that starts with every possible move (if that were possible) and narrows it down to one move that it will make.  Now because these two computers are programmed with the same library of chess possibilities, eventually, I believe that there will be a point in the recurssion that they will take seperate paths that will lead to the move they will make.  I don't think that the computer will crash, but at first it may take a while for them to figure out the first moves as the program goes through its recurssive process.
Do or do not, there is no try yes I changed my picture, it is of my daughter.

Offline jamortTopic starter

  • Supreme Robot
  • *****
  • Posts: 375
  • Helpful? 2
Re: Chess Game...
« Reply #10 on: June 28, 2009, 11:00:22 AM »
Ive though up some psuedo code and for the beggining like 3 moves when i play chess if I match the other players first three moves it normally ticks them off so im going to do that..

then when it gets moving it checks to see what players can take out what hen makes a list of the rank they hold on the board and the cross checks if  the piece moved can be can be took out after that move... I'm trying to come up with a math problem to figure that out
just dpnt have it worked out...
my english teacher once said, "dont talk about what you dont know in public...."

so I replied the truth, " Exactly why I dont ever talk about English."

 


Get Your Ad Here