summaryrefslogtreecommitdiff
path: root/2048/DEPENDENCIES/move_sci.sci
diff options
context:
space:
mode:
Diffstat (limited to '2048/DEPENDENCIES/move_sci.sci')
-rwxr-xr-x2048/DEPENDENCIES/move_sci.sci13
1 files changed, 13 insertions, 0 deletions
diff --git a/2048/DEPENDENCIES/move_sci.sci b/2048/DEPENDENCIES/move_sci.sci
new file mode 100755
index 000000000..6bd822942
--- /dev/null
+++ b/2048/DEPENDENCIES/move_sci.sci
@@ -0,0 +1,13 @@
+// function result = move_sci(b,nonred,max_sci)
+// Moves matrix b to matrix result with the information on where to move,
+// decided by the indices of nonred.
+// The matrix result will have as many rows as b has and max number of columns.
+// b is augumented with zeros to have nonred number of columns;
+// The columns of b put into those of result as decided by nonred.
+
+function result = move_sci(b,nonred,max_sci)
+[brows,bcols] = size(b);
+b = [b zeros(brows,length(nonred)-bcols)];
+result = zeros(brows,max_sci);
+result(:,nonred') = b;
+endfunction