This question already has answers here:
Algorithm for solving Flow Free Game
(6 answers)
Closed 7 years ago.
I'm looking to create a program to perform a puzzle for me in a similar fashion as this one. I have completed the piece searching portion to identify each of the pieces but I'm stuck at where to being to start solving the puzzle.
Backtracking is an option but for very large board sizes it will have high complexity and take time.
Is there any suitable algorithm to solve the game efficiently. Can using heuristics to solve the board help?
Looking for a direction to start.
It's hard to understand the precise logic of the game you posted. However, if you want something more efficient than DFS/BFS, then you should take a look at A* star: http://theory.stanford.edu/~amitp/GameProgramming/
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 20 hours ago.
Improve this question
I want to program a software that calculates the best combination of materials to use base on parameters such as its tensile strength, elastic modulus, stiffness, and results from doing certain tests from those materials. Those each factor are going to be weighted differently in a WDM. Is there an algorithm that would allow me to find the best combination without actually going through all the combinations and doing each individual calculations? I will be working with a lot of data, so efficiency is important
I tried researching algorithms like kruskal's and other things, but I'm not very fammiliar with them
First step is to write down an equation to calculate a number that you want to optimize.
If you can do that and the equation has no squares or other exponential terms then this is the classical linear programming problem https://en.wikipedia.org/wiki/Linear_programming
Your equation needs to look something like this:
max O = n1 * p1 + n2 * p2 - n3 * p3 ...
If so, then your best bet is to choose a linear programming package ( ask google ) with a good introductory tutorial and plug your problem into that. After a day or so on a steep learning curve, your problem will become almost trivial.
If you cannot do that, then you will need to use some sort of hill climbing algorithm - probably best to hire an expert to help with that.
This question already has answers here:
How to count possible combination for coin problem
(18 answers)
Closed 8 years ago.
I have given an array.And i want to find the all permutation of an array so it sum to a specific numbers.ExampleArray a =[2,3,5 ,1] Target = 8`Solution: [2,2,2,2] ,[5,3] ,[3,3,2] ,[5,2,1] and all possible combinationPlease provide me a approach to solve this the problem , the problem i am facing how to handle the repetition of the elements.Target is a large number of 10^6.
I think it is same asThis theory
You are facing a typical Subset Problem. The worst case complexity of this problem is exponential no matter how you put it. You might find good polynomial-time approximations that work wonders for average case though.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I am trying to understand basic chess algorithms. I have not read the literature in depth yet but after some cogitating here is my attempt:
1) Assign weight values to the pieces(i.e. a bishop is more valuable than a pawn)
2) Define heuristic function that attaches a value to a particular move
3) Build minimax tree to store all possible moves. Prune the tree via alpha/beta pruning.
4) Traverse the tree to find the best move for each player
Is this the core "big picture" idea of chess algorithms? Can someone point me to resources that go more in depth regarding chess algorithms?
Following is an overview of chess engine development.
1. Create a board representation.
In an object-oriented language, this will be an object that will represent a chess board in memory. The options at this stage are:
Bitboards
0x88
8x8
Bitboards is the recommended way for many reasons.
2. Create an evaluation function.
This simply takes a board and side-to-evaluate as agruments and returns a score. The method signature will look something like:
int Evaluate(Board boardPosition, int sideToEvaluateFor);
This is where you use the weights assigned to each piece. This is also where you would use any heuristics if you so desire. A simple evaluation function would add weights of sideToEvaluateFor's pieces and subtract weights of the opposite side's pieces. Such an evaluation function is of course too naive for a real chess engine.
3. Create a search function.
This will be, like you said, something on the lines of a MiniMax search with Alpha-Beta pruning. Some of the popular search algorithms are:
NegaMax
NegaScout
MTD(f)
Basic idea is to try all different variations to a certain maximum depth and choose the move recommended by the variation which results in highest score. The score for each variation is the score returned by Evaluation method for the board position at the maximum depth.
For an example of chess engine in C# have a look at https://github.com/bytefire/shutranj which I put together recently. A better open source engine to look at is StockFish (https://github.com/mcostalba/Stockfish) which is written in C++.
This question already has answers here:
Algorithm interview from Google
(8 answers)
Closed 8 years ago.
I am a long time lurker, and just had an interview with Google where they asked me this question:
Given a requested time d which is impossible (i.e. within 5 days of an already scheduled performance), give an O(log n)-time algorithm to find the next available day d2 (d2 > d).
I had no clue how to solve it, and now that the interview is over, I am dying to figure out how to solve it. Knowing how smart most of you folks are, I was wondering if you can give me a hand here. This is NOT for homework, or anything of that sort. I just want to learn how to solve it for future interviews. I tried asking follow up questions but he said that is all I can tell you.
Thanks!
This is completely firing from the hip because I'm not sure if the question is complete, but if you had a list of dates in an array such that d[0] < d[1] < ... < d[n], the simple answer would be a binary search tree to find the next day.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
What Algorithm for a Tic-Tac-Toe Game Can I Use To Determine the “Best Move” for the AI?
I want to develop a tic tac toe (5x7) game in which there are two players one is computer and one is human.
the player who makes 4 in a row
or 4 in diagonal first wins. If i do using brute force technique it takes long time for computer to decide next move. Can anyone suggest an algorithm with less time complexity ?
thanks in advance..
Alpha-Beta prunning is a good algorithm for searching for the best next turn.