1 % ------------------------------------------------------------------------------ 2 % File: dotsville_lls.pro 3 % Type: Prolog source 4 % Line: Dotsville - low level semantics 5 % Date: 2020 6 % Author: Miguel Cruz 7 % ------------------------------------------------------------------------------ 8 9 % ------------------------------------------------------------------------------ 10 % libraries 11 12 :- consult('dotsville.pro'). 13 :- consult('lp.pro'). 14 :- consult('gv.pro'). 15 16 % ------------------------------------------------------------------------------ 17 % just a few states of the world, the third of which is featured in the demos 18 19 state1 :- 20 clear_world, 21 add_dot(cell(1,1),color(blue)), 22 add_dot(cell(2,1),color(blue)), 23 add_dot(cell(1,3),color(red)), 24 add_dot(cell(2,3),color(yellow)), 25 add_dot(cell(3,3),color(orange)), 26 display_world. 27 28 state2 :- 29 clear_world, 30 add_dot(cell(1,1),color(red)), 31 add_dot(cell(1,2),color(blue)), 32 add_dot(cell(2,2),color(red)), 33 display_world. 34 35 state3 :- 36 clear_world, 37 add_dot(cell(1,2),color(yellow)), 38 add_dot(cell(1,4),color(red)), 39 add_dot(cell(2,4),color(red)), 40 add_dot(cell(1,6),color(blue)), 41 add_dot(cell(2,6),color(green)), 42 add_dot(cell(3,6),color(blue)), 43 add_dot(cell(4,6),color(green)), 44 display_world. 45 46 % ------------------------------------------------------------------------- Task #1 47 % exists_dot_of_color(Color) 48 % --- succeeds if there is a dot of color Color 49 50 % --> Task 1: Define the method here (Completed) 51 52 exists_dot_of_color(Color) :- 53 dot(_,color(Color)). 54 55 demo__exists_dot_of_color :- 56 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: exists_dot_of_color'), nl, 57 state3, 58 exists_dot_of_color(blue), 59 write('>>> there is a blue dot'),nl, 60 not(exists_dot_of_color(purple)), 61 write('>>> there is no purple dot'),nl. 62 63 % ------------------------------------------------------------------------- Task #2 64 % exists_dot_of_color_on_table(Color) 65 % --- succeeds if there is a dot of color Color 66 67 % --> Task 2: Define the method here (Completed) 68 69 exists_dot_of_color_on_table(Color) :- 70 dot(cell(1,_),color(Color)). 71 72 demo__exists_dot_of_color_on_table :- 73 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: exists_dot_of_color_on_table'), nl, 74 state3, 75 exists_dot_of_color_on_table(blue), 76 write('>>> there is a blue dot on the table'),nl, 77 not(exists_dot_of_color_on_table(green)), 78 write('>>> there is no green dot on the table'),nl. 79 80 % ------------------------------------------------------------------------- Task #3 81 % exists_dot_left_of(Color1,Color2) 82 % --- succeeds if there is a dot of Color1 to the left of a dot of Color2 83 84 % --> Task 3: Define the method here (Completed) 85 86 exists_dot_left_of(Color1,Color2) :- 87 dot(cell(_,Column1),color(Color1)), 88 dot(cell(_,Column2),color(Color2)), 89 Column1 < Column2. 90 91 demo__exists_dot_left_of :- 92 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: exists_dot_left_of'), nl, 93 state3, 94 exists_dot_left_of(red,blue), 95 write('>>> there is a red dot to the left of a blue dot'),nl, 96 not(exists_dot_left_of(blue,red)), 97 write('>>> there is not a blue dot to the left of a red dot.'),nl. 98 99 % ------------------------------------------------------------------------- Task #4 100 % exists_dot_right_of(Color1,Color2) 101 % --- succeeds if there is a dot of Color1 to the right of a dot of Color2 102 103 % --> Task 4: Define the method here (Completed) 104 105 exists_dot_right_of(Color1,Color2) :- 106 dot(cell(_,Column1),color(Color1)), 107 dot(cell(_,Column2),color(Color2)), 108 Column1 > Column2. 109 110 demo__exists_dot_right_of :- 111 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: exists_dot_right_of'), nl, 112 state3, 113 exists_dot_right_of(blue,red), 114 write('>>> there is a blue dot to the right of a red dot'),nl, 115 not(exists_dot_right_of(red,blue)), 116 write('>>> there is not a red dot to the right of a blue dot.'),nl. 117 118 % ------------------------------------------------------------------------- Task #5 119 % list_dots_of_color(Color) 120 % --- lists all of the dots of color Color 121 122 % --> Task 5: Just study this code, and carefully enter it into your file (Completed) 123 124 list_dots_of_color(Color) :- 125 dot(cell(R,C),color(Color)), 126 write(dot(cell(R,C),color(Color))), nl, 127 fail. 128 list_dots_of_color(_). 129 130 demo__list_dots_of_color :- 131 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: list_dots_of_color'), nl, 132 state3, 133 write('>>> these are the blue dots ...'),nl, 134 list_dots_of_color(blue), 135 write('>>> these are the red dots ...'),nl, 136 list_dots_of_color(red), 137 write('>>> these are the purple dots ...'),nl, 138 list_dots_of_color(purple). 139 140 % ------------------------------------------------------------------------- Task #6 141 % list_dots_in_column(Column) 142 % --- lists all of the dots in column Column 143 144 % --> Task 6: Define the method here (Completed) 145 146 list_dots_in_column(Column) :- 147 dot(cell(R,Column),color(Color)), 148 R > 0, 149 write(dot(cell(R,Column),color(Color))), nl, 150 fail. 151 list_dots_in_column(_). 152 153 demo__list_dots_in_column :- 154 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: list_dots_in_column'), nl, 155 state3, 156 write('>>> these are the dots in column 1 ...'),nl, 157 list_dots_in_column(1), 158 write('>>> these are the dots in column 2 ...'),nl, 159 list_dots_in_column(2), 160 write('>>> these are the dots in column 3 ...'),nl, 161 list_dots_in_column(3), 162 write('>>> these are the dots in column 4 ...'),nl, 163 list_dots_in_column(4), 164 write('>>> these are the dots in column 5 ...'),nl, 165 list_dots_in_column(5), 166 write('>>> these are the dots in column 6 ...'),nl, 167 list_dots_in_column(6). 168 169 % ------------------------------------------------------------------------- Task #7 170 % add_dot_to_column(Column,Color) 171 % --- add a dot of the given Color to the given Column 172 173 % --> Task 7: Just study this code, and carefully enter it into your file (Completed) 174 175 add_dot_to_column(Column,Color) :- 176 not(dot(cell(1,Column),_)), 177 add_dot(cell(1,Column),color(Color)). 178 add_dot_to_column(Column,Color) :- 179 not(dot(cell(2,Column),_)), 180 add_dot(cell(2,Column),color(Color)). 181 add_dot_to_column(Column,Color) :- 182 not(dot(cell(3,Column),_)), 183 add_dot(cell(3,Column),color(Color)). 184 add_dot_to_column(Column,Color) :- 185 not(dot(cell(4,Column),_)), 186 add_dot(cell(4,Column),color(Color)). 187 add_dot_to_column(Column,_) :- 188 write('### no room to add a dot to column '),write(Column),nl. 189 190 demo__add_dot_to_column :- 191 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: add_dot_to_column'), nl, 192 state3, 193 add_dot_to_column(2,red), 194 add_dot_to_column(4,purple), 195 add_dot_to_column(6,yellow), 196 write('>>> after adding red and purple dots to columns 2 and 4: '), nl, 197 display_world. 198 199 % ------------------------------------------------------------------------ Task #8 200 % add_random_dot(Row,Col) 201 % --- add a randomly colored dot in row Row and column Col 202 203 % --> Task 8: Define the method here (Completed) 204 205 add_random_dot(Row,Col) :- 206 pick([red,blue,yellow,orange,purple,green],Color), 207 not(dot(cell(Row,Col),_)), 208 add_dot(cell(Row,Col),color(Color)). 209 210 demo__add_random_dot :- 211 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: add_random_dot'), nl, 212 state3, 213 add_random_dot(1,1), 214 add_random_dot(2,1), 215 add_random_dot(3,1), 216 add_random_dot(4,1), 217 add_random_dot(1,3), 218 add_random_dot(2,3), 219 add_random_dot(3,3), 220 add_random_dot(4,3), 221 write('>>> the world after filling columns 1 and 3 with random dots ...'),nl, 222 display_world. 223 224 % ------------------------------------------------------------------------- Task #9 225 % remove_dot_from_column(Column) 226 % --- succeeds if there is at least one dot in a column by removing top dot 227 228 % --> Task 9: Just study this code, and carefully enter it into your file (Completed) 229 230 remove_dot_from_column(Column) :- 231 dot(cell(4,Column),_), retract(dot(cell(4,Column),_) ). 232 remove_dot_from_column(Column) :- 233 dot(cell(3,Column),_), retract(dot(cell(3,Column),_) ). 234 remove_dot_from_column(Column) :- 235 dot(cell(2,Column),_), retract(dot(cell(2,Column),_) ). 236 remove_dot_from_column(Column) :- 237 dot(cell(1,Column),_), retract(dot(cell(1,Column),_) ). 238 remove_dot_from_column(Column) :- 239 write('### There is no dot in column '), write(Column), write(' to remove.'), nl. 240 241 demo__remove_dot_from_column :- 242 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: remove_dot_from_column'), nl, 243 state3, 244 remove_dot_from_column(1), 245 remove_dot_from_column(2), 246 remove_dot_from_column(3), 247 remove_dot_from_column(4), 248 remove_dot_from_column(5), 249 remove_dot_from_column(6), 250 write('>>> after removing a dot from each nonempty column ...'),nl, 251 display_world. 252 253 254 % ------------------------------------------------------------------------- Task #10 255 % count_dots_in_column(Column,Count) 256 % --- returns the number of dots in the given column 257 258 % --> Task 10: Define the method here (Completed) 259 260 count_dots_in_column(Column,4) :- 261 dot(cell(4,Column),_). 262 count_dots_in_column(Column,3) :- 263 dot(cell(3,Column),_). 264 count_dots_in_column(Column,2) :- 265 dot(cell(2,Column),_). 266 count_dots_in_column(Column,1) :- 267 dot(cell(1,Column),_). 268 count_dots_in_column(Column,0) :- 269 dot(cell(0,Column),_). 270 271 demo__count_dots_in_column :- 272 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: count_dots_in_column'), nl, 273 state3, 274 count_dots_in_column(1,Count1), 275 write('>>> number of dots in column 1: '), write(Count1), nl, 276 count_dots_in_column(2,Count2), 277 write('>>> number of dots in column 2: '), write(Count2), nl, 278 count_dots_in_column(3,Count3), 279 write('>>> number of dots in column 3: '), write(Count3), nl, 280 count_dots_in_column(4,Count4), 281 write('>>> number of dots in column 4: '), write(Count4), nl, 282 count_dots_in_column(5,Count5), 283 write('>>> number of dots in column 5: '), write(Count5), nl, 284 count_dots_in_column(6,Count6), 285 write('>>> number of dots in column 6: '), write(Count6), nl. 286 287 % ------------------------------------------------------------------------- Task #11 288 % count_dots(Count) 289 % --- returns the number of dots in the world 290 291 % --> Task 11: Define the method here (Completed) 292 293 count_dots(Count) :- 294 count_dots_in_column(1,Count1), 295 count_dots_in_column(2,Count2), 296 count_dots_in_column(3,Count3), 297 count_dots_in_column(4,Count4), 298 count_dots_in_column(5,Count5), 299 count_dots_in_column(6,Count6), 300 Count is Count1 + Count2 + Count3 + Count4 + Count5 + Count6. 301 302 demo__count_dots :- 303 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: count_dots'), nl, 304 state3, 305 count_dots(Count), 306 write('>>> number of dots in the world: '), write(Count), nl. 307 308 % ------------------------------------------------------------------------- Task #12 309 % available_space_count_in_column(Column,Count) 310 % --- returns the number available spaces in the given column 311 312 % --> Task 12: Define the method here (Completed) 313 314 available_space_count_in_column(Column,Count) :- 315 count_dots_in_column(Column,C), 316 Count is 4 - C. 317 318 demo__available_space_count_in_column :- 319 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: available_space_count_in_column'), nl, 320 state3, 321 available_space_count_in_column(1,Count1), 322 write('>>> space available in column 1: '), write(Count1), nl, 323 available_space_count_in_column(2,Count2), 324 write('>>> space available in column 2: '), write(Count2), nl, 325 available_space_count_in_column(3,Count3), 326 write('>>> space available in column 3: '), write(Count3), nl, 327 available_space_count_in_column(4,Count4), 328 write('>>> space available in column 4: '), write(Count4), nl, 329 available_space_count_in_column(5,Count5), 330 write('>>> space available in column 5: '), write(Count5), nl, 331 available_space_count_in_column(6,Count6), 332 write('>>> space available in column 6: '), write(Count6), nl. 333 334 % ------------------------------------------------------------------------- Task #13 335 % available_space_count(Count) 336 % --- returns the number of dots available in the world 337 338 % --> Task 13: Define the method here (Completed) 339 340 available_space_count(Count) :- 341 available_space_count_in_column(1,Count1), 342 available_space_count_in_column(2,Count2), 343 available_space_count_in_column(3,Count3), 344 available_space_count_in_column(4,Count4), 345 available_space_count_in_column(5,Count5), 346 available_space_count_in_column(6,Count6), 347 Count is Count1 + Count2 + Count3 + Count4 + Count5 + Count6. 348 349 demo__available_space_count :- 350 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: available_space_count'), nl, 351 state3, 352 available_space_count(Count), 353 write('>>> number of spaces available in the world: '), write(Count), nl. 354 355 % ------------------------------------------------------------------------- Task #14 356 % fill_column(Column) 357 % --- fill the specified column with randomly colored dots 358 359 % --> Task 14: Just study this code, and carefully enter it into your file (Completed) 360 361 fill_column(Column) :- 362 available_space_count_in_column(Column,Count), 363 add_random_dots_to_column(Column,Count). 364 365 add_random_dots_to_column(_,0). 366 add_random_dots_to_column(Column,N) :- 367 add_random_dot_to_column(Column), 368 NM1 is N-1, 369 add_random_dots_to_column(Column,NM1). 370 371 add_random_dot_to_column(Column) :- 372 not(dot(cell(1,Column),_)), 373 add_random_dot(1,Column). 374 add_random_dot_to_column(Column) :- 375 not(dot(cell(2,Column),_)), 376 add_random_dot(2,Column). 377 add_random_dot_to_column(Column) :- 378 not(dot(cell(3,Column),_)), 379 add_random_dot(3,Column). 380 add_random_dot_to_column(Column) :- 381 not(dot(cell(4,Column),_)), 382 add_random_dot(4,Column). 383 add_random_dot_to_column(Column) :- 384 write('### no room to add a random dot to column '),write(Column),nl. 385 386 demo__fill_column :- 387 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: fill_column'), nl, 388 state3, 389 fill_column(1), 390 fill_column(2), 391 fill_column(3), 392 fill_column(4), 393 fill_column(5), 394 fill_column(6), 395 write('>>> the world after filling all of the columns: '), nl, 396 display_world. 397 398 % ------------------------------------------------------------------------- Task #15 399 % fill_world 400 % --- fill the world with randomly colored dots 401 402 %--> Task 15: Define the method here (Completed) 403 404 fill_world :- 405 fill_column(1), 406 fill_column(2), 407 fill_column(3), 408 fill_column(4), 409 fill_column(5), 410 fill_column(6). 411 412 demo__fill_world :- 413 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: fill_world'), nl, 414 state3, 415 fill_world, 416 write('>>> after filling the world: '), nl, 417 display_world. 418 419 % ------------------------------------------------------------------------- Task #16 420 % sprinkle_dots(NumberOfDots) 421 % --- sprinkle so many randomly colored dots into random columns 422 423 % --> Task 16: Just study this code, and carefully enter it into your file (Completed) 424 425 sprinkle_dots(0). 426 sprinkle_dots(N) :- 427 available_space_count(Count), 428 N > Count, 429 write('### not enough space available in the world for the sprinkling.'), nl. 430 sprinkle_dots(N) :- 431 sprinkle_the_dots_for_real(N). 432 433 sprinkle_the_dots_for_real(0). 434 sprinkle_the_dots_for_real(N) :- 435 sprinkle_one_dot, 436 NM1 is N-1, 437 sprinkle_the_dots_for_real(NM1). 438 439 sprinkle_one_dot :- 440 available_spaces(S), 441 pick(S,space(Row,Column)), 442 add_random_dot(Row,Column). 443 444 available_spaces(ListOfSpaces) :- 445 available_spaces(1,ListOfSpaces). 446 447 available_spaces(6,[Space]) :- 448 available_space_count_in_column(6,Count), 449 Count > 0, 450 nextSpace(6,Space). 451 available_spaces(6,[]). 452 453 available_spaces(C,ListOfSpacesC) :- 454 available_space_count_in_column(C,Count), 455 Count > 0, 456 nextSpace(C,Space), 457 D is C + 1, 458 available_spaces(D,ListOfSpacesD), 459 ListOfSpacesC = [Space|ListOfSpacesD]. 460 available_spaces(C,ListOfSpacesC) :- 461 D is C + 1, 462 available_spaces(D,ListOfSpacesD), 463 ListOfSpacesC = ListOfSpacesD. 464 465 nextSpace(Column,space(1,Column)) :- not(dot(cell(1,Column),_)). 466 nextSpace(Column,space(2,Column)) :- not(dot(cell(2,Column),_)). 467 nextSpace(Column,space(3,Column)) :- not(dot(cell(3,Column),_)). 468 nextSpace(Column,space(4,Column)) :- not(dot(cell(4,Column),_)). 469 470 demo__sprinkle_dots :- 471 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: sprinkle_dots'), nl, 472 clear_world, 473 display_world, 474 sprinkle_dots(12), 475 write('>>> after sprinkling 12 dots on the empty world: '), nl, 476 display_world, 477 clear_world, 478 write('>>> after clearning the world: '), nl, 479 display_world, 480 sprinkle_dots(12), 481 write('>>> after sprinkling 12 dots on the empty world: '), nl, 482 display_world. 483 484 % ------------------------------------------------------------------------- Task #17 485 % is_empty_column(Column) 486 % --- succeed if the specified column is empty 487 488 % --> Task 17: Define the method here (Completed) 489 490 is_empty_column(0). 491 is_empty_column(Column):- 492 available_space_count_in_column(Column,Count), 493 Empty is Count - 4, 494 Empty < 0,!,fail. 495 is_empty_column(Column):- 496 available_space_count_in_column(Column,Count), 497 Empty is Count - 4, 498 Empty = 0,!. 499 500 demo__is_empty_column :- 501 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: is_empty_column'), nl, 502 state3, 503 is_empty_column(3), 504 write('>>> column 3 is empty '), nl, 505 not(is_empty_column(4)), 506 write('>>> column 4 is not empty '), nl. 507 508 % ------------------------------------------------------------------------- Task #18 509 % is_full_column(Column) 510 % --- succeed if the specified column is full 511 512 % --> Task 18: Define the method here (Completed) 513 514 is_full_column(0). 515 is_full_column(Column):- 516 available_space_count_in_column(Column,Count), 517 Count > 4,!,fail. 518 is_full_column(Column):- 519 available_space_count_in_column(Column,Count), 520 Count = 0,!. 521 522 demo__is_full_column :- 523 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: is_full_column'), nl, 524 state3, 525 not(is_full_column(4)), 526 write('>>> column 4 is not full '), nl, 527 not(is_full_column(5)), 528 write('>>> column 5 is not full '), nl, 529 is_full_column(6), 530 write('>>> column 6 is full '), nl. 531 532 % ------------------------------------------------------------------------- Task #19 533 % move_dot_from_column_to_column(Column1,Column2) 534 % --- move a dot from Column1 to Column2, if possible 535 536 % --> Task 19: Just study this code, and carefully enter it into your file (Completed) 537 538 move_dot_from_column_to_column(Column1,Column2) :- 539 not(is_empty_column(Column1)), 540 not(is_full_column(Column2)), 541 top_dot(Column1,dot(_,color(Color))), 542 remove_dot_from_column(Column1), 543 add_dot_to_column(Column2,Color). 544 545 top_dot(Column,Dot) :- 546 dot(cell(4,Column),color(Color)), Dot = dot(cell(4,Column),color(Color)). 547 top_dot(Column,Dot) :- 548 dot(cell(3,Column),color(Color)), Dot = dot(cell(3,Column),color(Color)). 549 top_dot(Column,Dot) :- 550 dot(cell(2,Column),color(Color)), Dot = dot(cell(2,Column),color(Color)). 551 top_dot(Column,Dot) :- 552 dot(cell(1,Column),color(Color)), Dot = dot(cell(1,Column),color(Color)). 553 554 555 demo__move_dot_from_column_to_column :- 556 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: move_dot_from_column_to_column'), nl, 557 state3, 558 move_dot_from_column_to_column(2,1), 559 move_dot_from_column_to_column(4,1), 560 move_dot_from_column_to_column(6,1), 561 move_dot_from_column_to_column(4,6), 562 write('after moving dots from columns 2 to 1, 4 to 2, 6 to 1, and 4 to 6'),nl, 563 display_world. 564 565 566 % ------------------------------------------------------------------------- Task #20 567 % count_dots_of_color_in_column(Color,Column,Count) 568 % --- count the number of dots of a particular Color in the given Column 569 570 % --> Task 20: Just study this code, and carefully enter it into your file (Completed) 571 572 count_dots_of_color_in_column(Color,Column,Count) :- 573 declare(count,0), 574 count_the_colored_dots_in_the_column(Color,Column), 575 valueOf(count,Count), 576 undeclare(count). 577 578 count_the_colored_dots_in_the_column(Color,Column) :- 579 dot(cell(_,Column),color(Color)), 580 inc(count), 581 fail. 582 count_the_colored_dots_in_the_column(_,_). 583 584 demo__count_the_colored_dots_in_the_column :- 585 nl, nl, write('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> demo: count_the_colored_dots_in_the_column'), nl, 586 fill_world, 587 display_world, 588 count_dots_of_color_in_column(blue,1,CountBlue1), 589 write('>>> number of blue dots in column 1 = '), write(CountBlue1), nl, 590 count_dots_of_color_in_column(blue,2,CountBlue2), 591 write('>>> number of blue dots in column 2 = '), write(CountBlue2), nl, 592 count_dots_of_color_in_column(blue,3,CountBlue3), 593 write('>>> number of blue dots in column 3 = '), write(CountBlue3), nl, 594 count_dots_of_color_in_column(blue,4,CountBlue4), 595 write('>>> number of blue dots in column 4 = '), write(CountBlue4), nl, 596 count_dots_of_color_in_column(blue,5,CountBlue5), 597 write('>>> number of blue dots in column 5 = '), write(CountBlue5), nl, 598 count_dots_of_color_in_column(blue,6,CountBlue6), 599 write('>>> number of blue dots in column 6 = '), write(CountBlue6), nl, 600 fill_world, 601 display_world, 602 count_dots_of_color_in_column(purple,1,CountPurple1), 603 write('>>> number of purple dots in column 1 = '), write(CountPurple1), nl, 604 count_dots_of_color_in_column(purple,2,CountPurple2), 605 write('>>> number of purple dots in column 2 = '), write(CountPurple2), nl, 606 count_dots_of_color_in_column(purple,3,CountPurple3), 607 write('>>> number of purple dots in column 3 = '), write(CountPurple3), nl, 608 count_dots_of_color_in_column(purple,4,CountPurple4), 609 write('>>> number of purple dots in column 4 = '), write(CountPurple4), nl, 610 count_dots_of_color_in_column(purple,5,CountPurple5), 611 write('>>> number of purple dots in column 5 = '), write(CountPurple5), nl, 612 count_dots_of_color_in_column(purple,6,CountPurple6), 613 write('>>> number of purple dots in column 6 = '), write(CountPurple6), nl. 614 615 616 % ------------------------------------------------------------------------- 617 % ------------------------------------------------------------------------- 618 % demos 619 % --- run all of the demos 620 621 demos :- 622 nl, write('>>> beginning of demos'), nl, nl, 623 demo__exists_dot_of_color, 624 demo__exists_dot_of_color_on_table, 625 demo__exists_dot_left_of, 626 demo__exists_dot_right_of, 627 demo__list_dots_of_color, 628 demo__list_dots_in_column, 629 demo__add_dot_to_column, 630 demo__add_random_dot, 631 demo__remove_dot_from_column, 632 demo__count_dots_in_column, 633 demo__count_dots, 634 demo__available_space_count_in_column, 635 demo__available_space_count, 636 demo__fill_column, 637 demo__fill_world, 638 demo__sprinkle_dots, 639 demo__is_empty_column, 640 demo__is_full_column, 641 demo__move_dot_from_column_to_column, 642 demo__count_the_colored_dots_in_the_column, 643 nl, write('>>> end of demos'), nl. 644 645