PHP Classes

PHP Matrix Similarity: Find similarities in a 2D tile matrix

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 48%Total: 130 All time: 9,327 This week: 75Up
Version License PHP version Categories
matrix-similarity 1.0.3The PHP License5HTML, Algorithms, Math
Description 

Author

This class can find similarities in a 2D tile matrix.

It can generate a bidimensional array of a given size and populate it with random letters from a given set of values.

The class can traverse the generated array to find similar sequences of values following a given set of directions of connected neighbor values.

The class can also display the array in a Web page highlighting the similar connected values.

Innovation Award
PHP Programming Innovation award nominee
May 2015
Number 5
2D matrices are often used to solve problems of algorithm implementation, geographic mapping and gaming.

This class can find matrix similarities using 2D arrays. It can be useful for instance to determine if players in a 2D tile game have achieved goals determined by the trails of the tiles that they traversed.

Manuel Lemos
Picture of Ghali Ahmed
  Performance   Level  
Name: Ghali Ahmed <contact>
Classes: 5 packages by
Country: Tunisia Tunisia
Age: 40
All time rank: 22628 in Tunisia Tunisia
Week rank: 312 Up2 in Tunisia Tunisia Up
Innovation award
Innovation award
Nominee: 3x

Example

<?php
$letters
= ['a', 'b'];
$directions = [
   
'knight' => [[2, 1],[2, -1],[-2, 1],[-2, -1],[1, 2],[-1,2],[1,-2],[-1,-2]],
   
'plus' => [[0, 1],[-1, 0],[0, -1],[1, 0]],
   
'plus_and_coin' => [[0, 1],[-1, 0],[0, -1],[1, 0],[1, 1],[-1, 1],[1, -1],[-1, -1]]
];

$strategie = 'plus';

$matrix = new MathMatrixHelper($letters, $directions[$strategie], 20);
print
'<b>getAllConnexion:</b><br>';
$startTime = microtime(true);
$result = $matrix->getAllConnexion(6, 6);
$matrix->printTile($result, 6, 6);

print
'<b>getRegularConnexion:</b><br>';
$result = $matrix->getRegularConnexion(6, 6, 5,true);
$matrix->printTile($result, 6, 6);
$endTime = microtime(true);
echo
"Execution time : " . ($endTime - $startTime) . " seconds<br/><br/>";


  Files folder image Files  
File Role Description
Accessible without login Plain text file demo.php Example Experimental example that demonstrate how the class works
Plain text file MathMatrixHelper.php Class Main class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:130
This week:0
All time:9,327
This week:75Up
 User Ratings  
 
 All time
Utility:66%StarStarStarStar
Consistency:75%StarStarStarStar
Documentation:-
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:48%StarStarStar
Rank:2921