JavaScript (ES6), 137 bytes
This one uses a more convoluted version of the helper function \$g\$.
Explanation to be updated.
m=>m.map((r,y)=>r.map((c,x)=>t+=c+=(g=(X,k=6)=>~k>0||(m[y+Y+k%5%3]||0)[x-X+k%53%3]&g(X,k*68))(Y=0)&&2+3*g(Y=3)*g(-3)*g``*g(0,Y=6)),t=0)|t
Try it online!
JavaScript (ES6), 146 ... 142140 140137 bytes
m=>m.map((r,y)=>r.map((c,x)=>t+=c+=(g=(X,kk=6)=>k>8||(325>>k|=>k>>8||(m[y+Y+k/3|0]||0m[y+Y+k%5%3]||0)[x-X+k%3])&gX+k%27%4]&g(X,-~kk+46))(Y=0)&&2+3*g(Y=3)*g(-3)*g``*g(!(0,Y=6))),t=0)|t
Try it online!Try it online!
How?
CommentedHelper function
The relative position in the submatrix isWe start with \$(dx,dy)=(k\bmod 3,\lfloor k/3\rfloor)\$\$k=6\$ and we test the least significant bit ofadd 325 >> k
\$46\$ to figure out whether we're over\$k\$ after each iteration. The relative coordinates in the plus sign or notsubmatrix are given by:
0 1 2 1 0 1
3 4 5 --- 325 >> k & 1 ---> 0 0 0
6 7 8 1 0 1
$$\begin{align}&dx=(k\bmod 27)\bmod 4\\
&dy=(k\bmod 5)\bmod 3\end{align}$$
k | k%27 | dx=k%27%4 | k%5 | dy=k%5%3 | (dx, dy)
----+------+-----------+-----+----------+----------
6 | 6 | 2 | 1 | 1 | (+2, +1)
52 | 25 | 1 | 2 | 2 | (+1, +2)
98 | 17 | 1 | 3 | 0 | (+1, +0)
144 | 9 | 1 | 4 | 1 | (+1, +1)
190 | 1 | 1 | 0 | 0 | (+1, +0)
236 | 20 | 0 | 1 | 1 | (+0, +1)
During the first iterationThe cell at \$(+1, +0)\$ is tested twice, which is not an issue.
The next value of \$k\$ is actually undefined. But\$282\$ which triggers the test 325k >> undefined & 18
is \$1\$ as expected and the value ofstops the cell at this position is ignored anywayrecursion.
g = (X, k) => = 6) => // g is a recursive function taking X and thea counter k
k >>> 8 || ( // if k = 9282, stop the recursion and return 1
325( >>m[ ky |+ Y + // otherwise, return 1 if we are outsidetest the '+'cell signlocated at
( m[y + Y + k % 5 % 3 ] // or the cell located at row y + Y + floor((k /mod 35)
k /mod 3 | 0] //)
|| 0 //
)[x[ x - X + k % 3] // and column x - X + ((k mod 327) ismod set4)
k % 27 % 4 ] //
) //
& g(X, -~k) k + 46) // do a recursive call with k + 146
Main function:
Main function
m => // m[] = input matrix
m.map((r, y) => // for each row r[] at position y in m[]:
r.map((c, x) => // for each cell c at position x in r[]:
t += // add to t:
c += // 1 point if c = 1
g(Y = 0) && 2 // 2 points if there's a Double Plus at (x, y)
+ 3 * // 3 points if there are also Double Pluses at:
g(Y = 3) * // (x - 3, y + 3)
g(-3) * // (x + 3, y + 3)
g`` * // (x, y + 3)
g(!(0, Y = 6)) // (x, y + 6)
), // end of inner map()
t = 0 // start with t = 0
) | t // end of outer map(); return t