• Advertisement
Sign in to follow this  

is there pre-programmed AI?

This topic is 2201 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

im using microsoft visual stuidio C#. and i can do very very simple AI like paper rock scissors. but for me writing something more complicated like a checkers game against computer is a ways away for me. is there pre-written AI i can use, or at least look at to kinda grasp how its written?

doesnt have to be complicated like some AI monster trying to kill you, hunt you... just something like checkers.

thank!

Share this post


Link to post
Share on other sites
Advertisement
Good luck finding one. AIs tend to be very specific to the games they're written for. Even generic AIs for well known games will require some adaptation to use your representation of the playfield.

Share this post


Link to post
Share on other sites
I don't think you'll find anything packaged and ready to be used, but you could learn about alpha-beta search and get something working in a couple of weeks.

If you want to do it, start by writing a class that represents the board, a class that represents a move, a function that performs a move on a board, a function that undoes a move on a board (this one is optional, and not very important if your board class is small and can be copied cheaply), a function that generates a list of available moves given a board, and a function that determines how good the board looks for white (start with something simple like 100*(number_of_white_pawnd - number_of_black_pawns) + 140*(number_of_white_kings - number_of_black_kings)). Then you'll have all the ingredients to implement a simple minimax search (use the negamax convention).

Now you'll have a really crappy AI that does play a game of checkers. There are many, many ways to improve your program:

  • Better evaluation function (really important)
  • Alpha-beta pruning (really important)
  • Move-ordering heuristics (e.g., killer moves, history heuristic)
  • Transposition tables (a.k.a. "hash tables")
  • Iterative deepening
  • Opening book
  • Endgame tablebase


    You can find a lot of information on chess programming online, and much of it applies to checkers as well.

    I spent most of my weekends between the ages of 17 and 23 programming a Spanish checkers program. Then I moved to chess, and I even started a go program a few years ago, but now I have a job, a wife, a kid, and not enough time for absorbing hobbies. :)

    Anyway, I highly recommend writing a checkers AI. You'll learn a ton of things along the way.

Share this post


Link to post
Share on other sites
There is no such thing as "an AI" in that sense.

There are only implementations of very specific AI techniques for playing very specific games. The techniques you use for playing Go are wildly different from Chess and different still from good Checkers implementations. Even though the games are all played with pieces on a grid, it's a totally different approach for each. Even Tic-Tac-Toe has different "good" AI implementations than Checkers, for instance.

As soon as you leave turn-based, two-player, pieces-on-a-board games, you enter a still different realm. Even turn-based strategy games like Civilization have totally different AI models once again.

Your best bet is to pick a type of AI to study, ideally based on a single game or game rule set, and learn from there. And of course if you want to take up FPS game AI afterwards, you're going to have to go back to square one and learn a bunch more different stuff.

Share this post


Link to post
Share on other sites
ok, so i gather if im going to be making ai for my games... i want to learn 1 type that im going to use, and none else?

Share this post


Link to post
Share on other sites
Not quite.

You want to start with one type. Learn that, and get used to it. Then you can go on and learn more.

The point I was trying to make is that you can't just "learn AI" and then write any old AI. Every game's AI is going to be very different.

Share this post


Link to post
Share on other sites
AI programming isn't exactly a beginner's topic. Focus on learning to program. Being distracted by problems you're not ready to handle does you no good.

Share this post


Link to post
Share on other sites

AI programming isn't exactly a beginner's topic. Focus on learning to program. Being distracted by problems you're not ready to handle does you no good.
ok thanks. ill keep learning the basics. but after a while ill put my self to the challenge of a checkers game. i think thats a good goal and would challenge me for sure, good for problem solving and such.

thanks all who helped on yet another top of mine :) :) :) i really do appreciate all the help i get on this forum! many thanks!

Share this post


Link to post
Share on other sites
You can always poke around sites like aigamedev.com and see what they have to offer, but don't be surprised if the concepts are beyond your level of experience (not that there's anything wrong with that). I agree that it's probably good to start small and work your way up. But a simple checkers AI is probably in reach, if you want to play with it; just google around for tutorials on checkers and search algorithms and you should get enough material to get going.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement