Introduction: Use Silverlight 2.0 (c#) to develop a Lianliankan game. How to play: Select the card with the left mouse button. If the connection between the two selected cards is no more than 3 straight lines, the two selected cards can be eliminated.
Ideas
1. Card initial arrangement algorithm: It is known that the container capacity is x, the number of unique cards is y, x >= y && x % 2 == 0, first randomly arrange the cards in the container, and then take out the same cards in the container For a set with an odd number (the number of members in the set must be an even number), finally cut the set across the board and copy the cards from the right half of the set to the left half of the set in sequence. The above algorithm ensures that based on a certain random rate, there will not be an odd number of identical cards.
2. No solution algorithm and rearrangement algorithm: Among the cards existing in the container, calculate whether there is an eliminable path in pairs. If not, there is no solution and needs to be rearranged. When rearranging, you need to get the existing card set and card position set, randomly pick cards from the card set (if you take one out, this one will be removed from the original set), and then put it in the card position set in order, so as to achieve the purpose of replacing the existing cards. Purpose of rearrangement
3. Two-point elimination path algorithm and algorithm for selecting the optimal elimination path: Take all coordinate sets without placeholders (including yourself) in the x-axis direction and y-axis direction of the first point selected by the player, and the names are respectively x1s, y1s; take all coordinate sets without placeholders (including yourself) in the x-axis direction and y-axis direction of the second point selected by the player, and the names are x2s, y2s respectively. First find two points with equal x coordinates in x1s and Find the set of eliminateable paths in and y2s. The combination of the two sets is the set of all erasable paths between the two points selected by the player. If the set is empty, the two points cannot be eliminated. The shortest path in the set is the optimal elimination path, and the 4-point connecting line in the set is Eliminate path connectors
4. The game is developed using the MVVM (Model - View - ViewModel) pattern
Expand