Othello heuristic

In competitive two-player games, the killer heuristic is a technique for improving the efficiency of alpha-beta pruningwhich in turn improves the efficiency of the minimax algorithm. This algorithm has an exponential search time to find the optimal next move, so general methods for speeding it up are very useful.

Barbara Liskov created the general heuristic to speed tree search in a computer program to play chess endgames for her Ph. Alpha-beta pruning works best when the best moves are considered first. This is because the best moves are the ones most likely to produce a cutoffa condition where the game playing program knows that the position it is considering could not possibly have resulted from best play by both sides and so need not be considered further.

1/2 data creazione documento: 15/11/2018 08:29 pagina 1 di 2

It only needs to consider the other player's possible responses to that best move, and can skip evaluation of responses to worse moves it will not make. The killer heuristic attempts to produce a cutoff by assuming that a move that produced a cutoff in another branch of the game tree at the same depth is likely to produce a cutoff in the present position, that is to say that a move that was a very good move from a different but possibly similar position might also be a good move in the present position.

By trying the killer move before other moves, a game playing program can often produce an early cutoff, saving itself the effort of considering or even generating all legal moves from a position. In practical implementation, game playing programs frequently keep track of two killer moves for each depth of the game tree greater than depth of 1 and see if either of these moves, if legal, produces a cutoff before the program generates and considers the rest of the possible moves.

If a non-killer move produces a cutoff, it replaces one of the two killer moves at its depth. This idea can be generalized into a set of refutation tables. A generalization of the killer heuristic is the history heuristic. The history heuristic can be implemented as a table that is indexed by some characteristic of the move, for example "from" and "to" squares or piece moving and the "to" square. This information is used when ordering moves.


Othello Heuristics

Unsourced material may be challenged and removed. Categories : Game artificial intelligence Heuristics Optimization algorithms and methods. Hidden categories: CS1 errors: missing periodical Articles needing additional references from April All articles needing additional references. Namespaces Article Talk. Views Read Edit View history. Languages Add links. By using this site, you agree to the Terms of Use and Privacy Policy.Othello is a turn-based two-player strategy board game.

Gienchi comode sneakers bianco uomo outlet

The players take turns placing pieces--one player white and the other player black--on an 8x8 board in such a way that captures some of the opponent's pieces, with the goal of finishing the game with more pieces of their color on the board.

Every move must capture one more more of the opponent's pieces.


To capture, player A places a piece adjacent to one of player B's pieces so that there is a straight line horizontal, vertical, or diagonal of adjacent pieces that begins with one of player A's pieces, continues with one more more of player B's pieces, and ends with one of player A's pieces. For example, if Black places a piece on square 5, 1he will capture all of Black's pieces between 5, 1 and 5, 6 :.

For more more information about the game which is also known as Reversi including detailed rules, see the entry on Wikipedia. Additionally, this implementation doesn't take into account some tournament-style Othello details, such as game time limits and a different indexing scheme.

We will implement representations for the board and pieces and the mechanics of playing a game. We will then explore several game-playing strategies.

There is a simple command-line program provided for playing against the computer or comparing two strategies. Written by Daniel Connelly. We represent the board as a element list, which includes each square on the board as well as the outside edge.

Each consecutive sublist of ten elements represents a single row, and each list element stores a piece. An initial board contains four pieces in the center:. The outside edge is marked? The black and white pieces represent the two players. We need functions to get moves from players, check to make sure that the moves are legal, apply the moves to the board, and detect when the game is over.

A move must be both valid and legal: it must refer to a real square, and it must form a bracket with another piece of the same color with pieces of the opposite color in between. Find a square that forms a bracket with square for player in the given direction. Returns None if no such square exists. A more sophisticated strategy could look at every available move and evaluate them in some way. This consists of getting a list of legal moves, applying each one to a copy of the board, and choosing the move that results in the "best" board.

Construct a strategy that chooses the best move by maximizing evaluate player, board over all boards resulting from legal moves.

One possible evaluation function is score. A strategy constructed with maximizer score will always make the move that results in the largest immediate gain in pieces. A more advanced evaluation function might consider the relative worth of each square on the board and weight the score by the value of the pieces held by each player.

Since corners and most edge squares are very valuable, we could weight those more heavily, and add negative weights to the squares that, if acquired, could lead to the opponent capturing the corners or edges.

Compute the difference between the sum of the weights of player's squares and the sum of the weights of opponent's squares. The maximizer strategies are very short-sighted, and a player who can consider the implications of a move several turns in advance could have a significant advantage.

The minimax algorithm does just that. Find the best legal move for player, searching to the specified depth.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

It only takes a minute to sign up. I understand that occupying the corners is desirable, as a counter placed there can never be flipped.

Also, placing a counter on a square next to a corner seems to be bad as it usually hands the corner to your opponent. In addition to trying your best not to allow your opponent to control edges and corners, trying to place in such a way that your opponent cannot play is a good tactic.

