280 likes | 474 Views
An Overview of Game Theory. by Kian Mirjalali. What kind of game is mentioned in our discussion?. There are two players A and B . Assume that A always starts the game (for convenience only). In each turn, one of them plays and the turns are alternative.
E N D
An Overview ofGame Theory by Kian Mirjalali
What kind of game is mentioned in our discussion? • There are two players A and B. • Assume that A always starts the game (for convenience only). • In each turn, one of them plays and the turns are alternative. • A and B are opponents (They play against each other).
Usual properties of our games: • The game is finite. • There is no factor of randomization (such as dice or coin). • The loser is the one who cannot move anymore. • We assume these properties to be true unless otherwise specified.
What we are usually supposed to do: • Predict who is the winner (according to the initial state of the game). • Give a winning strategy for the winner. • Helpful assumption : • The players are very clever and do their best moves to win the game.
Some simple games • GRAFGAME.EXE • A famous Game of stones: • There are n stones. • Each player has to take off k stones in his turn, which 1≤ k ≤ r (for some predefined value of r).
Who is the winner in the second game? • Let’s solve it for r=1. • Obvious result: • If n is even then B wins. • If n is odd then A wins. • No strategy is needed for winning!
Solution for the second game (continue): • How about r=2 ? • Let’s make a winner table: • Result: • B wins if and only if n is a multiple of 3.
Solution for the second game (continue): • What about the strategy? • If n is a multiple of 3, then the winning strategy for B, is to make the number of stones, dividable by 3, after A’s moves. • If n is not a multiple of 3, then the winning strategy for A, is to make the number of stones, dividable by 3, in the first move, and then acting just like B in a 3∣n game.
General Solution for the second game: • A similar rule holds for larger values of r: • B wins if and only if n is a multiple of r+1.
General Solution for the second game: • And a similar strategy can be used for winning: • If n is a multiple of r+1, then the winning strategy for B, is to make the number of stones dividable by r+1 again after A’s moves. • If n is not a multiple of r+1, then the winning strategy for A, is to make the number of stones dividable by r+1 in the first move, and then acting just like B in a (r+1)∣n game.
State Graph • Place a vertex for each state. • Connect vertex u to vertex v with a directed edge, if and only if the game can go from the state equivalent to u, to the state equivalent to v, in a single move.
An Example of State Graph • An example of state graph for the latter game is below (for n=9 and r=3):
Using state graphs to find the winners: • We apply the method for the example above (n=9 and r=3). • Starting with the vertices of final states and going up backward while finding the winners. B A A A B A A A B A
General method to find the winners: v A • Consider the available moves in the state of vertex v: • If there was an edge leading to a B-marked vertex: • mark v with A. • Otherwise: • mark v with B. A A B ? ? ? v B A A A A A A
Special notes • The state graph is a DAG, in finite games. (why?) • We can mark the vertices of this DAG (with A or B) in the reverse order of its topological sorting. • There is a single source equivalent to the initial state of the game. Its label shows the winner of the main game.
Special notes (continue) • The method of marking the vertices is just like a dynamic algorithm. • We can use the memoized method to mark the vertices (just like any other dynamic algorithm). • We can use the state graph also in order to obtain a winning strategy.
Special notes (continue) • The winner always moves from an A-marked vertex state to a B-marked one. • The loser always has no way but moving from a B-marked vertex state to an A-marked one.
Special notes (continue) • In the final states (which are sinks in the DAG) B-marked vertices are losing states and A-marked vertices are winning states. • The memoized algorithm works just like a post-order traversal.
An important problem • What should we do if the number of the states is too many to be stored in memory? • Examples : • Chess • Reversi • Checkers
An important problem (continue) • The answer is just the answer to the same problem in dynamic algorithms: • We have to use Back-Tracking. • We have to sacrifice time for memory.
More problems • What if Back-Tracking was a too slow algorithm due to the number of the states?
More problems (answer) • It’s in this moment when all hope for a fast deterministic algorithm has faded. • We can no longer go as deep as the vertices of final states. • We have to use a new method. Not always leading to win but doing nearly the best moves in each turn.
A new method • We don’t put A and B labels on vertices any more. Instead, we assign a real value to each vertex. • It’s something like probability to win the game. The more this value is, the more it’s probable for us to win the game. • A winning state vertex is assigned the value of +∞ (and vise versa).
A new method (continue) • We start the Back-Tracking just like a simple one, but as we reach an appropriate depth (not too shallow resulting in bad moves and not too deep resulting in long runtimes), we stop going down and use a heuristic function to evaluate the assigned value to the current vertex.
A new method (continue) • The better the heuristic function works, the better the algorithm selects its moves. • The value assigned to upper vertices is specified according to these two principles: • Our player tries to maximize the assigned value. • The opponent tries to minimize it.
A new method (continue) • An optimization method: • α-β-pruning. • It’s mentioned in DA courses.
Bye Bye sentences • It was just an overview of the game theory. • You can see many interesting puzzles about games. You can deal with them much better now. • Writing programs playing games is an enjoyable job. • Start it right now (of course after the DA seminars): select a famous game and write its program. You won’t regret that!
An open problem: Find a good heuristic function for the game of life.