PHP Classes

File: demo.php

Recommend this page to a friend!
  Classes of Ghali Ahmed  >  PHP Matrix Similarity  >  demo.php  >  Download  
File: demo.php
Role: Example script
Content type: text/plain
Description: Experimental example that demonstrate how the class works
Class: PHP Matrix Similarity
Find similarities in a 2D tile matrix
Author: By
Last change: adding php tag
Date: 7 years ago
Size: 744 bytes
 

Contents

Class file image Download
<?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/>";