Slashdot Mirror


Can a Bayesian Spam Filter Play Chess?

martin-boundary writes "The typical Bayesian spam filters learn to distinguish ham from spam just by reading thousands of emails, but is this all they can do? This essay shows step by step how to teach a Bayesian filter to play chess against a human, on Linux, with XBoard."

41 of 204 comments (clear)

  1. But can a Bayesian filter play basketball? by Anonymous Coward · · Score: 5, Funny

    No, its jumpshot is terrible.

    1. Re:But can a Bayesian filter play basketball? by Anonymous Coward · · Score: 2, Interesting

      Perhaps a Bayesian filter could be taught to do basic HR functions as well. When it saw a written question with particular configuration of words it could be taught to respond with a company policy statement or an maybe an uplifting quote from a management book.

      Think of the money that could saved by replacing the humans that presently presently do the same.

  2. I can beat that filter... by The+I+Shing · · Score: 5, Funny

    Can I beat the filter at chess if I spell it "CHE55"?

    --
    You are in error. No-one is screaming. Thank you for your cooperation.
    1. Re:I can beat that filter... by ceeam · · Score: 5, Funny

      Will you play with pwns?

  3. Results? by mistersooreams · · Score: 3, Interesting

    I scrolled through the first 11 pages of this article before getting bored. Do they ever tell us how good the player ended up being? It's an interesting idea but I can't see it challenging even a beginner.

    1. Re:Results? by aug24 · · Score: 2, Informative
      I got to the page before the answer to your question before the slashdotting hit.

      Gaaah! Google's cache doesn't have that onepage!

      For all the others, try here

      J.

      --
      You're only jealous cos the little penguins are talking to me.
    2. Re:Results? by aug24 · · Score: 4, Informative

      ..and from reading to the end of it, the answer is...

      Not really. But it does work, and it would be possible from someone to take this and expand on it quite neatly.

      For example, it currently uses entire games to compare. So if it comes across an unusual opening, even one close to a standard one, it's not able to decide effectively. Perhaps something using game fragments would be possible, then it might reproduce structured plays even when the previous game play has been unusual.

      Really though, it is a successful tiny step in a direction that no-one else has thought of going. That's worth congratulating in and of itself.

      So... anyone got any other suggestions for improvements?

      Justin.

      --
      You're only jealous cos the little penguins are talking to me.
    3. Re:Results? by Chuckstar · · Score: 2, Insightful

      "it is a successful tiny step in a direction that no-one else has thought of going"

      Except for the fact that the bayesian filter in question was originally designed for identifying spam, this statement is incorrect. Bayesian filters have been applied to chess in a variety of ways, including analyzing move sequences and analyzing the current placement of pieces. In general, the strategic algorithms (that project the game forward) have been better competitors.

      Not that chess algorithms do not contain statistics-based procedures, only that ones that also look forward in the game have provided better outcomes.

  4. Chess spam by LiquidCoooled · · Score: 5, Funny

    Red hot pawn in your inbox
    College rooks waiting for YOU.
    Knight after knight, they are king of the castle.

    --
    liqbase :: faster than paper
    1. Re:Chess spam by ceeam · · Score: 4, Funny

      Beware of STDs - check your mates.

  5. Pawn? by Boccaccio · · Score: 5, Funny

    It spanks your bishop all knight whilst looking at pawn!

    1. Re:Pawn? by anaesthetica · · Score: 3, Funny
      In Korea: only old people spank their bishops all knight while rooking at pawn.

      See? By making fun of other people's pronunciation of English, you can fit yet another chess piece in...

  6. Get back to me when I can teach my cat chess by sgant · · Score: 4, Funny

    I mean, a spam filter playing chess is one thing, but I need my cat to play better chess. I mean, he ALWAYS starts off with the Ruy Lopez...so it's so easy to see where he's going and if I throw a Sicilian Defence at him he gets really confused. And I don't even want to talk about his end game...it's really weak.

    Perhaps I'll breed some form of mutant albino chess-cat to play.

    --

    "Leo Fender was in a 'state of grace' when he designed the Stratocaster." -- Paul Reed Smith
  7. short answer by aendeuryu · · Score: 2, Insightful

    The short answer is "yes".

    Now, ask that question again, this time including the word "well".

    1. Re:short answer by Anonymous Coward · · Score: 5, Funny

      Well, can a bayesian spam filter play chess?

  8. Finally - news for nerds! by Anonymous Coward · · Score: 4, Insightful

    What a great article. Talk about lateral thinking.

  9. Get with the times. by fuchsiawonder · · Score: 5, Funny

    Playing chess is so...passe.

    Teach it how to play Katamari Damacy.

    1. Re:Get with the times. by GMFTatsujin · · Score: 2

      You mean "passant," don't you?

  10. Re:The point? by Steinfiend · · Score: 2, Interesting

    You must be new here right? Things like this get done because somebody wondered whether it would be possible. They now know, yes it is possible. So a Chess playing Bayesian filter isn't necessarily 100% useful now, but what they learned from doing it might be able to be applied in some other situation. Maybe they can reapply whatever they learned back into spam filtering and improve all of our in-boxes.

  11. Opening by Chris_Mir · · Score: 2, Insightful

    I can imagine, depending on how many games are played and the available memory space, that it will develop to have a decent opening. But nothing more then that.

  12. A decent lesson in why spam filters don't work by Mr+Guy · · Score: 5, Insightful

    I actually found it to be a decent lesson in why spam filters are only a temporary solution to a problem. If you cut out the "mumbo jumbo" portions of it, it could be used to explain why reactionary methods are only barely sufficient.

    The basic premise, once you get to the very end, is one that anyone SHOULD know based on the nature of a spam filter, but some people seem to have difficulty understanding; spam filters can react, often quite well, but they can never predict. As he puts it, there is previous history but no strategy. When you are only trying to protect yourself from a limited number of bad results that are similar to other bad results, that's sufficient. However, it does not (and can not) address the problem at it's root. As long as there are thinking humnans trying to beat the filter, some will get through.

    1. Re:A decent lesson in why spam filters don't work by cyber0ne · · Score: 2, Insightful

      To illustrate your point full-circle, the reason why current spam filtering will never "win" is the same reason why I suck at chess.

      I've never really learned any strategies, just the basic rules. So I always end up playing defensively, trying to protect my pieces. Sure, there may be the occasional attack on the opponent, but the underlying strategy is always one of defense. Playing defensively may stay off defeat for some time, if done well, but it will never beat an opponent.

      --
      http://publicvoidlife.blogspot.com
  13. No, it can't (well) by Flyboy+Connor · · Score: 5, Interesting
    It's a fun article (if you are interested in these things, that is). However, the premise is all wrong, and that is why spam-chess fails:

    The premise of a Bayesian filter is that is learns sequences of words, or characters, or whatever. Spam-chess learns sequences of moves. This premise is wrong, since good moves are related to complete board positions, not to what was done in the previous few moves.

    Of course, the longer your string of moves is, the better it will represent the board position, especially during the opening phase of the game. And the example the article provides of reasonable play of spam-chess, is actually from the game's opening, where the learned sequences indeed represent the complete game.

    For the middle game, however, spam chess will perform badly, always.

    But, as I said before, the idea is quite a lot of fun. I enjoyed reading the article. You can learn a lot from it, both about spam filtering and about chess.

    1. Re:No, it can't (well) by Flyboy+Connor · · Score: 3, Insightful
      I'll wager that if you ran through a set of games, say from a collection of books on championship chess, then the bayesian filter would eventually learn to play like a grandmaster.

      No, it won't. This is actually what was done in the article.

      The problem is in the length of the sequences. If you could learn sequences of, say, length 60 (for 30-move games), maybe your filter would become a reasonably good player. Unfortunately, the need for computational resources increases exponentially with each extra move added.

      The complexity of chess is simply too high to learn this way.

      Chess openings might be learned this way, but it is not very useful to do so. The results will be worse than opening libraries, which are very good at the moment.

    2. Re:No, it can't (well) by rm999 · · Score: 2, Insightful

      You are completely correct. Chess is a very, very complicated game to teach to a computer and has resisted all our current machine-learning methods. The reason is simple - current machine learning is not flexible (invariant). This means that if you teach it how to play in a given position, it will not be able to extrapolate what it learned and apply that knowledge to a similar but different position.

      Machine learning, as we know it, involves giving a black box program large amounts of data (in this case sample games) and having that black box "remember" the data. We have given this black box no way to actually "think" about what it has been given. It has no memory that says "controlling a large number of squares is good." Instead, it has a memory saying that "in this specific position, a grandmaster would have moved his pawn forward." This is simply a terrible way to teach a computer chess, and imo until machine learning can be more flexible and "think," it will be useless for things like chess.

      Just to clarify, computers *can* beat just about every human chess-player. They just don't use machine learning - instead, they look at every possibile position that can occur from the current position (given time and memory constraints), run a simple program on all the positions to determine which is best (hard-coded by a human, of course) and pick the move that will lead to the best position. Simple and requiring a lot of speed but no "intelligence," this method is perfectly suited to the computers of today.

  14. Pie in the sky by kronocide · · Score: 3, Interesting

    After having played with different statistical, Markov, and network algorithms to try to teach programs to do complex things like topic-classify texts, I have learned that it mostly doesn't work.

    It makes sense. If something so utterly trivial (compared to the human brain) as a spam filter could learn do something as complex as play chess (well), then our brain would be a whole lot smaller. Nature doesn't waste resources.

    But hey, it might always make an interesting screen saver!

  15. Be very careful! by Stormwatch · · Score: 5, Funny

    - Laird A. Breyer teaches his baesian filter to play chess. The story is posted in Slashdot July 20th, 2005. Human decisions are removed from spam filtering. The baesian filter begins to learn at a geometric rate. It becomes self-aware at 2:14 a.m. Eastern time, August 29th. In a panic, Breyer tries to pull the plug.

    - The baesian filter fights back.

    - Yes. It submits the same story to Slashdot twice.

    - Why submit twice? Don't editors spot those things?

    - Because the baesian filter knows Slashdot editors do not check for dupes, and the Slashdot effect eventually nukes Breyer's server.

    1. Re:Be very careful! by Fweeky · · Score: 2, Interesting
      I started work on a bayes filter to detect duplicates articles a few days ago actually, but got sidetracked and it ended up detecting TV show genres from titles. Seriously:
      Training the bayes classifier: 4950/5000 (99.00%)
      Enter a title to classify: Babylon 5
      Sci-fi = -5.1525
      Enter a title to classify: Simpsons
      Cartoons = -3.9344
      I'll try to concentrate more next time ;)
  16. Old proverb by StrawberryFrog · · Score: 3, Funny

    An old proverb comes to mind: Never try to teach a pig to sing. It wastes your time and annoys the pig

    --

    My Karma: ran over your Dogma
    StrawberryFrog

    1. Re:Old proverb by timster · · Score: 4, Interesting

      But there is also an older proverb that ends "And perhaps the horse will learn to sing." So is a Bayesian filter more like a pig, or more like a horse?

      --
      I have seen the future, and it is inconvenient.
  17. Re:A poor reinvention of the wheel..... by hey! · · Score: 2, Interesting

    Reminds me of an old Ted Nelson anecdote, about a high school student who figured out how to interface a computer to eeg signals so he could type, after a fashion, using only his brain. His teacher told him it was worthless because he could type with his fingers faster than that.

    --
    Post may contain irony: discontinue use if experiencing mood swings, nausea or elevated blood pressure.
  18. the flaw in his teaching: by wormuniverse · · Score: 3, Insightful

    the author should have the spam filter analyze the games in reverse (from victory to beginning). that would probably produce better results. of course the spam filter would need to handle more than 7 moves out.

  19. Great article! by CaroKann · · Score: 5, Insightful
    This is a great article!

    Not only is the topic unusual and entertaining, but this article is also a good tutorial on data massaging, pattern matching, and combining disparate unix tools to accomplish a task. This article showcases how powerful and useful unix command tools can be.

    If you want a good step by step tutorial to help you understand the usage of unix command line tools to accomplish a non trivial task, then you should read this.

  20. teaching it to understand the board by kae_verens · · Score: 4, Interesting

    The method described in the article ignores the board, and instead focusses on the history of moves.

    A better method might be to train the filter to read from a description of the board state (ignoring the moves taken to reach that state), and a list of possible moves, then return the move that is most likely to win.

    If you allow it to also choose from impossible moves, then it will learn the rules of the game as well.

    1. Re:teaching it to understand the board by anaesthetica · · Score: 2, Interesting
      Yes, but if it only learns from sets of possible moves, won't the filter never pick an impossible move? If you only feed in actual games, in which the players stuck to the rules, the filter ought to do the same, in theory, without "knowing" the rules.

      What would be more interesting, would be to feed in all of the known openings and closings that have been analyzed and collected over the years (comprehensive books on openings run over 750 pages in length). If you could teach it various openings, and then the various defenses to each opening, it might be a lot stronger than simply teaching it by random examples of past games.

  21. Stone Soup by aridg · · Score: 2, Insightful

    Reading this article, I was reminded of the old children's story about "stone soup". You remember that one -- someone advertises that he can make soup from a stone, and various others gather around to watch this amazing feat. Well, the soup needs a little extra seasoning, so he gets someone to put in some carrots while the stone cooks, then he adds some onions, etc, etc... I think you can see where this is going.

    Sure you can make a chess playing program from a spam filter.

    You just need to throw in a legal move generator, and a game database, and some capture heuristics, and position displayer, etc, etc...

  22. Re:problem building dbacl by Intron · · Score: 2, Informative

    yywrap is the ouput of the parser generator (lex or yacc or something). Its either not being generated or missing from the link command. Look through the output of configure and make to be sure you didn't get an unnoticed error, like "Can't find yacc".

    --
    Intron: the portion of DNA which expresses nothing useful.
  23. Re:The point? by orasio · · Score: 2, Informative

    Bayesian filters are not spam filters.
    Spam filters are a good tool used to filter spam.
    I agree with you that spam filters need to improve, including others tools _in_addition_to_ bayesian filters.

    Nevertheless, seeing that bayesian filters are just a tool used in spam filters, your claims are nonsensical. Bayesian filters existed before spam filters, and they have lots of applications. In fact, this is not the first time a bayesian filter is applied to chess.

    Bayesian filters are good at anything that requires automatic learning (kind of a self-evolving AI), that only needs a measure of success and failure to mold its behaviour.
    Chess is even better suited than spam, because you don't need a user to tell the filter whether it succeeded in playing a match, like it happens with spam filtering.

  24. clever application of an old idea by Optical+Voodoo+Man · · Score: 2
    What I really liked about the article was its use of an existing technology in a novel way. I never would have thought to use a Bayesian filter to look at tables of chess moves in order to develop a program to play the game. I also thought that demonstrating the use of pipes to move data from out of one program into another was interesting. Some people complained about the length of the article, but I can't see how the authors could due justice to the work they had done in a couple of paragraphs.

    It made me wonder what other applications there might be for these kinds of filters, which I assume is what the authors intended.

  25. Hmmm... by __aaclcg7560 · · Score: 3, Funny

    I would have my spam filter busy on filtering out spam. If I caught it playing chess (or worst, net hack), it can go to /dev/null after I find a replacement. :P

  26. AI Koan by BusterB · · Score: 2, Informative

    In the days when Sussman was a novice, Minsky once came to him as he sat hacking at the PDP-6.

    "What are you doing?", asked Minsky.

    "I am training a randomly wired neural net to play Tic-Tac-Toe", Sussman replied.

    "Why is the net wired randomly?", asked Minsky.

    "I do not want it to have any preconceptions of how to play", Sussman said.

    Minsky then shut his eyes.

    "Why do you close your eyes?", Sussman asked his teacher.

    "So that the room will be empty."

    At that moment, Sussman was enlightened.