This is effective during the mid- and late-game.

othello heuristic

This tactic is as much about luck in your opponent's placement as it is about your vision in being able to accomplish this. Frequently, when you force them to miss a placement, there is another opportunity on your part to make them miss another, which can sometimes domino to 5 or 6 consecutive placements for you. This also gives you a large advantage since players continue to take turns if they can, so you will have placed more than your opponent over the course of the game.

Don't take edge spaces adjacent to opponent pieces. Your opponent can usually just capture them. There are rare times to do so, but those times usually are ones which allow capturing the corner. Sign up to join this community. The best answers are voted up and rise to the top.

Home Questions Tags Users Unanswered.

Friday the 13th remake google drive

Tactics for Othello Ask Question. Asked 7 years, 4 months ago. Active 7 years, 4 months ago. Viewed times. What other tactics are useful to know? Tom77 Tom77 4, 3 3 gold badges 19 19 silver badges 35 35 bronze badges. As it will allow your opponent to place in a space along the boards edge, which are hard to take.

Computer Othello

Active Oldest Votes. SocioMatt SocioMatt 7, 3 3 gold badges 25 25 silver badges 60 60 bronze badges. More broadly, though, IIRC even limiting the number of moves available to your opponent appears to be a good heuristic - moves that have forced replies are usually better than moves that leave multiple replies.

I have a conference proceedings that includes a paper on Othello AI, I'll try to take a look later and see what else it mentions heuristically they mostly talk about their learning algorithm.

In addition to "Go for corners" Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password.

The psychology behind irrational decisions - Sara Garofalo

Post as a guest Name. Email Required, but never shown. The Overflow Blog. Socializing with co-workers while social distancing. Featured on Meta.I had an assignment to write an artificial intelligence for the game Reversiusing the alpha-beta pruning algorithm. And here is the result. The project consists of several classes implementing the inner structure of the game, and several controls and forms for the user interface.

Steps are repeated until none of the players could make his move. The game is over then, and the Finished event of the Game is raised. Since it is a project for an AI course, the AI should be the most important part of it. As mentioned above, the program uses the alpha-beta pruning algorithm to achieve victory.

As you know, the creation of the whole search tree containing all possible moves from the beginning till the end of the game needs a lot of memory. This happens in the following method of the MoveSolver class:. As you can see if you tried to figure out what this code really doesthe heuristic value for the specified node the board parameter represents the whole board at the current state of the game is formed using two criterions — stability the number of stable discs on the player's board and mobility number of opponent disks that could be converted.

The final value is evaluated using some "magical numbers" as coefficients. These coefficients are inspired by some tests I have made, and do not have any "reasonable" explanation. If the current node is a leaf, this means that we are at the end of the game and could easily see if the state is winning or not. Just subtract the number of opponent discs from the number of the player's discs, and add a quite big number positive or negative so the result will be grater than any heuristic valuation made at the same depth in the search tree.

That is because the valuation at the end of the game is surely correct and is more important than any heuristic valuation we have made.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up. I've written my own Reversi player, based on the MiniMax algorithm, with Alpha-Beta pruning, but in the first 10 moves my evaluation function is too slow.

Webrtc softphone

I need a good early-game evaluation function. I'm trying to do it with this matrix corresponding to the board which determines how favourable that square is to have:. I see you've already figured out the positional strategy. One very simple heuristic that works pretty good early in the game is "give-away", aka " evaporation ": boards that have more enemy stones and fewer of your stones are better. This is a little counter-intuitive, because the opposite is true at the end of the game.

In many board games, it is common for the first 'n' moves to be pre-calculated into an "opening book", which is just a file containing all the possible game positions within that number of moves, and the preferred responses to take for each. To generate the opening book you use the same heuristic as you do for normal play, but instead of doing it on the fly while the game is being played, you calculate all possible moves within those first 'n', and store the results into a file that you ship with the game.

Then when the game is actually playing, for those first 'n' moves, instead of running the heuristic which as you say, can be quite slowyou instead look up the pre-calculated results from the opening book you saved out earlier.


othello heuristic

Home Questions Tags Users Unanswered. Asked 7 years, 4 months ago. Active 7 years, 4 months ago. Viewed 6k times. Have you even written an early-game evaluation function for Reversi? Anko JohnDow JohnDow 1 1 silver badge 5 5 bronze badges. Have you looked up what MiniMax is? I'll edit the question to make it clearer. Active Oldest Votes. David Cary David Cary 3 3 bronze badges.


The Overflow Blog. Featured on Meta. Community and Moderator guidelines for escalating issues via new response…. Feedback on Q2 Community Roadmap. Related This heuristic function is actually a collection of several heuristics and calculates the utility value of a board position by assigning different weights to those heuristics. These heuristics take into account the mobility, coin parity, stability and corners-captured aspects of a board configuration.

