1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547
|
.TH CUAL 6 "2014-10-25"
.\"
.\" Copyright <=2002 by Immanuel Halupczok
.\" Modified 2003,2005-2008,2010-2012,2014 by the cuyo developers
.\" Maintenance modifications 2012 by the cuyo developers
.\" Maintenance modifications 2012 by Bernhard R. Link
.\"
.\" This program is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
.\" the Free Software Foundation; either version 2 of the License, or
.\" (at your option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with this program; if not, write to the Free Software
.\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
.\"
.de TQ
.br
.ns
.TP \\$1
..
.SH NAME
Cual \- Cuyo Animation Language
.PP
Cual is the main language used to describe the animations in cuyo.
Strictly speaking it's
the stuff between the << >> brackets in the level description files
(xxx.ld).
.PP
On the other hand this man page aims at being a complete description
of how to write levels for cuyo.
But it's still under construction.
See the file "example.ld" to get an idea
of how the rest of the level description works.
There's also a bit of example Cual code in "example.ld".
And of course, all the existing levels are examples.
.PP
Note that Cual is probably still very buggy.
So if strange things happen and
you're sure it's not your fault, tell me (cuyo@karimmi.de).
.
.SH HOW IT WORKS
.
The level description is organized in sections.
There is a global section and
every level has its own section, which is a subsection of the global section.
It is common practice to place each level in a separate file, which then
basically starts by opening its section and ends by closing it.
.PP
A section is defined by \fIname\fB = {\fIcontents\fB}\fR.
\fIname\fR is the name of the new section and \fIcontents\fR contains
the definitions that pertain to that section.
This is a sequence of definitions of the form \fIname\fB = \fIstuff\fR.
Here \fIstuff\fR can be \fB{\fIcontents\fB}\fR as above, or it can be a single
datum, or it can be a comma-separated list of data.
Inside such a list, \fIdatum\fB * \fInumber\fR
can be used as a shorthand for \fIdatum\fB, \fR...\fB, \fIdatum\fR, i.e. a
\fInumber\fR-fold repetition of \fIdatum\fR.
A datum can be an identifier, a string (enclosed by '"'), a word, or a number.
In place of a number
\fB<\fIexpression\fB>\fR
can be used, where \fIexpression\fR is an arbitrary expression made up from
literal numbers, previously defined numeric data, and the operators
\fB+\fR, \fB\-\fR, \fB*\fR, \fB/\fR and \fB%\fR.
.PP
Definitions can also depend on versions.
See section \fBVERSIONING\fR below.
.PP
Apart from definitions, a section can also contain cual definitions
(see below).
These have to be enclosed in \fB<<\fR and \fB>>\fR.
.PP
Each blob has its own (main) Cual procedure which does the drawing and the
animation stuff.
The procedure only depends on the kind of the blob, that
is, it is the same for blobs of the same kind.
However each blob has its own instance of the variables.
.PP
In every game step, the procedure of each of the blobs is called once.
(There are 12.5 game steps per second.)
It has to draw the blob each time, even if nothing has changed.
(However, there's an internal routine in cuyo
which checks if the same is drawn as in the last step and which then
suppresses the drawing.)
.PP
There may be other procedures associated to a kind of blob, which are
executed at special events, for example when a falling blob lands.
In contrast to the main procedure, these event handlers are not allowed to
draw anything.
See section \fBEVENT HANDLERS\fR for a list of the existing events.
.PP
The name of the main procedure of a blob (the one which draws the blob)
is the name of the kind of the blob.
Normally, that name is the word listed after \fIpics=\fR entry in the .ld file;
but if that "word" contains a dot,
only the part before the dot makes up the name.
(E. g. with \fBpics=redblob.xpm,greenblob.xpm\fR,
the names are "redblob" and "greenblob".)
.PP
The name of an event handler procedure is the name of the kind, followed
by a dot, followed by the event name.
(E.g. "redblob.land" for the landing event of the redblob from above.)
.PP
[Explain the default procedures.]
.
.SH LEVEL DATA
.SS String valued data
.
.TP
.B name
The name of the level.
This appears in the list of levels as well as in the level intro.
.TP
.B description
This is an optional further description of the level in its intro.
.TP
.B author
The name of the level author(s) for credit at the beginning of a level.
.
.SS Identifier valued data
.
.TP
.B bgpic
Background picture (file name).
If too small, placed at bottom.
Defaults to none.
.TP
.B toppic
Appearance of the top border coming down (file name).
Defaults to none.
.TP
.B explosionpic
Appearance of the explosions (file name).
Has a default.
.
.SS Number valued data
.
.TP
.B numexplode
The size that a group of blobs has to reach in order to explode.
This is only the level-wide default.
Each kind can override this.
Whether the group does explode is also controlled by \fBbehaviour\fR.
See section \fBVARIABLES AND CONSTANTS\fR for details.
.TP
.B toptime
Time the border takes to come down, in number of game steps.
Each game step lasts 80ms.
The default value is 50 (i.e. one pixel every four seconds).
.TP
.B topoverlap
Placement of \fBtoppic\fR relative to the actual border.
More precisely, number of pixels the lower border of the picture
is below the actual border.
Defaults to the height of the picture.
.TP
.B topstop
When the border comes down at the end of the level, number
of pixels it should stop before the bottom.
Set this to the same value as topoverlap
if you want your toppic to be comletely visible at the end.
Defaults to 0.
.TP
.B chaingrass
Must be 0 or 1.
If set to 1, chain reactions are necessary to kill the grass.
Defaults to 0.
More precisely, \fBchaingrass\fR only controls the default for
\fBbehaviour\fR for grass blobs.
See section \fBVARIABLES AND CONSTANTS\fR for details.
.TP
.B mirror
Must be 0 or 1.
If set to 1, the level appears upside-down.
Defaults to 0.
.TP
.B randomfallpos
Must be 0 or 1.
If set to 1, the initial fall position is randomized horizontally.
Defaults to 0.
.TP
.B neighbours
Determines in which directions the blobs can connect to each other in order
to form groups.
This is only the level-wide default.
Each kind can override this.
See section \fBVARIABLES AND CONSTANTS\fR for values.
Defaults to \fBneighbours_rect\fR.
.TP
.B hexflip
In hex mode, determines whether the even or the odd columns are shifted upwards.
By default (hexflip = 0), the odd columns are shifted. 1 means: shift even columns
of player 1; 2 means: shift even columns of player 2; 3 means: shift even columns
of both players.
.TP
.B randomgreys
The expected time between two randomly appearing greys in game steps (80ms).
Use \-1 for none at all, which is the default.
.TP
.B nogreyprob
The probability that a grey does not appear.
See \fBgreyprob\fR and \fBcolourprob\fR in section \fBKIND DATA\fR for details.
The default is 0.
.TP
.B aiu_color, aiu_grass, aiu_grey, aiu_two_above, aiu_monochromic_vertical, aiu_height
Parameters for the AI player's utility function.
Default respectively to <10*(number of kinds)>, 20, 10, <aiu_color/2>,
<aiu_color>, and 10.
See section \fBTHE AI UTILITY FUNCTION\fR for details.
.
.SS Colour valued data
(A colour is an RGB triple of numbers between 0 and 255.)
.
.TP
.B bgcolor
The background colour.
Defaults to white.
.TP
.B textcolor
Colour of any text.
This includes the beginning-of-level information, message()s, and score.
Defaults to a certain shade of dark grey.
.TP
.B topcolor
The colour of the top border coming down
(where not determined by \fBtoppic\fR).
Defaults to a certain shade of light grey.
.
.SS Other data
.
.TP
.B startdist
Distribution of blobs at the beginning of the level.
It is a list of strings, the format of which
is described in the section \fBSTARTDIST\fR.
.TP
.B pics, greypic, startpic, emptypic
Lists of kinds.
These can be either file names referring to the picture
to be used, or declarations of kinds that have to be defined later on.
The different keywords (e.g. pics, emptypic) define different defaults.
In fact, only the first three may be real lists,
\fBemptypic\fR is limited to exactly one entry.
In these lists, it is advisable to use \fB*\fR whenever possible.
Besides being shorter to write, it also speeds up loading of the level
and cuts down memory usage.
This is because cuyo does some initializations only once for each entry
with multiplier.
.RS
.PP
The intentions of these lists are normal blob kinds resp. grey blob kind
resp. grass blob kind resp. nothing-blob.
However, the only differences between
\fBpics\fR, \fBgreypic\fR and \fBstartpic\fR are
the default values for \fBbehaviour\fR, \fBcolourprob\fR, \fBgoalprob\fR,
\fBgreyprob\fR, \fBversions\fR and \fBdistkey\fR (see there).
All of these can also be overridden individually.
Also, the default drawing code is different.
(The default drawing code for \fBstartpic\fR does not draw connections.)
.RE
.TP
.B \fIkind\fR
Each kind can have its own section.
See \fBKIND DATA\fR below for the entries of that section.
.
.SH KIND DATA
.
.TP
.B numexplode, neighbours
Defining these data in the section of a kind
overrides the level-wide value for the kind.
See section \fBLEVEL DATA\fR for a description of these data.
.TP
.B pics
A list of file names of pictures to be used for this kind.
The \fIn\fRth entry can later be accessed in cual with \fBfile=\fIn\-1\fR.
.TP
.B colourprob
The probability that this kind appears as one of the two steered falling blobs.
More precisely, this is a nonnegative integer weight.
For determining the actual probability,
the value is divided by the sum of the \fBcolourprob\fRs of all kinds.
This sum must be positive.
The default is 1 for kinds declared with \fBpics=\fR and 0 for all other kinds.
The probability is also used for \fB+\fR in \fBstartdist\fR.
For more details see section \fBSTARTDIST\fR.
.TP
.B goalprob
This affects the semantics of \fB*\fR in \fBstartdist\fR
in the same way, as \fBcolourprob\fR does for \fB+\fR.
The default is 1 for kinds declared with \fBstartpic=\fR
and 0 for all other kinds.
.TP
.B greyprob
The probability that this kind appears as a grey blob.
This is similar to \fBcolourprob\fR, but there is a difference:
For greyprob, \fBnogreyprob\fR is included in the sum,
so that it might happen that no blob appears at all.
There is a notable difference between a positive \fBnogreyprob\fR
and a positive \fBgreyprob\fR in kind \fBnothing\fR,
when several lines of grey blobs appear:
In the latter case, empty blobs appear in the wall of greys, making holes.
In the former case, the wall is made less high.
Usually this is preferable.
The default is 1 for kinds declared with \fBgreypic=\fR
and 0 for all other kinds.
The value also affects the semantics of \fB\-\fR in \fBstartdist\fR.
In this case, \fBnogreyprob\fR is not included in the sum.
.TP
.B versions
At the creation of a blob, its \fBversion\fR variable is initialized.
Usually, it is chosen at random from \fB0\fR to \fBversions\-1\fR,
but \fBstartdist\fR provides the possibility to specify it exactly.
See section \fBSTARTDIST\fR for details.
The default is 1.
.TP
.B distkey
An alphanumerical key, which is used in \fBstartdist\fR to identify
this kind of blob.
The default is \fBA\fR for kinds declared with \fBstartpic\fR
and undefined for all other kinds.
See section \fBSTARTDIST\fR for details.
.
.SH CUAL DEFINITIONS
.
Inside << >>, variable and procedure definitions are expected.
.TP
.B \fIprocname\fB = \fIcode\fB ;
Defines a "procedure".
The next section describes how \fIcode\fR looks like.
Example:
.RS
.PP
redblob = {
.br
schema16; 0*;
.br
1; A,B,C; *;
.br
};
.RE
.TP
.B var \fIvarname1\fR [\fB= \fIdef1\fR [\fB: reapply\fR]]\fB, \fIvarname2\fR [\fB= \fIdef2\fR [\fB: reapply\fR]]\fB, \fR...\fB ;
Defines variables with default values.
If no default is specified, zero is used.
See section \fBVARIABLES AND CONSTANTS\fR about the
meaning of the default value and the optional suffix \fB: reapply\fR.
.TP
.B default \fIvarname1\fB = \fIdef1\fR [\fB: reapply\fR]\fB, \fIvarname2\fB = \fIdef2\fR [\fB: reapply\fR]\fB, \fR...\fB ;
Changes the default for already defined variables.
Again, the suffix \fB: reapply\fR is optional.
This is useful to give to a single kind a different default for a variable
than to the other kinds.
Also, the default of a system variable can be changed this way.
.
.SH CODE
.
A code fragment can be one of the following:
.TP
.B { \fIcode\fB; \fIcode\fB; ...}
Executes one command after the other.
.TP
.B \fIcode\fB, \fIcode\fB, ...
This is useful for simple animations.
Executes exactly one of the commands:
In the n-th call, the n-th command is
executed. After the last command, the first one is executed again.
However, if one of the commands is "busy" (see section \fBBUSIENESS\fR),
this one will be executed until
it stops being busy, and only after that,
the next command will be executed.
.TP
.B \fIprocname\fB
Executes the procedure \fIprocname\fR, which has to be already defined.
The result is the same as if the code from procname
would have been inserted in that place.
.TP
.B &\fIprocname\fB
Executes the procedure \fIprocname\fR; however, every instance
of such a procname is the same.
This concerns busieness and the state of an animation sequence.
(See sections \fBBUSIENESS\fR and \fBAMPERSAND-CALL\fR.)
.TP
.B busy
Does nothing except being busy.
(See section \fBBUSIENESS\fR.)
.TP
.B \fIvarname\fB = \fIexpr\fB
Sets the variable.
See section \fBVARIABLES AND CONSTANTS\fR for details.
.TP
The same with \fB+=\fR, \fB\-=\fR, \fB*=\fR, \fB/=\fR, \fB%=\fR, \fB.+=\fR, \fB.\-=\fR.
Does what you would expect.
.TP
.B [ \fIvarname\fB = \fIexpr\fB ] \fIcode\fB
Sets the variable \fIvarname\fR to \fIexpr\fR, executes \fIcode\fR
and then resets the variable to the old value.
.TP
.B \fInumber\fB
A shortcut for \fBfile = \fInumber\fR.
.TP
.B \fIletter\fB
A shortcut for \fBpos = \fInumber\fR, where different letters mean different numbers:
A: 0, B: 1, ..., Z: 25, a: 26, ..., z: 51
.TP
.B *
Draw the icon specified by the variables
\fIkind\fR, \fIfile\fR and \fIpos\fR.
May also draw only a part
of the icon, if specified by the variable
\fIqu\fR
(see section \fBVARIABLES AND CONSTANTS\fR).
.TP
.B *@(\fIposition\fB)
Like \fB*\fR, but draws the icon at some other position.
This drawing is performed \fIafter\fR all drawing by *.
If \fB*@\fR is used from several blobs,
the further order of drawing is not specified.
It is guaranteed, however,
that at any given time this order is the same for all positions.
(See section \fBVARIABLES AND CONSTANTS\fR for more details about @.)
.TP
.B @(\fIposition\fB)*
Like \fB*\fR, but draws the icon at some other position.
This drawing is performed \fIbefore\fR all drawing by *.
If \fB@*\fR is used from several blobs,
the further order of drawing is not specified.
It is guaranteed, however,
that at any given time this order is the same for all positions.
(See section \fBVARIABLES AND CONSTANTS\fR for more details about @.)
.TP
.B if \fIexpr\fB \fIif-arrow\fB \fIif-code\fB ;
.TQ
.TQ
.B if \fIexpr\fB \fIif-arrow\fB \fIif-code\fB else \fR[\fIelse-arrow\fR]\fB \fIelse-code\fB ;
The arrows can be either "\->" or "=>".
If you use "\->" arrows, it does exactly what
you would expect.
If the if-arrow is "=>",
then once the expression gets
true, the if-code
will be executed every subsequent
time (without testing the condition),
as long as it is "busy".
For more details see section \fBBUSIENESS\fR.
If the else-arrow is "=>",
then once the expression gets false, the
else-code will be executed every subsequent
time as long as it is busy.
The else-arrow may only be omitted, if the if-arrow is "\->".
Then the else-arrow also is "\->".
(But this might change in the future.)
.TP
.B switch {
.TQ
.B \ \fIexpr1\fB \fIarrow1\fB \fIcode1\fB ;
.TQ
.B \ \fIexpr2\fB \fIarrow2\fB \fIcode2\fB ;
.TQ
.B \ ...
.TQ
.B }
The arrows can be either "\->" or "=>".
Does the same as:
.RS
.PP
if \fIexpr1\fR \fIarrow1\fR \fIcode1\fR
.br
else => if \fIexpr2\fR \fIarrow2\fR \fIcode2\fR
.br
...
.PP
The last \fIexpr\fR may be omitted.
This is equivalent to setting it to true.
.RE
.TP
.B bonus(\fIexpr\fB)
The player gets \fIexpr\fR bonus points.
.TP
.B message(\fIString\fB)
The string is displayed (blinking) on the screen.
To be used together with bonus(...).
Example:
.RS
.PP
bonus(50);
.br
message("You get 50 bonus points");
.RE
.TP
.B explode
Makes the blob explode.
For the next 8 steps or so, the
blob is still what it was before, but the explosion is
drawn over the graphics.
After that, it's changed to a nothing-blob.
.TP
.B lose
The players immediately lose the level.
.TP
.B sound(\fIFilename\fB)
Plays the given sound file.
.PP
You can also omit the code completely.
Then, of course, it does not do anything.
This can be useful as part of \fB,\fR-sequences.
.PP
There's a shortcut for drawing: You may omit the ";" between
a number, a letter and the "*".
.
.SH EXPRESSIONS
.
The only data type in cual is int.
Bools are represented by 0 and 1, like in C.
(And any number other than 0 is interpreted as true, if a boolean is expected.)
.PP
Of course, variables, constants and numbers are expressions, and
you can use parentheses.
There are the following operators
(listed here in order of increasing precedence):
.PP
.RS
.TP
.B ||
Boolean or
.TP
.B &&
Boolean and
.TP
.BR == ", " != ", " < ", " > ", " <= ", " >=
Comparison
.TP
.B ==..
A special comparison
.TP
.B !
Boolean not
.TP
.BR + ", " \-
Add, subtract
.TP
.B :
Special operator
.TP
.BR * ", " / ", " %
Multiply, divide, modulo
.TP
.BR & ", " | ", " .+ ", " .\-
Bitwise and, bitwise or, setting of bits (same as bitwise or), unsetting of bits
.TP
.B \-
Unary minus
.TP
.B \.
Testing of bits (\fIa\fB.\fIb\fR is the same as \fIa\fB&\fIb\fB != 0\fR)
.RE
.PP
\fB/\fR and \fB%\fR work mathematically correct and do not make funny changes
when the sign of the numerator changes.
More specifically, if \fIb\fR is positive, then \fIa\fB/\fIb\fR
is the largest integer \fIn\fR such that \fIn\fB*\fIb\fB<=\fIa\fR.
If \fIb\fR is negative, then \fIa\fB/\fIb\fR is the largest integer \fIn\fR
such that \fIn\fB*\fIb\fB>=\fIa\fR.
In both cases \fIa\fB%\fIb\fR is such
that \fB(\fIa\fB/\fIb\fB)*\fIb\fB+\fIa\fB%\fIb\fB = \fIa\fR.
Examples:
.TS
tab(#); l l.
.sp
13/5=2 # 13%5=3
\-13/5=\-3 # \-13%5=2
13/\-5=\-3 # 13%\-5=\-2
\-13/\-5=2 # \-13%\-5=\-3
.TE
.PP
The following are the special operators:
.TP
.B \fIexpr1\fB == \fIexpr2\fB .. \fIexpr3\fB
Is true, if \fIexpr1\fR lies between \fIexpr2\fR and \fIexpr3\fR.
You may also omit one of \fIexpr2\fR and \fIexpr3\fR.
(Then, it does the same as <= resp. >=.)
The precedence implies that \fBx==y==2..3\fR is the same as \fBx==(y==2..3)\fR
and is neither \fB(x==y)==2..3\fR nor \fBx==(y==2)..3\fR.
Note that this operator might
change in the future. (I plan to make something like
"\fIexpr\fR in \fIset\fR" in Pascal.)
.TP
.B \fIexpr1\fB : \fIexpr2\fB
Is true (that is, 1) with probability
\fIexpr1\fR/\fIexpr2\fR
.TP
.B \fIneighbour_pattern\fB
\fIneighbour_pattern\fR is a sequence of six
or eight characters \fB0\fR, \fB1\fR and \fB?\fR.
It is true if the sequence fits to the
neighbour sequence of the blob.
The neighbour sequence is a string of "0"s and "1"s
with a "1" for each neighbour of the same kind,
starting above and going clockwise.
This way, you get a string of "0"s and "1"s (six or eight, depending
on whether this level is in hex mode).
.RS
.PP
Example: \fB1???0???\fR is true iff the
blob above this blob is of the
same kind and the blob below it is of
different kind.
.PP
For an empty blob the semantics is slightly different:
If in some direction there is no neighbour, because the field ends there,
the entry in the neighbour sequence is 1 nevertheless.
So for an empty blob \fB1???0???\fR is true, iff the
blob above this blob does not exist or is empty as well,
and the blob below this blob exists and is not empty.
.PP
If some blob changes its kind during a step, the expression will still
test the neighbours as they were at the beginning of the step.
(See the section \fBVARIABLES AND CONSTANTS\fR for details.)
.RE
.PP
The following functions exist:
.TP
.B rnd(\fIexpr\fB)
Returns a random value between 0 and \fIexpr\fR\-1
.TP
.B gcd(\fIexpr1\fB, \fIexpr2\fB)
Returns the greatest common divisor of \fIexpr1\fR and \fIexpr2\fR
.
.SH VARIABLES AND CONSTANTS
.
The following kinds of variables and constants exist:
.TP 3
\(em
User defined variables (see section \fBCUAL DEFINITIONS\fR).
At the start of the
level (or at the creation of the blob) the value is the default value you
provided.
If you supplied the default with \fB: reapply\fR,
whenever a blob's kind changes,
the value of the variable is also set to the default of the new kind.
There is a subtlety: This only happens if the new value of kind
is in fact different from the old one.
.TP
\(em
System variables.
These variables are always defined and have special
meanings, e.g. \fBfile\fR and \fBpos\fR.
Some of them are read-only.
.TP
\(em
User defined constants.
These are defined in the main .ld part, not in cual (not inside << >>).
.TP
\(em
System constants.
Some of them depend on properties of the level, some are really constant.
.PP
Of each variable, there's one instance in each blob.
Normally, you access
the instance in your own blob, but with the following syntax, you can access
variables of other blops:
.PP
\fIvarname\fB@@(\fIx\fB, \fIy\fB; \fIside\fB)
.br
\fIvarname\fB@@(\fIx\fB; \fIside\fB)
.br
\fIvarname\fB@@(; \fIside\fB)
.br
\fIvarname\fB@(\fIdx\fB, \fIdy\fB; \fIside\fB)
.br
\fIvarname\fB@(\fIdx\fB; \fIside\fB)
.br
\fIvarname\fB@()
.PP
If \fIx\fR and \fIy\fR are given,
these are absolute coordinates in the grid of blops,
that is the variable is taken from the blob with loc_x=x and loc_y=y
(see under \fBThe system variables\fR).
If only \fIx\fR is given, it specifies one of the two blobs that are
currently falling.
If there is only one such blob left, because the other
one got stuck on some tower, the remaining blob's coordinate is 0.
Otherwise one of the two has coordinate 0, the other 1.
.PP
In the \fB@\fR variants, the coordinates are relative to the current blob.
The variant \fB@@(; \fIside\fB)\fR refers to the semiglobal blob,
the variant \fB@()\fR to the global blob (See section \fBTHE GLOBAL BLOB\fR).
The extra part \fB; \fIside\fR is optional and specifies the side
of the game.
This is only meaningful in two-player mode.
\fIside\fR = \fB<\fR specifies the left player,
\fIside\fR = \fB>\fR the right player,
\fIside\fR = \fB=\fR the player to which the current blob pertains,
and \fIside\fR = \fB!\fR the other player.
\fB@()\fR and \fB@@()\fR can also be given as \fB@\fR respectively \fB@@\fR.
.PP
This can be done for both, reading and
writing variables.
It also works for system variables (but not for constants).
.PP
In hex mode levels, for odd \fIdx\fR, \fIdy\fR should be a "half integer",
that is a number ending in ".5".
This is the only place in Cual where non-integers appear.
Especially, ".5" is not allowed in composite expressions.
Therefore, also integer \fIdy\fR is always allowed.
If a half-integer is expected and an integer is given, it is assumed to be
rounded to above, that is 5 then represents 4.5 and \-5 represents \-5.5.
.PP
Caution: With \fBmirror=1\fR the absolute and the relative coordinates use
different coordinate systems.
Handle with extreme care.
.PP
Accessing foreign variables is not as easy as it might look at first glance;
it might easily introduce a dependence of the internal order of execution
of the blob codes.
For this reason,
.TP 3
\(em
reading variables with \fB@\fR or \fB@@\fR
always returns the value of the variable it had
at the \fIbeginning\fR of the current step, that is, before any of the
blob codes has been executed.
.TP
\(em
when writing variables with \fB@\fR or \fB@@\fR,
the write operation will only be executed
at the \fIend\fR of the current step.
(The write operations are stored in a kind of queue.)
.PP
This is also true if a blob accesses its own variables with \fB@(0,0)\fR.
.PP
The operators \fB+=\fR, \fB\-=\fR, etc.
are also performed in the future if the left
hand side is an \fB@\fR-variable.
(To be more precice, the right hand side is
calculated instantanousely.)
.PP
For illustration, look at the following six statements:
.PP
.TS
tab(#);
l l.
1)#X += 1
2)#X@(0, 0) += 1
3)#X = X + 1
4)#X = X@(0, 0) + 1
5)#X@(0, 0) = X + 1
6)#X@(0, 0) = X@(0, 0) + 1
.TE
.PP
Only 1) and 3) do the same; they simply increment X by 1.
Statement 4) sets X to one more than it was at the beginning of the step.
Statements 2), 5) and 6) cause the value of X
to be changed in the future (after the
current step): X is set to one more
than:
.TP
2)
the value of X just before the change (that is, X is incremented
in the future),
.TP
5)
the current value of X,
.TP
6)
the value of X at the beginning of the step.
.
.SS Some more details
.
.TP 3
\(em
Whenever you try to access a variable at a location which doesn't exist,
you will get the default value.
If default values depend on the kind,
the default pertaining to the blob executing the code is used.
This may change in the future.
.TP
\(em
Changing a variable which doesn't exist does nothing (and does not
result in an error).
.TP
[Add explanation of \fItime slices\fR; roughly:
@-access of variables in reality don't access the value at the
beginning/end of the game step, but of the time slice.
The call of the main procedure of all blobs happens in the same time
slice, but each other kind of event has its own time slice.]
.PP
.
.SS The system variables
.
.TP
.B file
Specifies the file number from which to take the icon that
is drawn by "*".
This variable is reset to 0 before the drawing procedure is executed.
.TP
.B pos
Specifies the position in the file of the icon that is drawn
by "*".
This variable is reset to 0 before the drawing procedure is executed.
.TP
.B kind
The kind of the blob.
There are constants for the possible values of this variable.
If you change the kind, you should be aware of three things:
.RS
.TP 3
\(em
Expressions like "001???01" test the neighbour pattern at
the \fIbeginning\fR of the current step.
So the change of the variable \fIkind\fR will not be reflected.
.TP
\(em
In the current step, the program to draw the blob has already
been invoked (it might even be the program which changed this variable);
so in this step, the blob will still look like one of the old
kind.
However, if things are drawn after the kind has been changed,
icons from the new kind are taken.
.TP
\(em
Defaults of the new kind that are declared with \fB: reapply\fR are applied.
This happens at the same time that kind changed,
but only if the new kind is different from the old one.
.RE
.TP
.B version
Is assigned a hopefully distinctive value at the blob's creation.
See \fBversions\fR in section \fBKIND DATA\fR for details.
.TP
.B qu
Tells "*" which part of the icon to draw.
It's possible to draw the whole icon, or only one of its quarters.
If a quarter
is drawn, you may specify independently which of the quarters to
take and at which position to draw it.
Use the constants (see below).
This variable is reset to "draw all" before the drawing
procedure is executed.
.TP
.B out1, out2
Set these Variables for debug output.
The values will be printed on top of the blob.
These variable are reset to "output nothing"
before the drawing procedure is executed.
(In fact, "output nothing" is one special big value.)
.TP
.B weight
When \fBcalculate_size\fR is set in \fBbehaviour\fR,
\fBsize\fR will be regularly updated
to the sum of \fBweight\fR in the connected component.
The default is 1.
.TP
.B inhibit
Set this variable to a sum of the constants DIR_...; this will
inhibit that this blob connects into the given directions.
This is \fInot\fR for the graphics but for the calculation of the
connected components and the explosions.
.TP
.B behaviour
This is a bit field.
Refer to \fBThe Constants\fR below for the meaningful of its bits.
The default is \fBcalculate_size\fR+\fBexplodes_on_size\fR for normal blobs,
\fBexplodes_on_explosion\fR+\fBexplodes_on_chainreaction\fR for grey blobs,
\fBfloats\fR for the empty blob and
\fBgoalblob\fR+\fBexplodes_on_explosion\fR+\fBexplodes_on_chainreaction\fR or
\fBgoalblob\fR+\fBexplodes_on_chainreaction\fR
(depending on whether chaingrass is set) for grass blobs.
.TP
.B falling_speed, falling_fast_speed
These variables are only used in the semiglobal blobs.
They define the vertical speed of the steered falling blobs.
The unit is pixels per game step.
The defaults are 6 and 32.
.PP
.
.SS The system read-only variables
.
.TP
.B time
The number of time steps since the level was started.
.TP
.B turn
Is 1 resp. 2 if the blob is falling and just being turned
by the user and 0 otherwise.
(1 in the first turning step, 2 in the second one.)
Be aware that if the user presses the turn key fast several
times, some of these steps may be omitted.
(Use the turn event
if you want to be sure that a program block is executed once
for every turn.)
.TP
.B connect
Contains internal data.
Will be removed.
Probably.
.TP
.B size
The size of the component of the blob.
(That is, how many blobs are connected.)
.TP
.B basekind
The value of the constant generated for the name of the kind of the blop.
Example:
.RS
.PP
\fBpics = orange, pear, apple * 3, banana, apple\fR
.PP
Here, all four kinds \fBapple\fR have the same value for basekind,
and this value is \fBapple\fR.
.RE
.TP
.B loc_x, loc_y
The absolute coordinates of the blob.
(0,0) = top left corner
.TP
.B loc_xx, loc_yy
The absolute coordinates of the blob in pixels.
This is not always the same as loc_x*32 and loc_y*32,
particularly for the steered falling blobs.
.TP
.B loc_p
The player of the blob (1 or 2)
.TP
.B falling
true, if the blob is falling or it is a preview of a falling blob.
(Falling in the sense of steered by the player.
Grey blobs are not falling in that sense.)
.TP
.B falling_fast
True, if the blob is falling fast, that is, the user pressed
the down key.
.TP
.B informational
True, if the blob is one of the info-blobs at the side of the game area.
In this sense, the previews of the falling blobs also count as info-blobs.
.TP
.B players
The number of players.
.TP
.B exploding
When the blob is exploding, the position in the
explosion animation (1 to 8); 0 else.
.RS
.PP
Currently, there is one exception: if the explosion has been triggered
by the \fBexplode\fR command, then \fBexploding\fR will have value 1 only
\fIafter\fR the current game step [more precisely: time slice; fix that].
Reason: when reading \fBexploding@(x,y)\fR, we maybe don't know yet that
the other blob calls \fBexplode\fR.
.
.SS The Constants:
.
.B Constants for behaviour:
.TP
.B goalblob
Set goalblob if this blob should act like grass: You will have
to get rid of it to win the level and making this blob explode will give
more points.
.TP
.B calculate_size
When this bit is set, \fBsize\fR will be regularly updated to the sum
of \fBweight\fR in the connected component.
.TP
.B explodes_on_size
When this bit is set, a connected component explodes, when it has
\fBsize\fR>=\fBnumexplode\fR.
.TP
.B explodes_on_explosion, explodes_on_chainreaction
When these bits are set, the blob explodes whenever an explosion that was
triggered by \fBexplodes_on_size\fR happens in its neighbourhood.
\fBexplodes_on_chainreaction\fR refers to those triggering explosions
that are the second or later part of a chain reaction.
\fBexplodes_on_explosion\fR refers to the other ones.
.TP
.B floats
When this bit is set, the blob keeps its vertical position
even if there is an empty blob below.
This bit has no effect on the steered falling blobs.
.PP
.B Constants for kind:
.TP
.B <name of kind of blob>
For each kind of blob, there's one constant with
the name of that kind. Use it to check if a
blob is of that kind using \fBkind@(\fIx\fB,\fIy\fB) == \fIaKind\fR
or to change to that kind using \fBkind = \fIaKind\fR.
See \fBkind\fR under \fBThe system variables\fR for the side-effects
of setting \fBkind\fR.
.RS
.PP
Sometimes it is necessary to perform arithmetic on kinds,
for example when several have been declared using the \fB*\fR multiplier.
The values of the constants are successive in the order, in which the kinds
have been declared.
When a name is used several times, the first use defines the value.
Example:
.PP
\fBstartpic = apple, orange
.br
pics = orange, pear, apple * 3, banana
.br
greypic = pineapple\fR
.PP
This initializes 2 kinds with the defaults for startpic,
6 kinds with the defaults for pics, and 1 kind with the defaults for greypic.
The value of the constant \fBorange\fR is 1 more than that of \fBapple\fR,
\fBpear\fR is 2 more than \fBorange\fR, \fBbanana\fR is 4 more than
\fBpear\fR and \fBpineapple\fR is 1 more than \fBbanana\fR.
We do not specify what these values actually are.
.PP
This constant also exists for the empty kind, if one has been declared
using \fbemptypic\fR.
In this case the value's relation to the other values
is not specified at all.
.RE
.TP
.B global, semiglobal
Denote the kind of the global, respectively semiglobal, blob.
.TP
.B nothing
Is the same as the constant for the empty kind.
Is provided, because sometimes, you don't have
an empty kind, but you still need to test if a
blob is empty.
.TP
.B outside
The value of kind if the coordinates are outside
of the game board.
.PP
.B Constants for neighbours:
.TP
.B neighbours_rect
A blob connects up, down, left, and right.
This is the default.
.TP
.B neighbours_horizontal
A blob connects left and right.
.TP
.B neighbours_vertical
A blob connects up and down.
.TP
.B neighbours_diagonal
A blob connects diagonally.
.TP
.B neighbours_hex6
When used in the level-wide \fBneighbours\fR, this sets hex mode.
A blob connects up, down, left with a slight upwards shift,
left with a slight downwards shift, right with a slight upwards shift,
and right with a slight downwards shift.
.TP
.B neighbours_hex4
When used in the level-wide \fBneighbours\fR, this sets hex mode.
A blob connects left with a slight upwards shift,
left with a slight downwards shift, right with a slight upwards shift,
and right with a slight downwards shift.
.TP
.B neighbours_knight
A blob connects in knight moves (Two forward and then one sideways.
Forward is one of up, down, left or right.
Sideways is perpendicular to forward.
This makes a total of eight directions.).
.TP
.B neighbours_eight
Combines \fBneighbours_rect\fR with \fBneighbours_diagonal\fR.
.TP
.B neighbours_3D
A more obscure mode created especially for 3d.ld.
When used in the level-wide \fBneighbours\fR, this sets hex mode.
A blob connects up, down, two (but not one) to the left, and two to the right.
In even columns it also connects right with a slight upwards shift.
In odd columns it also connects left with a slight downwards shift.
.TP
.B neighbours_none
A blob does not connect at all.
.PP
.B Constants for qu:
.TP
.B Q_ALL
Value for qu, which means "draw the complete picture".
.TP
.B Q_TL, Q_TR, Q_BL, Q_BR
Values for qu.
"TL" means draw top-left quarter, etc.
(See the "*" command in the Code section.)
.TP
.B Q_SRC_DST
SRC and DST may be TL, TR, BL, BR.
Take quarter SRC and draw it at position DST.
.PP
.B Miscellanious constants:
.TP
.B DIR_XX
To be used with the variable inhibit to prevent the blob
connecting in the given directions.
XX can be U, D, L, R (horizontal and vertical); UL, UR, DL, DR (diagonal);
UUL, UUR, DDL, DDR, LLU, LLD, RRU, RRD (knight); F, B (3d)
.
.SH VERSIONING
.
Sometimes it is necessary to define a level slightly differently for different
purposes.
For example you might need to decrease \fBnumexplode\fR for the
two-player version lest it becomes unplayable.
The difficulty settings from cuyo's main menu provide another example.
.PP
This is done by qualifiing a definition with the versions it should apply to.
It is best explained by an example:
.PP
numexplode = 8
.br
numexplode[2] = 6
.br
numexplode[1,hard] = 10
.PP
This specifies that normally numexplode should be 8.
In two-player mode it should be 6.
In one-player hard mode it should be 10.
Here the specifiers \fB2\fR
for two-player mode, \fB1\fR for one-player mode and \fBhard\fR for hard mode
are used.
Along with \fBeasy\fR for easy mode these are all predefined specifiers
intended for levels.
Additionally (and for internal purposes),
there are specifiers for the level tracks:
\fBmain\fR, \fBall\fR, \fBgame\fR, \fBextreme\fR, \fBnofx\fR, \fBweird\fR,
and \fBcontrib\fR.
.PP
Furthermore, you can make up and use your own specifiers.
In order for them to take effect, though, you have to give cuyo additional
information about the current version.
This is done on the command line using the \fB\-\-version\fR option.
For example
.PP
cuyo \-\-version=hard,geek
.PP
Specifies both hard version (you can change that in the menu)
and version "geek", which is not predefined.
.PP
There are several constraints to be observed:
.TP 3
\(em
All versions of a definition must be made before the first use of the thing
defined.
As sometimes it is not obvious where the defined thing is used
(for example startpic uses a previous greypic by assigning successive numbers
to kinds),
it is best to group all these versions into one block.
.TP
\(em
A given version also applies to every more specialized version, for which no
definition is given.
In the above example, \fBnumexplode\fR is set to \fB6\fR
in two-player hard mode and in two-player easy mode as well.
.RS
.PP
All resulting conflicts must be resolved.
For example, if you make a definition
for \fB[2]\fR and one for \fB[hard]\fR, you must also make a definition for
\fB[2,hard]\fR (or, equivalently, for \fB[hard,2]\fR), because otherwise it
would be ambiguous which of the two former
should apply in two-player hard mode.
.RE
.TP
\(em
Cuyo knows that \fBeasy\fR and \fBhard\fR exclude each other.
Consequently, it is unnecessary (and indeed prohibited) to give an
\fB[easy,hard]\fR definition, even if both \fB[easy]\fR and \fB[hard]\fR
are given.
The same holds for \fB1\fR and \fB2\fR, and for level tracks.
.TP
\(em
Furthermore, cuyo knows that \fB1\fR and \fB2\fR are exhaustive: There is no
mode which is neither single-player nor two-player.
(The human-versus-AI mode counts as two-player as far as cual is concerned.)
Therefore, if there are definitions for both, it is unnecessary, (and again
illegal) also to define a version without any of both.
For example, if \fB[1,de]\fR and \fB[2,de]\fR are given, \fB[de]\fR must be
omitted.
Alternatively, you could of course give \fB[1,de]\fR and \fB[de]\fR
or \fB[de]\fR and \fB[de,2]\fR.
The level track specifiers are exhaustive as well.
.
.SH BUSIENESS
.
(No, not Business ;\-)
.PP
Busieness is a concept to make it easier to implement simple animated
sequences which are triggered by certain events.
Each code fragment has an internal state which tells if it is busy.
.TP 3
\(em
Normal statements like assignments are never busy.
.TP
\(em
A chain of commands separated by "," is busy as long as not
all of the commands have been executed.
.TP
\(em
\fIcode1\fR ; \fIcode2\fR is busy as long as at least one of
\fIcode1\fR and \fIcode2\fR are busy.
.PP
Here's an example of how to use busieness for an animation which appears
at random intervals:
.PP
\fBswitch {
.br
1:100 => {B*, C*, D*, E*};
.br
\-> A*;
.br
};
.PP
This code fragment normally draws the icon at position A (0).
But in each
step, with a probability of 1/100, an animation sequence consisting of icons
B, C, D and E is started.
With a normal arrow ("\->") after the "1:100",
after the step in which B has been drawn, the probability would be 99/100
that A is drawn again.
But with the double arrow, the switch statement
won't switch back to A until the animation has terminated.
.PP
(Btw: It doesn't matter if there's a "\->" or a "=>" before the "A*";
A* isn't busy anyway.)
.
.SH THE GLOBAL BLOB
.
Apart from the normal blobs which you can see on screen, there's one global
blob (for the whole game, not one for each player), which, well, isn't really
a blob, but behaves a bit like it.
It has
its own set of variables, and it can have a program which is run once every
step.
To define such a global program, use \fBglobal=\fIcode\fR.
However, the global
variables do exist even if you don't define global code.
See section \fBVARIABLES AND CONSTANTS\fR on how to access them.
Note that the global blob is always executed before any of the normal blobs.
.PP
There are also semiglobal blobs.
There is one for each player.
These are programmed with \fBsemiglobal=\fIcode\fR.
.
.SH EVENT HANDLERS
.
The following events exist:
.TP
.B init
Is called only once, when the blob gets into life, just before the first
time its main drawing routine is called.
.TP
.B turn
Is called for falling blobs each time they are rotated.
.TP
.B land
Is called when the steered blob lands (just after it landed).
.TP
.B changeside
Is called when a blob moves from one player to the other, just after the
blob has arrived at the new player.
.TP
.B connect
Is called when the connection of blobs is recalculated.
.TP
.B row_up
Is called when a player got a row from the other side, after everything
is finished and just after the loc_y of all blobs has been decreased by 1.
Is only called for the semiglobal blob, though.
.TP
.B row_down
Is called when a player gives a row to the other side, before anything
visible happens, but just after the loc_y of all blobs has been increased by 1.
Is only called for the semiglobal blob, though.
.TP
.B keyleft, keyright, keyturn, keyfall
Are called when the player presses the left, right, turn or fall key.
Are only called for the steered falling blobs and the semiglobal blob, though.
(Note that, in contrast to turn, keyturn is called even if the steered blob
cannot be rotated due to some obstacles, and also if there is no steered blob.)
.
.SH THE LIFE OF A BLOB
.
Normal blobs come into life at the beginning of the game, or they fall
into life: either as colored blobs, steered by the user, or as grey blobs.
More precisely, the steered blobs already come into life when they appear
as the preview.
When a blob moves (by gravitiy or when rows go from one player to another),
it takes its variables with it.
When a blob explodes, it does not stop existing.
Rather, it transforms into an empty blob.
That's important for the variables: The empty blob still
has all the variables set to the values they had before; only its kind
is different.
Empty blobs are everywhere where there's no other blob.
(However, the falling blobs steered by the user are in some sense "above"
everything else; there are empty blobs beneath them.)
.PP
The life of empty blobs is different from the one of normal blobs.
Empty blobs are not affected by gravity, and they often start or stop existing.
For example, when a single grey blob is falling down, the empty blob below
it stops existing when the grey blob arrives and a new empty blob starts
existing when the grey blob moves on.
There is only one situation in which empty blobs move: When
a row moves from one player to the other, and everything moves up resp. down,
the empty blobs move, too.
.
.SH STARTDIST
.
The format of the startdist field is rather complicated.
On the plus side, this means that many things can be done with little effort.
We first describe the single-character format, which,
at the time of this writing, has sufficed for all needs.
After that, we describe the general format as an extension.
.PP
Every line of the startdist describes one row of blobs
in the level's initial state.
The lines are aligned to the bottom and the topmost lines come first
(normal reading order).
Each line must contain exactly 10 or exactly 20 characters,
except the last which is special.
In a line of length 20 the first 10 characters describe the left player,
the second 10 characters describe the right player.
A line of length 10 describes both players.
Hence, each character describes one blob.
The semantics are:
.TP
.B .
An empty blop.
.TP
.B +, \-, *
A blop chosen at random according to \fBcolourprob\fR,
respectively \fBgreyprob\fR, respectively \fBgoalprob\fR.
The value of \fBnogreyprob\fR has no influence.
.TP
.B 0..9, A..Z, a..z
These characters denote a specific kind.
If the character matches the \fBdistkey\fR of some kinds,
the first of these is chosen.
More generally, these characters are ordered such that \fB"9"\fR comes before
\fB"A"\fR and \fB"Z"\fR comes before \fB"a"\fR.
In this order, the maximal \fBdistkey\fR, which does not come after the
character, specifies the blob's \fBkind\fR.
The difference between the character and the \fBdistkey\fR then specifies the
blob's \fBversion\fR.
.RS
.PP
Example 1:
In the special case, where the character exactly matches a \fBdistkey\fR,
\fBversion\fR is set to 0.
.PP
Example 2:
Suppose kind \fBapple\fR has \fBdistkey = "A"\fR, kind \fBorange\fR has
\fBdistkey = "O"\fR and no further \fBdistkey\fRs exist.
Then the character \fB"C"\fR denotes an apple with \fBversion=2\fR,
the character \fB"N"\fR denotes an apple with \fBversion=13\fR,
the character \fB"O"\fR denotes an orange with \fBversion=0\fR,
the character \fB"S"\fR denotes an orange with \fBversion=4\fR,
the character \fB"a"\fR denotes an orange with \fBversion=12\fR,
and the character \fB"8"\fR does not denote anything (and hence is illegal).
.RE
.TP
.B %
An info blop with the version set according to the level-wide neighbours.
.TP
.B &
An info blop with the version set according to the level-wide chaingrass.
.PP
The last line may have length 4, 8, 10, or 20.
If it has length 10 or 20, it is just a normal line as above.
Otherwise it describes the informational blops next to the field.
In case of length 4,
the first entry describes the blop which depicts the number of greys.
The second entry describes the blop which depicts the number of grass blops.
The third entry describes the blop which depicts connection information.
The fourth entry describes the blop whoch depicts chaingrass information.
In case of length 8, the above holds for the left player.
The remaining 4 entries then describe the same for the right player,
but in reversed order.
The default is "-*%&&%*-" (or equivalently "-*%&").
.PP
As seen above, startdist can reference 62 kind/version combinations
directly (and more at random).
Because this might at some time not be enough, the multichar extension
has been introduced.
In this case, each blob is described by more than one character.
However, the number of characters per blob must be the same for all keys.
Hence, the lengths of \fBstartdist\fR lines then must be this number
multiplied by 10 or by 20.
Every multicharacter combination starting with \fB"."\fR, \fB"+"\fR, \fB"\-"\fR,
or \fB"*"\fR is treated as the corresponding character in single-character
format.
All other character combinations are treated as numbers in base 62
representation.
Here, \fB"A"\fR to \fB"Z"\fR are digits with decimal value 10
to 35, and \fB"a"\fR to \fB"z"\fR are digits with decimal value 36 to 61.
Leading spaces are allowed instead of zeroes (however, the all-space string
is forbidden).
The maximal \fBdistkey\fR which (as a number) is not larger than the number
given in \fBstartdist\fR, specifies the blob's \fBkind\fR.
The difference between the \fBstartdist\fR number and the \fBdistkey\fR
then specifies the blob's \fBversion\fR.
In the case of multichar \fBdistkey\fRs, the default for \fBdistkey\fRs
of kinds declared by \fBstartpic=\fR is 10 in decimal.
.PP
For blops whose kinds are chosen at random (i.e. characters \fB"+"\fR,
\fB"\-"\fR, \fB"*"\fR in single-character \fBstartdist\fRs),
cuyo tries to make these as different as possible.
That means, by a certain heuristic, cuyo minimizes the number of neighbouring
blobs of the same kind.
"Neighbouring", of course, refers to the \fBneighbours\fR entry.
\fBinhibit\fR and the \fBcalculate_size\fR bit of
\fBbehaviour\fR have no effect (these are mutable during the lifetime of
blobs, while at the time of \fBstartdist\fR processing, no blob's lifetime
has started yet).
So the only way to influence the unneighbouring
(if you really wish to do so), is by setting \fBneighbours\fR appropriately.
(Of course, this possibility is even more limited, when you intend to
set the \fBcalculate_size\fR bit during the blob's lifetime.)
.
.SH WHERE DO I PUT THE CUAL CODE?
.
Cual procedures and variables can be defined in different sections of
the .ld files:
.TP 3
\(em
Outside of everything; that code is accessible from every level coming
after that definition.
.TP
\(em
In the section of a level.
.TP
\(em
In the section of a kind.
.PP
This basically does what you expect.
However, there's one thing you might want to know: Even if you define a variable inside a
kind, \fIevery\fR blob in that level will have that variable.
The only effect
of defining the variable in the section of a kind is that this kind is the
only one which can access it.
.
.SH AMPERSAND-CALL
.
To explain a bit what calling a procecure with an & means, here two examples:
.PP
\fIExample 1:\fR
.br
<<
.br
myblob = {
.br
...
.br
switch {
.br
myvar \-> { 0A*; 1; A,B,C,D; *; 2A*};
.br
\-> { 0B*; 1; A,B,C,D; *; 2B*};
.br
};
.br
};
.br
>>
.PP
\fIExample 2:\fR
.br
<<
.br
anim = {1; A,B,C,D; *};
.br
.br
myblob = {
.br
...
.br
switch {
.br
myvar \-> { 0A*; &anim; 2A*};
.br
\-> { 0B*; &anim; 2B*};
.br
};
.br
};
.br
>>
.PP
The difference between these examples is what happens when myvar changes.
In example 1, the animation "A, B, C, D" will restart at the beginning
(because the two animations are different ones); in example 2, the
"same" animation is used
in both cases, so the animation will simply continue.
(Removing the ampersands from example 2 will turn the behaviour to the
one of example 1.)
.
.SH THE AI UTILITY FUNCTION
.
When deciding how to place the steered falling blobs, the AI player tries to
maximize a certain utility function.
Its value is the sum of the values for both steered falling blobs
plus \fBaiu_monochromic_vertical\fR
in case both blobs have the same color and they get placed vertically.
The value for a single blob is the sum of the following:
.TP 3
\(em
For each new neighbour of blob, the neighbour utility.
.TP
\(em
\fBaiu_two_above\fR, if the blob is two above a blob of same kind.
.TP
\(em
\fBaiu_height*20/\fR(the blob's \fBy\fR coordinate).
.PP
The neighbour utility
for a single new blob and a single one of its new neighbours
is the sum of the following:
.TP 3
\(em
\fBaiu_color\fR, if the neighbour has the same kind as the blob.
.TP
\(em
\fBaiu_grass\fR, if the neighbour fulfills \fBbehaviour.goalblob\fR.
.TP
\(em
\fBaiu_grey\fR, if the neighbour fulfills \fBbehaviour.explodes_on_explosion\fR.
.
.SH SEE ALSO
.
\fBcuyo\fP(6)
.
.SH BUGS
.
Probably a lot.
The following are just a few known ones:
.PP
There are several problems with busieness and that stuff.
There are several situations in which Cual doesn't behave in the
way I would like, and in other situations I don't know how Cual should
behave.
|