Let’s say I have an object, called “Tile”, which has both a name and a list of directions. We’ll assume that each tile has a 3×3 grid of pixels, which can either be on or off. The middle center pixel (designated with a “N” in the diagram) of the tile turns on when the North direction is “True”. The center left pixel (“W” in the diagram) of the tile turns on when the West direction is “True”. The center right pixel (“E”) of the tile turns on when the East direction is “True”. The bottom center pixel (“S”) of the tile turns on when the South direction is “True”. The middle pixel (“C”) is always on.
N WCE S
Each tile can only have one start and end, so there are 6 possible tiles. (Straights East-West and North-South, and all 4 turning pieces which form 90 degree angles)
Here’s an example tile, complete with attributes:
Tile1: -North: True -East: False -South: False -West: True
Here’s what that tile looks like, if dashes are “off” pixels and percent signs are on pixels:
-%- %%- ——-
Let’s say I have a list of these tiles, where each tile connects to the one in the list before it, and I am procedurally generating them.
The idea is to be able to generate paths of arbitrary lengths, which do not need to exist inside the bounds of an array.
Of course, I want my map of tiles to be logically sensible, so it cannot have more than 3 lefts or rights in a row. My current “solution” is to have a counter where I subtract one if it turns to the right of the current tile, and add one if it turns to the left. I could then force it to choose a left-turning piece if the counter is at -3, and force it to choose a right turning piece if the counter is at 3. (This algorithm will work with my current generation methods, that is not the problem.)
What is the most efficient way, given the past tiles and their respective directions, to determine whether to increment or decrement the counter?
Sorry if this is a little verbose, I couldn’t think of a better way to phrase my question.
Edit: To clarify, the goal of the algorithm is to determine whether a tile given turns left, right, or straight (which isn’t really a turn, but IDC) based on the previous tiles and return 1, -1, or 0, respectively. That’s it.
✓ Extra quality
ExtraProxies brings the best proxy quality for you with our private and reliable proxies
✓ Extra anonymity
Top level of anonymity and 100% safe proxies – this is what you get with every proxy package
✓ Extra speed
1,ooo mb/s proxy servers speed – we are way better than others – just enjoy our proxies!
USA proxy location
We offer premium quality USA private proxies – the most essential proxies you can ever want from USA
Our proxies have TOP level of anonymity + Elite quality, so you are always safe and secure with your proxies
Use your proxies as much as you want – we have no limits for data transfer and bandwidth, unlimited usage!
Superb fast proxy servers with 1,000 mb/s speed – sit back and enjoy your lightning fast private proxies!
99,9% servers uptime
Alive and working proxies all the time – we are taking care of our servers so you can use them without any problems
No usage restrictions
You have freedom to use your proxies with every software, browser or website you want without restrictions
Perfect for SEO
We are 100% friendly with all SEO tasks as well as internet marketing – feel the power with our proxies
Buy more proxies and get better price – we offer various proxy packages with great deals and discounts
We are working 24/7 to bring the best proxy experience for you – we are glad to help and assist you!