Skip to content

Commit 8b9586c

Browse files
authored
Update README.md
1 parent 9ca31d0 commit 8b9586c

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,48 @@ make bash
4040
```
4141

4242
# Endpoints
43-
API endpoints are not listed here. You can see all available endpoints in the [HttpHandler](http/HttpHandler.php) class in the `registerStandardHandlers` method
43+
API endpoints are not included in this document. For a complete list of available endpoints, please refer to the registerStandardHandlers method in the [HttpHandler](http/HttpHandler.php) class.
4444
* http://localhost:80 - Generates new CAPTCHA. You have ~40 seconds to solve it.
4545
* http://localhost:80/mask - Creates a new CAPTCHA.
4646
* http://localhost:80/mask?mask_id={id} - Edits an existing CAPTCHA.
4747

48+
# About the algorithm
49+
Algorithm for Calculating Point Match Percentage Between Masked and User Paths
50+
51+
This algorithm is designed to analyze the match of points between two data sets: masked paths and user paths. It computes two key metrics: the percentage of unique points from the mask affected by the user and the percentage of user points that did not match with mask points.
52+
53+
You can find the programmatic version of the algorithm in the calculatePathSimilarity method of the [CaptchaHandler](handlers/CaptchaHandler.php) class.
54+
55+
56+
## Data Structure
57+
58+
The algorithm takes two parameters:
59+
60+
* maskPaths: An array of masked paths, each containing an array of points.
61+
* userPaths: An array of user paths, also consisting of arrays of points.
62+
63+
Each point is represented by coordinates (e.g., x and y), and a predefined tolerance is used to evaluate their match.
64+
65+
## Main Steps of the Algorithm
66+
67+
1. Initialization of Arrays:
68+
* Two arrays are created: matchedPoints1 to store unique points from the mask that match user points, and matchedPoints2 to store user points that match with the mask.
69+
2. Comparing Mask Points with User Points:
70+
* The algorithm iterates through each point from the masked paths and compares it with each point from the user paths.
71+
* If a masked point matches a user point within the defined tolerance, it is added to the matchedPoints1 array. Only one match for each unique masked point is considered, leading to a transition to the next masked path.
72+
3. Comparing User Points with Mask Points:
73+
* This part of the algorithm performs the reverse action: it iterates through each point from user paths and checks for matches with points from the mask.
74+
* All matches are added to the matchedPoints2 array, including duplicates, allowing the algorithm to account for the number of misses.
75+
4. Calculating the Total Number of Points:
76+
* To compute match and miss percentages, the algorithm determines the total number of points in both data sets. This is done using a helper function that sums the number of points in each path.
77+
5. Calculating Percentages:
78+
* The percentage of matches (percentageMatched1) is calculated as the ratio of the number of unique matches to the total number of points in the mask. If there are no points in the mask, it returns 0.
79+
* The percentage of misses (percentageNotMatched2) is determined as the difference between the total number of user points and the number of matches, divided by the total number of user points. If the user paths are empty, it returns 0.
80+
81+
## Conclusion
82+
83+
The result of the algorithm is an array containing two values: the percentage of unique points from the mask that were affected by the user and the percentage of user points that did not match the mask. This analysis provides insights into how effectively the user followed the designated path and highlights areas of discrepancy.
84+
4885

4986
# Security
5087
The security of this application has not been tested.

0 commit comments

Comments
 (0)