Is a rule-based system that learns considered reinforcement learning? - artificial-intelligence

I'm reading a book, "AI for Game Developers" by Glenn Seemann and David M Bourg, where they use video game AI as an example of a rule-based system which learns.
Essentially, the player has 3 possible moves, and hits in combos of three strikes. The AI is aiming to predict the player's third strikes. The rules of the system are all the possible 3-move combinations. Each rule has a "weight" associated to it. Every time the system guesses incorrectly, the weight of a rule is decreased. When the system has to pick a rule, it picks the rule with the highest weight.
How is this any different from a reinforcement-learning based system? Thanks!

Yes, this is reinforcement learning in the established use of the term. You may run into some opposition from those doing active research today, as the "hot" portions deal with deep learning applications.
Your application has a well-defined game tree to search; you can direct the reinforcements with a mathematical structure that corresponds directly to the game. This is a machine learning application, along well-established learning algorithms.
Current "hot" research is working with more complex game situations in which the correspondence between an action and its result is not well-defined. These video games use DL networks rather than game trees in an effort to eventually discover the action rules that will lead to higher success. They're solidly in the DL part of AI, which is why you see a partitioning in the things you read.

Related

Decision making vs AI

I am doing a research about the difference between the decision making and the Artificial intelligence
How do these two subjects differ from one another? I didn't understand right now, are there a difference between these tow fields ? or one of them contains the other ?
One definition of AI is that it is about agents taking rational actions, where the definition of rational is context-dependent. In Artificial Intelligence: A Modern Approach (3rd edition), the authors say:
We define AI as the study of agents that receive percepts from the
environment and perform actions.
And later:
A rational agent is one that acts so as to achieve the best outcome or, when there is uncertainty, the best expected outcome.
Taking actions requires making decisions, and thus AI is about making rational decisions.
Of course, this doesn't mean that AI has a monopoly on decision making, as it is studied in business, psychology, and many other fields. But, with respect to your "decision tree" tag, decision trees are an AI technology for making decisions. (Decision trees are also usually learned from data.)

How mathematical is artificial intelligence as a focus?

Compared to mechanical engineering, computer engineering, or software engineering how do the mathematics compare? What should be mathematics that I should start focusing on learning now or should expect to learn if I want to become a researcher in the field or an industry expert? I am currently a senior in high school who is considering AI. Math doesn't scare me.
In AI one of the most important goals is to make computer act(and think!) like humans. For this purpose computers must learn models from observations(data) and act based on that model. This learning and prediction needs deep understanding of probability theory, statistics and stochastic processes as fundamental tools.
Today, probability and statistics are considered general mathematics like calculus and all undergraduate students are familiar with them, but you need to master them if your research field is in AI.
I would look into the following:
Probability - Bayesian Theory
Statistics - Data Interpretation, Graph Plotting, Graph Error Handling
Stochastic Theory
Entropy Theory (for finding degree of errant data)
Matrices and their computational formulae, use stochastic matrices
Since AI uses a lot of trees and graphs, a look into state space search and heuristic calculation would be quite useful..

Can "Monte-Carlo Tree Search" be applied on a "two player game with imperfect information" like Stratego?

I want to develop a two player game with imperfect information - "Stratego".
The game is "somewhat" like chess but initially we don't know anything about the ranks of the opponent's pieces. When a piece attacks or is attacked by some opponent's piece, their ranks are revealed and the higher rank piece kills/captures the lower rank piece.
More detail on the game can be found here.
I did a little research. I read "Opponent Modeling in Stratego" by J.A. Stankiewicz. But I couldn't find a complete tutorial on how to develop the game. I have successfully developed before a two player game - "Othello" a.k.a. Reversi, and I'm familiar with MINIMAX algorithm and alpha-beta pruning.
I found somewhere that Monte-Carlo Tree Search is also used in developing zero-sum two player games. Can it be used for games like stratego? Can I get a complete tutorial for the same?
Any other tutorial not involving Monte-Carlo Tree Search would also be useful :)
I think MCTS would have a difficult time in Stratego since the initial spreading function is so large while the best play is very dependent on the ground-truth of the game. That is to say, MCTS would, in the best case, give you a play that's statistically good amongst all the possible variations of your opponent's pieces, but the best next move is highly dependent on which particular variation they've chosen.
I'm still developing a solid understanding of MCTS, but it seems to me that MCTS does not do well in games where multi-round deceptive play involving hidden information is important (poker, canonically, but stratego, I would say, also). In such games, you really need to develop a model of the other player(s) situation/strategy and MCTS by its nature is going to give you an answer that is statistically related to all trees, not just the ground-truth tree.
MCTS works fine with games involving large amounts of chance (backgammon and other board games involving dice and many card games) and seems to me an excellent general-purpose solution that could be rapidly adopted to a large number of modern "European-style" board games. (The interesting thing with those is that although they involve "deceptive strategy" they generally involve relatively little hidden information.)
I don't know of any MCTS for incomplete information off the top of my had, and it seems like it would take substantial modification to the algorithm to get it to work.
Even in a very restricted type of Stratego where there are only ten pieces on each side, only two types of piece, and only one of the "stronger" piece, you're still playing one of ten possible actual games. In a full game of stratego there is far more uncertainty than that because of the large number of combinations of starting position, which all look alike.
It seems like you would also have to augment the algorithm to capture "revealed knowledge," as it happens, e.g., in our toy example, every encounter between pieces reveals some information about the enemy position.
It seems like it would be interesting to try, but only for a very restricted Stratego-like problem at first, and with the understanding that off the shelf MCTS is not sufficient and that you'd have to think carefully and deeply about the right extensions to the algorithm.

