I've written Tic-tac-toe in hypercube 4x4x4x4 in pure C

Discuss interdimensional programming, Java applets and so forth.

I've written Tic-tac-toe in hypercube 4x4x4x4 in pure C

Postby MorgothV8 » Fri Feb 20, 2009 2:05 pm

Hi all, I've written game tic-tac-toe in a pure-C (using only console output), this can be compiled on Windows, UNIX, DOS and so on
It only uses scanf() to get user input
Display is text-like,
where
XXXX
XXXX = @ is a single 2D wall, and wall are tiled, that way
XXXX
XXXX

@@@@
@@@@ = meaning thay You see just 4x4x4x hypercube as 4x4 grid of 4x4 fields, simply 16x16 grid
@@@@
@@@@

You can play against computer AI or observe duel beetween two AI's
z - mark place
x - let CPU move
ki - Y+/- move
jl - Y+/- move
om - Z+/- move
un - V+/- move
Anytime 'h' gives help

Game is simple, and its heart is just one (commented) method:
heuristic_count_moves_to_win()
Inside this function, ale moves are described

Good luck!

here source_code - can be compiled by nearly all C compilers, example: gcc -o game game.c
link

Please don't embed entire source files in code tags - upload the file (for example on TI Share as I have) and provide a link. I also cleaned up your indentation, and merged these posts - you can use the "edit" button at the top right of a post to add more info. ~Keiji

Oh and few tips
The game reads commands as letter+ENTER, for example:
l<ENTER> moves You left (x++)
z<ENTER> marks your move on current position
x<ENTER> makes that CPU is moving instead You in Your turn and then again normal CPU

This is because I'm using scanf() to get command, I could use some getch() but it is platform-specific, for example in conio.h in M$windows or in <termios.h> in UNIX, using only ordinary scanf makes it run on (I've tested)
Windows with Visual2003, Cygwin on Windows, Gcc on Solaris, Linux, FreeBSD (also 64bit)

To compile it, save as: game.c, launch command-prompt:
sh# gcc -O2 -Wall -o tttgame game.c
then
sh# ./tttgame

Try it and tell me if You like it.

Licencing: NONE
Do with this game and its source whatever You want.
MorgothV8
Mononian
 
Posts: 8
Joined: Fri Feb 20, 2009 1:57 pm

Return to Programming

Who is online

Users browsing this forum: No registered users and 8 guests

cron