147

A proper solution would probably be some learned/statistical model, but here are some fun ideas: Semi-colons at the end of a line. This alone would catch a whole bunch of languages. Parentheses directly following text with no space to separate it: myFunc() A dot or arrow between two words: foo.bar = ptr->val Presence of curly braces, brackets: while (...


54

I would be curious to see what are the average metrics of written English on one side, and code on the other side. length of paragraphs length of lines size of words chars used ratio between alphabetic, numeric and other symbol characters number of symbols per word etc. Maybe that alone could discriminate already between code and the rest. At least I ...


30

My personal opinion is that it was due to hubris. There were some mighty big egos walking the halls of MIT, Stanford, etc. back in the 60s and 70s and they just knew they had cracked this problem. Right. Although I wasn't part of that universe in those days, in the mid-to-late 80s I was working with similarity searching. Our work was initially based on ...


25

I took an introduction to AI course in my undergrad that used Prolog to have us implement an expert system. An expert system is a piece of software that is used to solve a very specific problem whose solution is dependent on a high number of rules and variables. For instance, you could imagine an expert system that tells you whether you should take an ...


23

Typically, Markov chains are used to generate text, but they can also be used to predict the similarity of text (per C.E. Shannon 1950) to a trained model. I recommend multiple Markov chains. For each prevalent language, train a Markov chain on a large, representative sample of code in the language. Then, for a Stack Overflow post for which you want to ...


23

The AI course I participated in online, taught at Stanford, recommended that Python be used for the homework. I believe Georgia Tech still uses LISP. The fallacy here is "new" is "good". AI research is one of the oldest computing research disciplines. It keeps calving off subfields as people realize that techniques from it can be used elsewhere. Language ...


19

Sounds like you're talking about Genetic Algorithms more-so than Genetic Programming, but here's my contribution to your understanding. It can be handy to think of GAs in terms of the parts that they are composed of. So let's say you have some sort of problem. The first thing you need is a way to express what a solution will look like. If you had a ...


19

From the preface to Prolog Programming for Artificial Intelligence: Prolog is a programming language centred around a small set of basic mechanisms, including pattern matching, tree-based data structuring and automatic backtracking. This small set constitutes a surprisingly powerful and flexible programming framework. Prolog is especially well suited for ...


17

Quite simply, they massively underestimated the scale of the problem at hand, especially where combinatinatorial explosion is concerned. Many AI solutions work fine for "toy" samples, but fail hard when they scale up to human-level problems. Arguably, they were also simply inexperienced. AI as a field had (relatively) only just been invented in terms of ...


15

The difference is a bit like using SQL for database queries rather than writing a program in, say, C. In SQL, you say what you want - but you don't (directly) have to specify the algorithm used to derive it. A Prolog program is sometimes called a database, but it's really a set of predicate logic statements. The evaluation mechanism takes the query and ...


15

I can think of a couple of reasons. AI experienced such rapid success with some of the toy problems tackled in the late 50s and early 60s, that they overestimated what they had accomplished. ELIZA and SHRDLU stunned folks despite being relatively simple programs. Unfortunately, a large part of what made those programs stunning was really just novelty. ...


15

To answer just your title, yes. Neural nets can give non-boolean answers. For example, neural nets have been used to predict stock market values, which is a numeric answer and thus more than just yes/no. Neural nets are also used in handwriting recognition, in which the output can be one of a whole range of characters - the whole alphabet, the numbers, and ...


15

Joel actually answered this one a few years back. The actual meaning of "teach a machine how to program by itself" is "teach a machine how to take a spec and create a program that corresponds to that spec." And with that in mind: The problem, here, is very fundamental. In order to mechanically prove that a program corresponds to some spec, the spec ...


14

Since Tic-Tac-Toe is a solved game, I would recommend simply playing a perfect game every time. The following algorithm will allow you (or the AI) to always deny your opponent victory: Win: If you have two in a row, you can place a third to get three in a row. Block: If the opponent has two in a row, you must play the third to block the opponent. Fork: ...


13

May I suggest a radically different approach? On SO the only human-language allowed is English, so anything that is non-English has 99.9% of chances to be a code snippet. So my solution would be: use one of the many English language-checkers out there (just make sure they also signal - beside misspellings - syntax mistakes like double dots, or non-language ...


12

I think people in the 60's used their own human experience to divide problems into "hard problems" and "easy problems": Things like winning chess, solving logical riddles, solving mathematical equations seem hard to us humans. Things like understanding natural languages or finding the outlines of objects in an image seem easy, because our brain does all the ...


12

You could get both at the same time. Many schools have a CS bachelors degree with a math/science emphasis that, once you've taken the required math courses for the CS degree, will leave you only a few courses away from the double major in math.


11

I think there're clear rules on how cities are partitioned into quarters or regions. You should ask your local administration on where they draw the borders. Then you could, for example, retrieve the location data of the address (latitude and longitude might work) and simply check in which region's boundaries this address is in. There's no need for a ...


11

I'm probably going to get a few down votes for this but I think you are approaching this from the wrong angle. This line got me: people have to go in and manually format code for people that are somehow unable to figure this out IMO that standpoint is kind of arrogant. I find this a lot in software design where programmers and designers get annoyed ...


11

Pseudo code would pose a real challenge because all programming language depend on special characters like '[]', ';', '()', etc. Simply count the occurrence of these special characters. Just like you would detect a binary file (more than 5% of a sample contains byte value 0).


11

AI has a long history of disappointments, but I think many critics often over-simplify what happened, such as with your quote "1960's engineers overpromised and underdelivered". In the 60's, AI was the domain of a relative handful of researchers (the field wasn't really sufficiently developed yet to call it engineering), mostly at universities, and very few ...


11

Your example sounds similar to Bridge. Top Bridge-playing systems use Monte Carlo methods to select moves. At a high level: Determine the probabilities of each card being in a given hand. You know with certainty which cards are in your hand and which cards have been played. Determine the probability of all other cards based on cards that have been played ...


11

First of all, it seems to me you are missing (or perhaps misunderstanding) the "explicitly" bit in "without being explicitly programmed" (from the quote in the question). It doesn't mean that no programming is required at all, it means that you are not programming a specific solution to the problem, but instead what you are making is a more general program ...


11

I wish to write a chess AI which simulates the way I think over the board, using C++. Awesome! My focus is on writing the algorithms for choosing moves (decision making), not defining the board and pieces. Er, huh? To my knowledge, most chess programs written to date are focused on taking advantage of the computer's calculating powers Well yes, ...


10

"The best algorithm to achieve this"? Define "best". A simple A* algorithm will generate the most efficient possible path for an enemy to take to reach the player, but would you really want to play against a perfect computer? That's a recipe for frustration right there. The Pac-Man "AI" was actually 4 very simple algorithms that told the 4 ghosts where ...


9

So you want the human to have a chance to win? Then play the move that blocks a winning line, or if there isn't one, play a move at random. Perhaps weight the centre for 3 and the corners for 2, with the edges at 1, but if what you want is an opponent you can beat, you don't want to be to clever. Obviously, the AI should play a winning move if there is one....


9

Take a look at n-grams. One n-gram is a sequence of n words. In your case you want n to be 3, since you need two query words and a resulting word. One 3-gram would be for example "I am tired", another one "I am happy". What you then need is a collection of these 3-grams that are collected over your target language, say English. Since you cannot collect it ...


9

Off the top of my head, the very classic, must-read, heavy book that will help you throughout your AI experience : Artificial Intelligence, A Modern Approach. Don't be scared by the size, this book is trying to explore multiple kinds of AI, and the authors warn that the reading of the entire book will need nearly a 2-semester period. If you want to focus on ...


8

The heart of Watson is IBM DeepQA software. We find some answers on it's FAQ: Q: What data is stored in Watson? A: All of Watson's data will be self-contained. Watson will perform without a connection to the web or any external resource. The vast majority of Watson's data will be a wide variety of natural language text. Some structured (...


Only top voted, non community-wiki answers of a minimum length are eligible