How do I pick a good representation for a board game tactic for a genetic algorithm?

For my bachelor's thesis I want to write a genetic algorithm that learns to play the game of Stratego (if you don't know this game, it's probably safe to assume I said chess). I haven't ever before done actual AI projects, so it's an eye-opener to see how little I actually know of implementing things.
The thing I'm stuck with is coming up with a good representation for an actual strategy. I'm probably making some thinking error, but some problems I encounter:
I don't assume you would have a representation containing a lot of
transitions between board positions, since that would just be
bruteforcing it, right?
What could branches of a decision tree look
like? Any representation I come up with don't have interchangeable
branches... If I were to use a bit string, which is apparently also
common, what would the bits represent?
Do I assign scores to the distance between certain pieces? How would I represent that?
I think I ought to know these things after three+ years of study, so I feel pretty stupid - this must look likeI have no clue at all. Still, any help or tips on what to Google would be appreciated!
I think, you could define a decision model and then try to optimize the parameters of that model. You can create multi-stage decision models also. I once did something similar for solving a dynamic dial-a-ride problem (paper here) by modeling it as a two stage linear decision problem. To give you an example, you could:
For each of your figures decide which one is to move next. Each figure is characterized by certain features derived from its position on the board, e.g. ability to make a score, danger, protecting x other figures, and so on. Each of these features can be combined (e.g. in a linear model, through a neural network, through a symbolic expression tree, a decision tree, ...) and give you a rank on which figure to act next with.
Acting with the figure you selected. Again there are a certain number of actions that can be taken, each has certain features. Again you can combine and rank them and one action will have the highest priority. This is the one you choose to perform.
The features you extract can be very simple or insanely complex, it's up to what you think will work best vs what takes how long to compute.
To evaluate and improve the quality of your decision model you can then simulate these decisions in several games against opponents and train the parameters of the model that combines these features to rank the moves (e.g. using a GA). This way you tune the model to win as many games as possible against the specified opponents. You can test the generality of that model by playing against opponents it has not seen before.
As Mathew Hall just said, you can use GP for this (if your model is a complex rule), but this is just one kind of model. In my case a linear combination of the weights did very well.
Btw, if you're interested we've also got a software on heuristic optimization which provides you with GA, GP and that stuff. It's called HeuristicLab. It's GPL and open source, but comes with a GUI (Windows). We've some Howto on how to evaluate the fitness function in an external program (data exchange using protocol buffers), so you can work on your simulation and your decision model and let the algorithms present in HeuristicLab optimize your parameters.
Vincent,
First, don't feel stupid. You've been (I infer) studying basic computer science for three years; now you're applying those basic techniques to something pretty specialized-- a particular application (Stratego) in a narrow field (artificial intelligence.)
Second, make sure your advisor fully understands the rules of Stratego. Stratego is played on a larger board, with more pieces (and more types of pieces) than chess. This gives it a vastly larger space of legal positions, and a vastly larger space of legal moves. It is also a game of hidden information, increasing the difficulty yet again. Your advisor may want to limit the scope of the project, e.g., concentrate on a variant with full observation. I don't know why you think this is simpler, except that the moves of the pieces are a little simpler.
Third, I think the right thing to do at first is to take a look at how games in general are handled in the field of AI. Russell and Norvig, chapters 3 (for general background) and 5 (for two player games) are pretty accessible and well-written. You'll see two basic ideas: One, that you're basically performing a huge search in a tree looking for a win, and two, that for any non-trivial game, the trees are too large, so you search to a certain depth and then cop out with a "board evaluation function" and look for one of those. I think your third bullet point is in this vein.
The board evaluation function is the magic, and probably a good candidate for using either a genetic algorithm, or a genetic program, either of which might be used in conjunction with a neural network. The basic idea is that you are trying to design (or evolve, actually) a function that takes as input a board position, and outputs a single number. Large numbers correspond to strong positions, and small numbers to weak positions. There is a famous paper by Chellapilla and Fogel showing how to do this for a game of Checkers:
http://library.natural-selection.com/Library/1999/Evolving_NN_Checkers.pdf
I think that's a great paper, tying three great strands of AI together: Adversarial search, genetic algorithms, and neural networks. It should give you some inspiration about how to represent your board, how to think about board evaluations, etc.
Be warned, though, that what you're trying to do is substantially more complex than Chellapilla and Fogel's work. That's okay-- it's 13 years later, after all, and you'll be at this for a while. You're still going to have a problem representing the board, because the AI player has imperfect knowledge of its opponent's state; initially, nothing is known but positions, but eventually as pieces are eliminated in conflict, one can start using First Order Logic or related techniques to start narrowing down individual pieces, and possibly even probabilistic methods to infer information about the whole set. (Some of these may be beyond the scope of an undergrad project.)
The fact you are having problems coming up with a representation for an actual strategy is not that surprising. In fact I would argue that it is the most challenging part of what you are attempting. Unfortunately, I haven't heard of Stratego so being a bit lazy I am going to assume you said chess.
The trouble is that a chess strategy is rather a complex thing. You suggest in your answer containing lots of transitions between board positions in the GA, but a chess board has more possible positions than the number of atoms in the universe this is clearly not going to work very well. What you will likely need to do is encode in the GA a series of weights/parameters that are attached to something that takes in the board position and fires out a move, I believe this is what you are hinting at in your second suggestion.
Probably the simplest suggestion would be to use some sort of generic function approximation like a neural network; Perceptrons or Radial Basis Functions are two possibilities. You can encode weights for the various nodes into the GA, although there are other fairly sound ways to train a neural network, see Backpropagation. You could perhaps encode the network structure instead/as well, this also has the advantage that I am pretty sure a fair amount of research has been done into developing neural networks with a genetic algorithm so you wouldn't be starting completely from scratch.
You still need to come up with how you are going to present the board to the neural network and interpret the result from it. Especially, with chess you would have to take note that a lot of moves will be illegal. It would be very beneficial if you could encode the board and interpret the result such that only legal moves are presented. I would suggest implementing the mechanics of the system and then playing around with different board representations to see what gives good results. A few ideas top of the head ideas to get you started could be, although I am not really convinced any of them are especially great ways to do this:
A bit string with all 64 squares one after another with a number presenting what is present in each square. Most obvious, but probably a rather bad representation as a lot of work will be required to filter out illegal moves.
A bit string with all 64 squares one after another with a number presenting what can move to each square. This has the advantage of embodying the covering concept of chess where you what to gain as much coverage of the board with your pieces as possible, but still has problems with illegal moves and dealing with friendly/enemy pieces.
A bit string with all 32 pieces one after another with a number presenting the location of that piece in each square.
In general though I would suggest that chess is rather a complex game to start with, I think it will be rather hard to get something playing to standard which is noticeably better than random. I don't know if Stratego is any simpler, but I would strongly suggest you opt for a fairly simple game. This will let you focus on getting the mechanics of the implementation correct and the representation of the game state.
Anyway hope that is of some help to you.
EDIT: As a quick addition it is worth looking into how standard chess AI's work, I believe most use some sort of Minimax system.
When you say "tactic", do you mean you want the GA to give you a general algorithm to play the game (i.e. evolve an AI) or do you want the game to use a GA to search the space of possible moves to generate a move at each turn?
If you want to do the former, then look into using Genetic programming (GP). You could try to use it to produce the best AI you can for a fixed tree size. JGAP already comes with support for GP as well. See the JGAP Robocode example for an instance of this. This approach does mean you need a domain specific language for a Stratego AI, so you'll need to think carefully how you expose the board and pieces to it.
Using GP means your fitness function can just be how well the AI does at a fixed number of pre-programmed games, but that requires a good AI player to start with (or a very patient human).
#DonAndre's answer is absolutely correct for movement. In general, problems involving state-based decisions are hard to model with GAs, requiring some form of GP (either explicit or, as #DonAndre suggested, trees that are essentially declarative programs).
A general Stratego player seems to me quite challenging, but if you have a reasonable Stratego playing program, "Setting up your Stratego board" would be an excellent GA problem. The initial positions of your pieces would be the phenotype and the outcome of the external Stratego-playing code would be the fitness. It is intuitively likely that random setups would be disadvantaged versus setups that have a few "good ideas" and that small "good ideas" could be combined into fitter-and-fitter setups.
...
On the general problem of what a decision tree, even trying to come up with a simple example, I kept finding it hard to come up with a small enough example, but maybe in the case where you are evaluation whether to attack a same-ranked piece (which, IIRC destroys both you and the other piece?):
double locationNeed = aVeryComplexDecisionTree();
if(thatRank == thisRank){
double sacrificeWillingness = SACRIFICE_GENETIC_BASE; //Assume range 0.0 - 1.0
double sacrificeNeed = anotherComplexTree(); //0.0 - 1.0
double sacrificeInContext = sacrificeNeed * SACRIFICE_NEED_GENETIC_DISCOUNT; //0.0 - 1.0
if(sacrificeInContext > sacrificeNeed){
...OK, this piece is "willing" to sacrifice itself
One way or the other, the basic idea is that you'd still have a lot of coding of Stratego-play, you'd just be seeking places where you could insert parameters that would change the outcome. Here I had the idea of a "base" disposition to sacrifice itself (presumably higher in common pieces) and a "discount" genetically-determined parameter that would weight whether the piece would "accept or reject" the need for a sacrifice.

What is your idea for a good AI project for a group of undergraduates?

There are two courses: "AI" and "AI in Games" both 15 students for 15 weeks.
I want to keep them motivated and creative.
I know I want some kind of competition (obvious for the latter course).
Maybe something like Marathon Match or ICFP.
I will need good visualization, so it would be great if it already exist.
One idea was to write AI for "Battle of Wesnoth", but I guess it's to diverse / boring.
Another game of Go. But that's too hard.
What are your ideas?
It will be work in groups of 3 students for 15 weeks.
MIT hosts a competition called BattleCode.
BattleCode, is a real-time strategy
game. Two teams of robots roam the
screen managing resources and
attacking each other with different
kinds of weapons. However, in
BattleCode each robot functions
autonomously; under the hood it runs a
Java virtual machine loaded up with
its team's player program. Robots in
the game communicate by radio and must
work together to accomplish their
goals.
Teams of one to four students enter
are given the BattleCode software and
a specification of the game rules.
Each team develops a player program,
which will be run by each of their
robots during BattleCode matches.
Contestants often use artificial
intelligence, pathfinding, distributed
algorithms, and/or network
communications to write their player.
At the final tournaments, the
autonomous players are pitted against
each other in a dramatic head-to-head
tournament. The final rounds of the
MIT tournament are played out in front
of a live audience, with the top teams
receiving cash prizes.
(source: mit.edu)
BattleCode in action.
You essentially are given the BattleCode software from MIT and your students can program the AI for their robots. They have a test suite so you can practice running your autonomous bots on your own in a practice arena. Towards the end of the semester they can enter in MIT's Open Tournament, where they compete with their software AI robots against schools all over the nation. Up to $40,000 is given away in cash and prizes as well as bragging rights for winning.
If you are looking to teach them about AI, Pathfinding, Swarm Intelligence, etc. I can't think of a more fun way.
May the best AI bot win!
Wii gesture recognition using hidden markov models.
I wouldn't count out Go. It's computationally hard for Go AI to compete with top human players, but the simple rules of Go (compared to Chess) make it a relatively easy game to write AI for. Your students' programs only need to compete against each other, not against Dan level human players. See An Introduction to the Computer Go Field and Associated Internet Resources for a lot of Go programming resources.
I think it's a good idea to select a theme both challenging enough that it can't be completely solved, yet allows the user to see the value of it in the real world and not so much a toy problem. My suggestion would thus be:
Word segmentation problem (e.g. convert "iamaboy" to "i'am a boy")
Word sense disambiguation (e.g. "The apple is nice to eat" - The apple is a fruit or a company?)
Optical character recognition
What I just list down is some of the more basic stuff of natural language processing. If your students is much more technically inclined, you can probably take it to the next level and let them tackle the problem of machine translation.
Empire, it's addictive as whatever and there are open source D versions (1 and 2) and a not quite free c++ version .

Resources