You are not logged in.

#1 2006-01-08 05:28:25

Shofs
Member
From: Central Illinois
Registered: 2004-12-15
Posts: 184

My tic-tac-toe program sucks

If anyone has any interest, please look at this code and tell me what is wrong with it.

It is supposed to play tic tac toe perfectly, it does not.

I attempted to use the negamax algorithm.

Please post any specific changes you made.

Thanks.

Offline

#2 2006-01-08 22:47:08

Shofs
Member
From: Central Illinois
Registered: 2004-12-15
Posts: 184

Re: My tic-tac-toe program sucks

UPDATE: I fixed something, it just doesn't play quite as I would expect.  I think that is a problem that it a property of my algorithim.
You see, it doesn't choose the same move for all the different rotations when there is symmetry involved, which sort of makes sense to me.

All and all though, you should be able to compile this and play it just fine . . . I think.

Offline

#3 2006-01-13 20:01:48

gzaector
Member
From: WV
Registered: 2004-11-14
Posts: 10
Website

Re: My tic-tac-toe program sucks

/* This doesn't seem to work, there is always at least 1 cmd line arg for some reason
    if (argc != 0)
    { printf ("WARNING: %d command line arguement(s) ignored!n", argc); }
    else
    { printf ("TEST"); }
*/

The reason why there is always at least one command line argument is because the name of the executable is counted.

For example, if you ran your program like this:

./tic-tac-toe foo bar

Then:

argc == 3
argv[0] == tic-tac-toe
argv[1] == foo
argv[2] == bar

-gz


yes | /dev/mem

Offline

#4 2006-01-13 21:04:27

Shofs
Member
From: Central Illinois
Registered: 2004-12-15
Posts: 184

Re: My tic-tac-toe program sucks

gzaector wrote:

The reason why there is always at least one command line argument is because the name of the executable is counted.

For example, if you ran your program like this:

./tic-tac-toe foo bar

Then:

argc == 3
argv[0] == tic-tac-toe
argv[1] == foo
argv[2] == bar

-gz


Thanks, I did not know that until now.

Offline

#5 2006-01-14 00:12:34

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: My tic-tac-toe program sucks

gzaector wrote:

For example, if you ran your program like this:

./tic-tac-toe foo bar

Then:

argc == 3
argv[0] == tic-tac-toe
argv[1] == foo
argv[2] == bar

Technically, it'd be the full command line:

foo/tic-tac-toe
argc == 1
argv[0] == "foo/tic-tac-toe"

In your example, argv[0] would ne "./tic-tac-toe"

Offline

Board footer

Powered by FluxBB