![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Nov 2005
Location: Estonia
Posts: 94
Rep Power: 0
![]() |
Another tic tac toe
http://commodore.gran.ee/tictactoe.zip
The "source" folder contains the python file which can also be ran on Linux. The tictactoe folder contains the windows executable (python and pygame are not needed). Currently the computer selects a square randomly (no AI). The plus is that the game is beatable (very, very easily) but the negative side is that I didn't learn anything from it . If someone gives me a tutorial for making AI for it I'll consider doing it.Press escape to leave the game. I suck but at least it doesn't have programmer art . |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
|
The only winning move is not to play
__________________
i dont know much about programming but i try to help |
|
|
|
|
|
#3 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Your AI could be as simple as blocking any opponent move which results in an immediate win for the opponent, and making any move which results in an immediate win for the machine. It could be as complex as a neural network whose weights are chosen by a genetic algorithm. Obviously you won't learn anything from it unless you work at it in one fashion or another.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Nov 2005
Location: Estonia
Posts: 94
Rep Power: 0
![]() |
I'm thinking of doing it with a game tree (if that's what they call it) because pathfinding algorithms and other stuff use it too.
|
|
|
|
|
|
#5 |
|
Professional Programmer
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 369
Rep Power: 0
![]() |
If even do a couple things that DaWei has suggested and cleaned up the AI, it would be a very slick tic-tac-toe game, very nice interface.
__________________
I am Addicted to Linux! |
|
|
|
|
|
#6 |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: UK
Posts: 213
Rep Power: 3
![]() |
Nice app chap, graphics are a lot better than the one I made thats for sure. look forward to seeing it with some smart AI.
![]() |
|
|
|
|
|
#7 |
|
Hobbyist Programmer
Join Date: Oct 2006
Posts: 203
Rep Power: 2
![]() |
AI for tic tac toe really wouldn't be that hard. There are a limited number of possible moves that can be made, and there is always a definite "best" choice (although there may be more than one choice that is equally good).
|
|
|
|
|
|
#8 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
I suspect the OP realizes that, but wonders HOW to instruct the machine to determine the "best" choice.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#9 | |
|
Hobbyist Programmer
|
Quote:
not sure if this is the best way, but here is probably how I would approach giving tic-tac-toe some AI. -The first check it will make at the beginning of every turn is to see if it has two in a row anywhere and if it could win. -if not it would check to see if you have two in a row anywhere so it can prevent you from winning. -if not it would check for two empty spots next to one it currently has placed on the board so it can set itself up. -if not then it would look for 3 empty spots on the board in a row so it could set itself up. Start out with something simple, get it working, and then refine it, test it, refine it some more, etc. I would probably then add difficulty levels which determine how often it has a chance to make a mistake, which would then be determined by some form of random number.
__________________
I have never let my schooling interfere with my education. -Mark Twain- Xbox live gamertag: melbolt |
|
|
|
|
|
|
#10 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Three previous shots and a discussion thread, among others. It's why there's a search box prominently displayed.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|