Optimal algorithm to lose game 2048 [closed] - algorithm

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 8 years ago.
Improve this question
By now, especially after this post and other similar internet resources, I guess most people have figured out how to easily win at Gabriele Cirulli's game 2048: even manually, by observing simple rules, reaching 2048 is not a problem.
However, losing at this game seems far more challenging than winning! As much as I try, the minimum tile I got so far was 16. It seems to me that losing depends on chance much more than winning. Is there any strategy that can guarantee to lose with no tile more than 8?
(Of course, some of the hints suggested here might help, such as calculating all possible moves for n steps and choosing the combination of moves that maximises the probability to get the tiles stuck and end the game. But is there a more logical principle to obtain that?)
In the luckiest case, you would alternate 2s and 4s; alternating 2s, 4s and 8s should be easier. Actually I have just made it with five 8s, seven 4s and four 2s.

Related

the number of swaps in sorting algorithm [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 days ago.
This post was edited and submitted for review 3 days ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
Recently I was learning sorting algorithms, and a description that I found in a book illustrated the numbers of comparisons, swaps, and extra space that will determine the performance. So I was very confused about that. Why will the number of swaps hurt the performance?
"performance" refers to the running time of code. I have seen another post that mentioned swapping elements is vastly more expensive.
in practice, swapping elements is vastly more expensive than comparing. This is even more pronounced when elements are far apart, due to caching. So, on modern hardware, algorithms that tend to swap less - and when they do swap, move elements the furthest toward their final destination - tend to win out.
I want to know the affection of swaps in sorting algorithms. I'm new to this, pls.

Real time applications for counting numbers [closed]

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 6 years ago.
Improve this question
I am solving interesting questions which are quite frequently asked in programming interview like following:
Compute sum of digits in all numbers from 1 to n?
Compute number of perfect square between two given numbers?
Count numbers from 1 to n that have 4 as a digit?
I am wondering what are real time applications for above? Can any one please share there views.
I think these questions have multiple solutions. Question 1 and 3 are interesting because you can solve these problems without iteration in very clever ways, but also solve them using very long winded ways. As someone who does a lot of interviewing, I would want use this type of question to gauge the sophistication of the candidate at solving problems. On that basis I don't think giving you a clever answer to these question is going to be in your best interests to succeeding at interviews. How you tackle a problem and how far you can push the boundaries is what is likely being tested.

Python: Fit geometric forms into a board matrix? [closed]

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 4 years ago.
Improve this question
In the past few days i was thinking of a solution for an AI problem. The problem sounds like this:
I want to determine an arrangement for a few given geometric forms(that do not exceed the given board size) on a square board of given size, in such a way that the board will be uniform covered and the forms will
not overlap.
I want to apply Depth first search / Greedy best first search, but it feels difficult to find a proper representation of the forms and the actual board in order to traverse it. I'm new to python so that makes it a bit more difficult. Any suggestions?
Visual example:
What you are describing is a variation on rectangle/square fitting. Versions of the problem exist where unused cells have to be minimised for an optimal placement of the figures, whereas other versions, like the one you are describing, require for the whole board to be covered uniformly. These are called 'perfect square/rectangle placement' problems.
Typical ways to solve these problems involve the usage of finite integer domains representing the variables of the rectangles and a set of constraints making sure the geometrical placements are valid ones (i.e. don't cross the board borders, don't overlap with each other mutually, ..).

Predict chances of winning or losing in a Chess Game [closed]

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 7 years ago.
Improve this question
I play chess most days at chess.com and was wondering how an algorithm might predict the result of my next game based on all my chess history at this site: my ratings when playing the previous games, the opponent rating, and whether I won or lost.
Thanks,
Roberto Falk
If you are searching for a way to estimate your skill and the skill of your opponent, look for the Elo-Rating. It was actually developed for that purpose (chess). The Elo-rating changes based on which games you won and lost (and against which opponent, based on their Elo-Rating).
That means, if you win against a strong opponent (compared to your strength), your Elo-Rating will improve a lot. If you win against a weak opponent, your Elo-Rating will improve almost not at all.
The problem is, how to get the Elo-Rating of your opponents. If the website does not offer it, the only way is to compute it yourself. However, you would need ALL games of ALL the players on this website to find out how good they really are. Just the number of won/lost games is worthless if you don't factor in the skill of the opponent. If someone won 100 games against a beginner, he doesn't have to be very good. If someone won 100 games against a very good player, he is much better.
If you are searching for a way to estimate the current state of a game while playing (i.e. who is more likely to win after some moves were executed), there are several popular heuristics for chess available. The most simple ones define a value for each piece (strong pieces have a higher value). To see which player has the stronger board, just sum up the values of their pieces.
For some more heuristics (and probably other programming ideas), see here: https://www.chessprogramming.org
There are several very good approaches to estimate the value of a board, much more than I could reasonably write up in an answer.

Algorithm for creating infinite terrain/landscape/surface? [closed]

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 5 years ago.
Improve this question
Does any have an algorithm for creating infinite terrain/landscape/surface?
Constraints
The algorithm should start by a random seed
The algorithm should be one to one, (the same seed gives the same result)
Other input parameter are allowed as long as 2 is fulfilled
The algorithm may output a 2d map
It suppose to create only surface with varying height (mountains), not three, ocean etc.
I’m looking for an algorithm and not a software.
It should be fast
None of other related questions in here answers this question.
If anything is unclear please let me know!
I would suggest something like Perlin noise, I've used it before for something like you're describing above, and it fits the bill. Check out this Example and you can see the sort of output you would expect from the noise generator.Here is a link to algorithm p-code too.
http://freespace.virgin.net/hugo.elias/models/m_perlin.htm
As others already said perlin noise is a possibility. Gpugems 3 has a nice capter about procedual generation using (IIRC, it has been some time since I read this) 3D Perlin noise.
Of course there are other methods too, e.g. Vterrain.org might be worth a look.

Resources