Skip to content

Commit

Permalink
Fixed Chess\SanSignal
Browse files Browse the repository at this point in the history
  • Loading branch information
programarivm committed Dec 21, 2024
1 parent 2b0d494 commit dab89c2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/SanSignal.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __construct(
$this->balance[$i] = $this->normalize(-1, 1, array_column($this->result, $i));
}

for ($i = 0; $i < count($this->result[0]); $i++) {
for ($i = 0; $i < count($this->balance[0]); $i++) {
$this->signal[$i] = round(array_sum(array_column($this->balance, $i)), 2);
}
}
Expand Down
30 changes: 15 additions & 15 deletions tests/unit/SanSignalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function e4_d5_exd5_Qxd5()
$expectedCenter = [ 0, 1.0, 0.08, 0.67, -1.0 ];
$expectedConnectivity = [ 0, -1.0, -1.0, -1.0, 1.0 ];
$expectedSpace = [ 0, 1.0, 0.25, 0.50, -1.0 ];
$expectedSignal = [ 0.0, 2.0, -1.67, -0.16, -5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
$expectedSignal = [ 0.0, 2.0, -1.67, -0.16, -5.0 ];

$movetext = '1.e4 d5 2.exd5 Qxd5';

Expand All @@ -42,7 +42,7 @@ public function e4_d5_exd5_Qxd5()
*/
public function A59()
{
$expectedSignal = [ 0.0, 2.5, 0.77, 1.01, 1.31, 1.4, 1.69, 3.52, 3.03, 2.77, 0.0, 1.85, 0.17, 0.88, -2.13, 3.42, 2.07, 2.24, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
$expectedSignal = [ 0.0, 2.5, 0.77, 1.01, 1.31, 1.4, 1.69, 3.52, 3.03, 2.77, 0.0, 1.85, 0.17, 0.88, -2.13, 3.42, 2.07, 2.24 ];

$A59 = file_get_contents(self::DATA_FOLDER.'/sample/A59.pgn');

Expand All @@ -56,7 +56,7 @@ public function A59()
*/
public function a3()
{
$expectedSignal = [ 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
$expectedSignal = [ 0.0, 2.0 ];

$movetext = '1.a3';

Expand All @@ -70,7 +70,7 @@ public function a3()
*/
public function a4()
{
$expectedSignal = [ 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
$expectedSignal = [ 0.0, 2.0 ];

$movetext = '1.a4';

Expand All @@ -84,7 +84,7 @@ public function a4()
*/
public function b4()
{
$expectedSignal = [ 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
$expectedSignal = [ 0.0, 1.0 ];

$movetext = '1.b4';

Expand All @@ -98,7 +98,7 @@ public function b4()
*/
public function c4()
{
$expectedSignal = [ 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
$expectedSignal = [ 0.0, 1.0 ];

$movetext = '1.c4';

Expand All @@ -112,7 +112,7 @@ public function c4()
*/
public function d4()
{
$expectedSignal = [ 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
$expectedSignal = [ 0.0, 3.0 ];

$movetext = '1.d4';

Expand All @@ -126,7 +126,7 @@ public function d4()
*/
public function e4()
{
$expectedSignal = [ 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
$expectedSignal = [ 0.0, 2.0 ];

$movetext = '1.e4';

Expand All @@ -140,7 +140,7 @@ public function e4()
*/
public function f4()
{
$expectedSignal = [ 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
$expectedSignal = [ 0.0, 2.0 ];

$movetext = '1.f4';

Expand All @@ -154,7 +154,7 @@ public function f4()
*/
public function g4()
{
$expectedSignal = [ 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
$expectedSignal = [ 0.0, 1.0 ];

$movetext = '1.g4';

Expand All @@ -168,7 +168,7 @@ public function g4()
*/
public function h4()
{
$expectedSignal = [ 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
$expectedSignal = [ 0.0, 2.0 ];

$movetext = '1.h4';

Expand All @@ -182,7 +182,7 @@ public function h4()
*/
public function a4_h5()
{
$expectedSignal = [ 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
$expectedSignal = [ 0.0, 2.0, 0.0 ];

$movetext = '1.a4 h5';

Expand All @@ -196,7 +196,7 @@ public function a4_h5()
*/
public function a4_a5()
{
$expectedSignal = [ 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
$expectedSignal = [ 0.0, 2.0, 0.0 ];

$movetext = '1.a4 a5';

Expand All @@ -210,7 +210,7 @@ public function a4_a5()
*/
public function a4_e5()
{
$expectedSignal = [ 0.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
$expectedSignal = [ 0.0, 2.0, -2.0 ];

$movetext = '1.a4 e5';

Expand All @@ -224,7 +224,7 @@ public function a4_e5()
*/
public function h4_e5()
{
$expectedSignal = [ 0.0, 2.0, -3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
$expectedSignal = [ 0.0, 2.0, -3.0 ];

$movetext = '1.h4 e5';

Expand Down

0 comments on commit dab89c2

Please sign in to comment.