Page 1 of 1

Tic Tac Toe solutions in newlisp

Posted: Tue May 06, 2008 8:36 pm
by duncanbojangles
Hello. I've played with Scheme before coming to newlisp and to test out newlisp I wrote a program to find all the possible moves in a 3x3 tic tac toe game in a mostly functional manner. In an effort to learn more about newlisp I was wondering if anyone had any other tic tac toe or similar solvers written in a different style.

If anyone wants, I can post the code I have to this thread. Also, I stored the moves in a giant nested list, where each nest of the list represents all the possible next moves of the parent list.

Code: Select all

(parent
    (child
        (child child))
    (child
        (child
            (child child child))
        child)))
There's a little more to it, but that's the gist of it. The file that contains this list is 14 megabytes!

Posted: Tue May 06, 2008 9:08 pm
by cormullion
Hi there! Hope you're enjoying newLISP.

It could be an interesting challenge - perhaps I'll take you up on it soon. I haven't done TicTacToe, but I did do a basic version of Othello/Reversi, which isn't a million miles away from TTT:

http://unbalanced-parentheses.nfshost.c ... si.lsp.txt

Although I'm not sure that calculating every possible move is desirable... (he said provocatively) :)

Posted: Thu May 08, 2008 6:59 am
by pjot
Yes, but it is kind of ugly (but it works). I tried to do something with AI but this was before the (bayes) stuff entered the language. Anyway for your reference:

http://www.turtle.dds.nl/newlisp/tictactoe.lsp


Peter