faddison / jewb Goto Github PK
View Code? Open in Web Editor NEWBejewelled board generator and solver
Bejewelled board generator and solver
this is a click strategy. a click pattern is a sequential set of click coordinates to execute.
-columns
-rows
-spiral
-music beat
-etc...
where do I use Strategy pattern and Factory pattern?
avoid clicking the same tile twice in a row and any tile directly adjacent or diagonal to that one. just generate new points until one outside of this dimension is found
if two tiles are clicked simultaneously and one of them depends on the second being in the original location to form a combo it will not occur because the second will be in a moving state. See figures below for example.
figure 1
x x x x x x x x
x x x x x x x x
x x x x x x x x
x x x x x x x x
x x x x x x x x
a b x x x x x x
b x x x x x x x
b x x x x x x x
In figure 1 above a combo can be made by swapping tiles (0,5) and (1,5). However, this requires that tiles (0,6) and (0,7) are stationary. the swap animation take between 300-600 ms. This limits how many moves can be made per second. Computationally, a move can be made in less than 1 ms.
In order to maximize the number of legitimate moves that can be made simultaneously (or pseudo simultaneously) all surrounding tiles that could possibly be affected by the swap must be found.
figure 2
x x x x x x x x
x x x o u x x x
x x x o u x x x
x o o a b u u x
x x x o u x x x
x x x o u x x x
x x x x x x x x
x x x x x x x x
Looking at figure 2, assume that a and b were just swapped. o and u show the possible combinations that could be formed from this swap (respectively). In order to minimize interference these areas should be avoided during the next swap. However, there's multiple degrees of interference to consider. First degree interference would mean trying to swap one of the affected tiles which would prevent a combo from being recognized. Second degree interference would be swapping another tile who's combo region intersected with this combo region. As shown below in figure 3.
figure 3
x x x x x x x d
x x x o uv v v c
x x x o u x x v
x o o a b u u v
x x x o u x x x
x x x o u x x x
x x x x x x x x
x x x x x x x x
Assuming c and d were just swapped immediately after a and b. Now one of their possible combo region intersect each other at (4,1) uv. What are the implications of this? One is that if a combo from the a and b swap forms which coincides with the c and d combo formation then we simply end up with a wasted move because the first combo already executed and the replacement tiles haven't been generated yet.
If this is the only consequence then a static click pattern can be successfully generated based on this algorithm. Since we are able to execute moves much quicker than the animation allows them to resolve eventually we will need to wait. But for now it will improve the bots legitimate moves per second significantly.
ie looking at adjacent tiles for possible combos instead of brute forcing every board state possible
relates to the previous issue of race conditions. I believe these issues may eventually resolve themselves due to the sequential nature of the event processing.
for now I must determine the order of operations when shifting columns down.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.