Automated Turing Test Passer

I've written a program that can pass the Turing Test 100% of the time. It's very simple. I can't believe no-one has thought of this before.

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
34
35
36
#include <fstream>
#include <iostream>
#include <string>

int line_of(const std::string& string, std::ifstream& file)
{
    std::string line;
    for (int number = 0; ; ++number) {
        std::getline(file, line);
        if (line == string)
            return number;
    }
    return -1;
}

void print_line(std::ifstream& file, int number)
{
    std::string line;
    for (int i = 0; i < number; ++i)
        std::getline(file, line);
    std::getline(file, line);
    std::cout << line << std::endl;
}

int main()
{
    while (true) {
        std::ifstream questions("questions.txt"), answers("answers.txt");
        std::string input;
        std::cout << "Ask me a question: " << std::flush;
        std::getline(std::cin, input);
        int number = line_of(input, questions);
        print_line(answers, number);
    }
    return 0;
}

The contents of the files "questions.txt" (every possible question) and "answers.txt" (every possible answer) are left as an exercise to the reader.

I have skipped out error checking. If you get a wrong answer or an infinite loop it just means that your questions.txt or answers.txt are insufficient. The program is 100% correct.
Last edited on
What about questions that have different answers, like "What time it is?"
"What did I just ask you?"
If any question isn't in the questions.txt file or any answer isn't in the answers.txt file, or the answer is wrong, then the files are wrong, the program is still 100% correct. It can always pass the Turing test given correct data.
There doesn't exist a set of correct data. While the statement
It can always pass the Turing test given correct data.
is true, the statement
I've written a program that can pass the Turing Test 100% of the time.
is not.
helios wrote:
There doesn't exist a set of correct data

It is my view that this is a failure of the data, not a failure of the program.
It is my view that this is a failure of the data, not a failure of the program.

Hmm, doesn't the program fail because of the data?
No, the data produced by the program fails because of the data.
So it is the data which fails to pass the Turing test?
Yes. The data fails to convince the human that it came from another human. The program would succeed if the data was correct.

[edit]
I've come up with an even shorter one:
1
2
3
4
5
6
7
8
9
#include <iostream>

int main()
{
    std::cout << "I'm not mad at you." << std::endl;
    while (true)
        std::cin.get();
    return 0;
}

This one simulates a human female.
Last edited on
The program would succeed if the data was correct.

I thought you said the program never fails.
It is my view that this is a failure of the data, not a failure of the program.
The program is correct in the sense that it correctly implements this informal specification:
pre: input contains answers to every possible Turing test
post: output contains the answers for the Turing test in the input
It's incorrect in the sense that the specification doesn't properly describe the problem of passing every possible Turing test, so no program that implements it will pass every possible Turing test.
Last edited on
@Catfish3
Okay, let me revise that statement to this: The program never fails on its own merits, it only fails as a result of erroneous input. But the same can be said of any program for which there exists a distinction between valid and invalid input - garbage in, garbage out.

@helios
It would if the data were correct. I know you say that the data can't ever be correct, but that's not a failure of the program, that's a failure of god to provide a universe where a set of all possible data can exist.
Last edited on
but that's not a failure of the program
Like I said, the program is correct. The specification is not.
If I asked you to specify and write a program that tests if a number is prime and you do this:
1
2
3
4
5
6
7
8
/*
problem is_prime(n: Int) = result: Bool{
    ensures: result == (n%2 != 0);
}
*/
bool is_prime(int n){
    return n%2;
}
the program is correct and can be proven to be correct, but you still didn't do what I asked you to do.
But the universe doesn't allow for the specification to be correct, so it's not the specification that fails, but the universe.
Topic archived. No new replies allowed.