Each heuristic scales its return value from to These values are weighed appropriately to play an optimal game. The various heuristics include:. Coin Parity This component of the utility function captures the difference in coins between the max player and the min player. The return value is determined as follows :. This value is calculated as follows :. Corners Captured Corners hold special importance because once captured, they cannot be flanked by the opponent.

This value is captured as follows :. Typical weights could be 1 for stable coins, -1 for unstable coins and 0 for semi-stable coins. Reference : An Analysis of Heuristics in Othello. How did you find the appropriate weights for the final score equation. I did not. Those researchers from University of Washington, who wrote the paper I reference at the end of the post, found them. Can you explain it? They were defined outside the heuristic function.

They are used to find the indices of the eight neighboring cells of a given cell. By cycling through their values and adding them to the indices of a given cell, we can obtain the indices of the 8 neighbors. Hi, I have reviewed your code and it is not clear to me whether and how you deal with coin stability. What approach did you take? Hi, I noticed that definition of matrix V was missing in the code I had pasted. In my original code, it was defined elsewhere.

I have updated the code snippet to include it. A tile is a front tile if it is adjacent to an empty square and so can potentially be flipped.


I made a tradeoff between accuracy and computation time. Calculating coin stability accurately might have been too expensive. The code I presented is not the only way certainly not the best way to implement the heuristics described.

Absolute value inequalities worksheet doc

Many thanks Kartik! This is very helpfu.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. The dark mode beta is finally here. Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. So lets say the root node is the initial game state. First action is the the AI's action while the second action is the opponent's action.

At node level 1 do i evaluate the disc count of my AI's chips and the number of legal moves it can make at the point of time after it has completed an action? At node level 2 do i evaluate the disc count of the opponent's chips and the number of legal moves it can make at the point of time after the opponent has completed an action?

Just want to check if i am on the correct path because it feels strange to count the number of legal moves of a player that has just completed an action. When generating games trees, you shouldn't evaluate a node unless it is a leaf node.

That is, you generate a tree until a level N which corresponds to a board with N moves made ahead of the current state of the board unless you have reached a node which corresponds to an end of game situation. It is only in those nodes when you should evaluate the state of the board game with your evaluation function.

Killer heuristic

That is what the minimax algorithm is about. The only case I know in which you evaluate a node after every player move is in iterative deepening algorithm which seems you are not using. The evaluation function is responsible for providing a quick assessment of the "score" of a particular position - in other words, which side is winning and by how much.

It is also called static evaluation function because it looks only at a specific board configuration. So yes, when you reach level N you can count the possible moves of both the computer and the user and substract them.

For example, if the result is positive it would mean that the computer has the advantage, if it is 0 it would mean a tie and it it is negative it will represent a disadvantage situation for the user in terms of mobility. Scoring a node which represents an end of game board configuration is trivial, assign a maximum value if you win and minimum value if you lose. Mobility is one of the most important features to be considered in the evaluation function of most board games those in which it is valuable.

And to evaluate it, you count the possible moves of each player given a static board configuration no matter whose turn is next. Even if a player recently made a move, you are giving scores to boards in the same level N of the tree when the same player made the last move therefore, scoring them in the same conditions and picking of those the one which has the best score.

othello heuristic

The features you are considering in your evaluation are very good. Usually, you want to consider material and mobility which you are in games in which they are very valuable though, I don't know if material is always an advantage in Othello, you should know it better as it is the game you are working on for a winning situation so I guess you are on the correct path.

EDIT: Be careful! In a leaf node the only thing you want to do is assign a particular score to a board configuration. It is in its parent node where that score is returned and compared with the other scores corresponding to other children. In order to choose which is the best move available for a particular player, do the following: If the parent node corresponds to an opponent's movethen pick the one with the least min value.

If it is the computer's turn to move, pick the score with the highest max value so that it represents the best possible move for this player. If your search reaches a full board then the evaluation should simply be based on the disc count to determine who won. The number of legal moves is useful in the opening and midgame as a large number of moves for you and a low number for the opponent normally indicates that you have a good position with lots of stable discs that your opponent cannot attack, while the opponent has a bad position where they may run out of moves and be forced to play a bad move e.

For this purpose, it does not matter greatly whose turn it is when counting the moves so I think you are on the correct path. Note that in the early stages of the game it is often an advantage to be the person with fewer discs as this normally means your opponent has few safe moves.

Once upon a time I heard that just using a random number for the Othello evaluation function is surprisingly to me also a perfectly reasonable choice.

The logic is that the player with the most choices will be able to steer the game to get the highest random number, and so this approach again means that the AI will favour moves which give it lots of choices, and his opponent few.

Learn more. Othello evaluation function Ask Question. Asked 7 years, 7 months ago. Active 7 years, 7 months ago. Viewed 11k times.

thoughts on “Othello heuristic

Leave a Reply
