home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lifeos2.zip / LIFE-1.02 / PITCH / WILDLIFE.SAV < prev    next >
Text File  |  1996-06-19  |  52KB  |  2,767 lines

  1. dynamic(is_out)?
  2. is_out(dummy).
  3. bind_deck(0,[5,
  4. 11,
  5. 12,
  6. 40,
  7. 16,
  8. 2,
  9. 15,
  10. 21,
  11. 30,
  12. 36,
  13. 45,
  14. 22,
  15. 6,
  16. 8,
  17. 19,
  18. 23,
  19. 20,
  20. 9,
  21. 24,
  22. 26,
  23. 27,
  24. 29,
  25. 10,
  26. 32,
  27. 0,
  28. 46,
  29. 38,
  30. 48,
  31. 51,
  32. 52,
  33. 17,
  34. 18,
  35. 25,
  36. 35,
  37. 43,
  38. 13,
  39. 4,
  40. 1,
  41. 7,
  42. 33,
  43. 39,
  44. 28,
  45. 44,
  46. 47,
  47. 3,
  48. 53,
  49. 42,
  50. 50,
  51. 34,
  52. 49,
  53. 14,
  54. 31,
  55. 37,
  56. 41]).
  57. bind_deck(1,[53,
  58. 52,
  59. 49,
  60. 30,
  61. 15,
  62. 29,
  63. 44,
  64. 51,
  65. 50,
  66. 7,
  67. 19,
  68. 48,
  69. 8,
  70. 13,
  71. 16,
  72. 14,
  73. 0,
  74. 24,
  75. 40,
  76. 43,
  77. 6,
  78. 28,
  79. 45,
  80. 5,
  81. 22,
  82. 37,
  83. 47,
  84. 46,
  85. 42,
  86. 41,
  87. 3,
  88. 11,
  89. 20,
  90. 21,
  91. 25,
  92. 26,
  93. 10,
  94. 23,
  95. 18,
  96. 27,
  97. 32,
  98. 34,
  99. 12,
  100. 36,
  101. 17,
  102. 9,
  103. 38,
  104. 33,
  105. 1,
  106. 35,
  107. 39,
  108. 4,
  109. 31,
  110. 2]).
  111. bind_deck(2,[34,
  112. 33,
  113. 31,
  114. 53,
  115. 32,
  116. 38,
  117. 43,
  118. 12,
  119. 26,
  120. 36,
  121. 21,
  122. 5,
  123. 17,
  124. 29,
  125. 35,
  126. 37,
  127. 44,
  128. 45,
  129. 41,
  130. 15,
  131. 46,
  132. 52,
  133. 51,
  134. 9,
  135. 50,
  136. 49,
  137. 48,
  138. 47,
  139. 27,
  140. 4,
  141. 16,
  142. 11,
  143. 10,
  144. 25,
  145. 42,
  146. 40,
  147. 0,
  148. 18,
  149. 2,
  150. 3,
  151. 7,
  152. 8,
  153. 19,
  154. 1,
  155. 6,
  156. 14,
  157. 22,
  158. 23,
  159. 30,
  160. 24,
  161. 20,
  162. 28,
  163. 39,
  164. 13]).
  165. bind_deck(3,[6,
  166. 34,
  167. 21,
  168. 17,
  169. 38,
  170. 15,
  171. 1,
  172. 7,
  173. 13,
  174. 10,
  175. 24,
  176. 2,
  177. 9,
  178. 26,
  179. 28,
  180. 35,
  181. 14,
  182. 39,
  183. 43,
  184. 23,
  185. 44,
  186. 45,
  187. 30,
  188. 37,
  189. 4,
  190. 50,
  191. 51,
  192. 0,
  193. 46,
  194. 41,
  195. 20,
  196. 32,
  197. 25,
  198. 19,
  199. 11,
  200. 12,
  201. 22,
  202. 29,
  203. 40,
  204. 42,
  205. 47,
  206. 16,
  207. 5,
  208. 31,
  209. 36,
  210. 3,
  211. 52,
  212. 18,
  213. 8,
  214. 27,
  215. 53,
  216. 49,
  217. 33,
  218. 48]).
  219. bind_deck(4,[53,
  220. 0,
  221. 14,
  222. 15,
  223. 17,
  224. 37,
  225. 51,
  226. 16,
  227. 18,
  228. 32,
  229. 52,
  230. 5,
  231. 23,
  232. 44,
  233. 10,
  234. 24,
  235. 50,
  236. 11,
  237. 28,
  238. 2,
  239. 34,
  240. 38,
  241. 41,
  242. 30,
  243. 9,
  244. 49,
  245. 48,
  246. 6,
  247. 33,
  248. 25,
  249. 47,
  250. 26,
  251. 46,
  252. 45,
  253. 43,
  254. 42,
  255. 3,
  256. 31,
  257. 7,
  258. 29,
  259. 35,
  260. 1,
  261. 20,
  262. 39,
  263. 27,
  264. 4,
  265. 8,
  266. 12,
  267. 13,
  268. 21,
  269. 22,
  270. 19,
  271. 36,
  272. 40]).
  273. bind_deck(5,[38,
  274. 41,
  275. 52,
  276. 0,
  277. 36,
  278. 11,
  279. 19,
  280. 26,
  281. 37,
  282. 12,
  283. 44,
  284. 45,
  285. 5,
  286. 17,
  287. 31,
  288. 49,
  289. 2,
  290. 7,
  291. 21,
  292. 46,
  293. 50,
  294. 10,
  295. 13,
  296. 16,
  297. 6,
  298. 20,
  299. 3,
  300. 27,
  301. 9,
  302. 29,
  303. 1,
  304. 30,
  305. 4,
  306. 22,
  307. 24,
  308. 32,
  309. 14,
  310. 18,
  311. 23,
  312. 25,
  313. 33,
  314. 35,
  315. 39,
  316. 8,
  317. 34,
  318. 43,
  319. 28,
  320. 48,
  321. 47,
  322. 42,
  323. 15,
  324. 51,
  325. 53,
  326. 40]).
  327. bind_deck(6,[3,
  328. 9,
  329. 29,
  330. 32,
  331. 36,
  332. 39,
  333. 40,
  334. 25,
  335. 2,
  336. 17,
  337. 27,
  338. 31,
  339. 7,
  340. 4,
  341. 24,
  342. 23,
  343. 14,
  344. 10,
  345. 13,
  346. 35,
  347. 38,
  348. 11,
  349. 21,
  350. 0,
  351. 15,
  352. 22,
  353. 26,
  354. 12,
  355. 19,
  356. 28,
  357. 41,
  358. 43,
  359. 1,
  360. 30,
  361. 18,
  362. 20,
  363. 33,
  364. 44,
  365. 46,
  366. 48,
  367. 34,
  368. 50,
  369. 47,
  370. 6,
  371. 16,
  372. 37,
  373. 49,
  374. 51,
  375. 52,
  376. 42,
  377. 53,
  378. 5,
  379. 45,
  380. 8]).
  381. bind_deck(7,[9,
  382. 7,
  383. 53,
  384. 52,
  385. 46,
  386. 5,
  387. 4,
  388. 6,
  389. 18,
  390. 16,
  391. 14,
  392. 25,
  393. 35,
  394. 36,
  395. 42,
  396. 43,
  397. 47,
  398. 40,
  399. 31,
  400. 2,
  401. 51,
  402. 38,
  403. 44,
  404. 32,
  405. 23,
  406. 24,
  407. 26,
  408. 13,
  409. 17,
  410. 50,
  411. 49,
  412. 29,
  413. 37,
  414. 48,
  415. 45,
  416. 15,
  417. 27,
  418. 1,
  419. 28,
  420. 8,
  421. 20,
  422. 22,
  423. 12,
  424. 33,
  425. 11,
  426. 10,
  427. 34,
  428. 3,
  429. 39,
  430. 21,
  431. 30,
  432. 19,
  433. 0,
  434. 41]).
  435. bind_deck(8,[31,
  436. 43,
  437. 53,
  438. 52,
  439. 1,
  440. 51,
  441. 50,
  442. 49,
  443. 48,
  444. 25,
  445. 39,
  446. 36,
  447. 47,
  448. 24,
  449. 46,
  450. 45,
  451. 2,
  452. 29,
  453. 20,
  454. 28,
  455. 22,
  456. 12,
  457. 26,
  458. 27,
  459. 40,
  460. 42,
  461. 5,
  462. 8,
  463. 17,
  464. 21,
  465. 38,
  466. 34,
  467. 4,
  468. 10,
  469. 33,
  470. 6,
  471. 18,
  472. 37,
  473. 3,
  474. 44,
  475. 23,
  476. 41,
  477. 13,
  478. 11,
  479. 16,
  480. 19,
  481. 15,
  482. 7,
  483. 30,
  484. 32,
  485. 35,
  486. 0,
  487. 14,
  488. 9]).
  489. bind_deck(9,[53,
  490. 52,
  491. 15,
  492. 26,
  493. 19,
  494. 38,
  495. 2,
  496. 11,
  497. 6,
  498. 0,
  499. 8,
  500. 16,
  501. 18,
  502. 22,
  503. 28,
  504. 5,
  505. 29,
  506. 32,
  507. 1,
  508. 30,
  509. 34,
  510. 35,
  511. 37,
  512. 39,
  513. 36,
  514. 44,
  515. 9,
  516. 21,
  517. 17,
  518. 27,
  519. 42,
  520. 45,
  521. 7,
  522. 10,
  523. 46,
  524. 23,
  525. 43,
  526. 47,
  527. 12,
  528. 4,
  529. 13,
  530. 20,
  531. 25,
  532. 31,
  533. 41,
  534. 24,
  535. 48,
  536. 3,
  537. 49,
  538. 14,
  539. 33,
  540. 40,
  541. 50,
  542. 51]).
  543. bind_deck(10,[9,
  544. 11,
  545. 26,
  546. 53,
  547. 52,
  548. 13,
  549. 28,
  550. 2,
  551. 10,
  552. 30,
  553. 0,
  554. 17,
  555. 22,
  556. 41,
  557. 6,
  558. 4,
  559. 18,
  560. 33,
  561. 34,
  562. 3,
  563. 5,
  564. 37,
  565. 46,
  566. 12,
  567. 15,
  568. 16,
  569. 24,
  570. 25,
  571. 32,
  572. 19,
  573. 39,
  574. 35,
  575. 47,
  576. 1,
  577. 48,
  578. 51,
  579. 36,
  580. 43,
  581. 8,
  582. 50,
  583. 40,
  584. 29,
  585. 44,
  586. 20,
  587. 49,
  588. 27,
  589. 14,
  590. 31,
  591. 7,
  592. 21,
  593. 38,
  594. 42,
  595. 45,
  596. 23]).
  597. bind_deck(11,[9,
  598. 22,
  599. 24,
  600. 32,
  601. 39,
  602. 23,
  603. 21,
  604. 17,
  605. 40,
  606. 47,
  607. 2,
  608. 8,
  609. 53,
  610. 10,
  611. 33,
  612. 28,
  613. 4,
  614. 16,
  615. 13,
  616. 29,
  617. 44,
  618. 51,
  619. 52,
  620. 15,
  621. 26,
  622. 30,
  623. 14,
  624. 50,
  625. 48,
  626. 49,
  627. 3,
  628. 31,
  629. 37,
  630. 46,
  631. 27,
  632. 5,
  633. 1,
  634. 35,
  635. 20,
  636. 0,
  637. 6,
  638. 11,
  639. 12,
  640. 34,
  641. 36,
  642. 7,
  643. 38,
  644. 41,
  645. 45,
  646. 43,
  647. 18,
  648. 25,
  649. 19,
  650. 42]).
  651. bind_deck(12,[53,
  652. 11,
  653. 30,
  654. 26,
  655. 32,
  656. 1,
  657. 8,
  658. 45,
  659. 52,
  660. 29,
  661. 16,
  662. 28,
  663. 15,
  664. 33,
  665. 19,
  666. 34,
  667. 35,
  668. 39,
  669. 42,
  670. 43,
  671. 48,
  672. 21,
  673. 22,
  674. 49,
  675. 12,
  676. 50,
  677. 46,
  678. 6,
  679. 24,
  680. 4,
  681. 51,
  682. 9,
  683. 18,
  684. 13,
  685. 7,
  686. 10,
  687. 31,
  688. 5,
  689. 27,
  690. 20,
  691. 25,
  692. 36,
  693. 40,
  694. 38,
  695. 23,
  696. 0,
  697. 3,
  698. 37,
  699. 41,
  700. 14,
  701. 44,
  702. 17,
  703. 47,
  704. 2]).
  705. bind_deck(13,[53,
  706. 19,
  707. 0,
  708. 9,
  709. 25,
  710. 52,
  711. 2,
  712. 11,
  713. 17,
  714. 13,
  715. 20,
  716. 21,
  717. 37,
  718. 23,
  719. 51,
  720. 50,
  721. 10,
  722. 33,
  723. 45,
  724. 18,
  725. 35,
  726. 46,
  727. 4,
  728. 14,
  729. 27,
  730. 34,
  731. 15,
  732. 12,
  733. 26,
  734. 38,
  735. 42,
  736. 36,
  737. 32,
  738. 47,
  739. 40,
  740. 3,
  741. 6,
  742. 7,
  743. 30,
  744. 44,
  745. 43,
  746. 16,
  747. 22,
  748. 28,
  749. 29,
  750. 8,
  751. 31,
  752. 1,
  753. 5,
  754. 24,
  755. 41,
  756. 39,
  757. 48,
  758. 49]).
  759. bind_deck(14,[53,
  760. 32,
  761. 8,
  762. 24,
  763. 26,
  764. 52,
  765. 51,
  766. 50,
  767. 2,
  768. 49,
  769. 17,
  770. 36,
  771. 39,
  772. 41,
  773. 27,
  774. 16,
  775. 48,
  776. 10,
  777. 12,
  778. 18,
  779. 19,
  780. 23,
  781. 5,
  782. 7,
  783. 14,
  784. 21,
  785. 28,
  786. 42,
  787. 44,
  788. 45,
  789. 46,
  790. 47,
  791. 9,
  792. 0,
  793. 4,
  794. 3,
  795. 6,
  796. 13,
  797. 1,
  798. 15,
  799. 11,
  800. 37,
  801. 38,
  802. 40,
  803. 20,
  804. 43,
  805. 34,
  806. 30,
  807. 29,
  808. 31,
  809. 33,
  810. 22,
  811. 25,
  812. 35]).
  813. bind_deck(15,[4,
  814. 1,
  815. 43,
  816. 53,
  817. 18,
  818. 39,
  819. 9,
  820. 38,
  821. 13,
  822. 32,
  823. 48,
  824. 50,
  825. 19,
  826. 52,
  827. 33,
  828. 46,
  829. 40,
  830. 51,
  831. 49,
  832. 47,
  833. 11,
  834. 21,
  835. 25,
  836. 45,
  837. 44,
  838. 3,
  839. 16,
  840. 0,
  841. 17,
  842. 20,
  843. 27,
  844. 30,
  845. 42,
  846. 2,
  847. 41,
  848. 15,
  849. 6,
  850. 29,
  851. 37,
  852. 35,
  853. 5,
  854. 7,
  855. 28,
  856. 31,
  857. 24,
  858. 36,
  859. 10,
  860. 22,
  861. 26,
  862. 34,
  863. 23,
  864. 14,
  865. 8,
  866. 12]).
  867. bind_deck(16,[53,
  868. 52,
  869. 51,
  870. 50,
  871. 5,
  872. 12,
  873. 49,
  874. 29,
  875. 13,
  876. 43,
  877. 23,
  878. 48,
  879. 6,
  880. 14,
  881. 4,
  882. 10,
  883. 32,
  884. 42,
  885. 0,
  886. 9,
  887. 22,
  888. 31,
  889. 34,
  890. 39,
  891. 27,
  892. 7,
  893. 33,
  894. 16,
  895. 36,
  896. 26,
  897. 41,
  898. 45,
  899. 3,
  900. 2,
  901. 30,
  902. 44,
  903. 1,
  904. 11,
  905. 18,
  906. 21,
  907. 46,
  908. 25,
  909. 20,
  910. 24,
  911. 35,
  912. 28,
  913. 17,
  914. 19,
  915. 38,
  916. 8,
  917. 47,
  918. 40,
  919. 37,
  920. 15]).
  921. bind_deck(17,[53,
  922. 49,
  923. 37,
  924. 52,
  925. 51,
  926. 19,
  927. 2,
  928. 20,
  929. 32,
  930. 39,
  931. 50,
  932. 4,
  933. 9,
  934. 18,
  935. 17,
  936. 48,
  937. 47,
  938. 46,
  939. 45,
  940. 44,
  941. 30,
  942. 11,
  943. 5,
  944. 38,
  945. 43,
  946. 21,
  947. 13,
  948. 15,
  949. 3,
  950. 35,
  951. 36,
  952. 25,
  953. 41,
  954. 6,
  955. 42,
  956. 40,
  957. 34,
  958. 1,
  959. 8,
  960. 7,
  961. 0,
  962. 10,
  963. 12,
  964. 14,
  965. 16,
  966. 23,
  967. 24,
  968. 22,
  969. 27,
  970. 26,
  971. 28,
  972. 29,
  973. 31,
  974. 33]).
  975. bind_deck(18,[15,
  976. 53,
  977. 52,
  978. 40,
  979. 17,
  980. 9,
  981. 0,
  982. 16,
  983. 43,
  984. 50,
  985. 51,
  986. 49,
  987. 11,
  988. 48,
  989. 47,
  990. 46,
  991. 27,
  992. 30,
  993. 28,
  994. 29,
  995. 38,
  996. 3,
  997. 24,
  998. 34,
  999. 32,
  1000. 45,
  1001. 44,
  1002. 42,
  1003. 20,
  1004. 37,
  1005. 5,
  1006. 23,
  1007. 2,
  1008. 7,
  1009. 14,
  1010. 10,
  1011. 8,
  1012. 1,
  1013. 4,
  1014. 12,
  1015. 18,
  1016. 19,
  1017. 13,
  1018. 21,
  1019. 6,
  1020. 22,
  1021. 26,
  1022. 31,
  1023. 25,
  1024. 33,
  1025. 35,
  1026. 36,
  1027. 39,
  1028. 41]).
  1029. bind_deck(19,[28,
  1030. 35,
  1031. 40,
  1032. 0,
  1033. 29,
  1034. 30,
  1035. 52,
  1036. 53,
  1037. 51,
  1038. 50,
  1039. 45,
  1040. 1,
  1041. 8,
  1042. 15,
  1043. 17,
  1044. 24,
  1045. 10,
  1046. 14,
  1047. 33,
  1048. 4,
  1049. 36,
  1050. 23,
  1051. 38,
  1052. 11,
  1053. 22,
  1054. 12,
  1055. 27,
  1056. 43,
  1057. 18,
  1058. 32,
  1059. 37,
  1060. 13,
  1061. 26,
  1062. 34,
  1063. 9,
  1064. 2,
  1065. 5,
  1066. 21,
  1067. 25,
  1068. 7,
  1069. 31,
  1070. 41,
  1071. 42,
  1072. 46,
  1073. 6,
  1074. 16,
  1075. 3,
  1076. 19,
  1077. 20,
  1078. 39,
  1079. 44,
  1080. 47,
  1081. 48,
  1082. 49]).
  1083. bind_deck(20,[53,
  1084. 0,
  1085. 16,
  1086. 28,
  1087. 8,
  1088. 10,
  1089. 3,
  1090. 12,
  1091. 15,
  1092. 20,
  1093. 30,
  1094. 14,
  1095. 31,
  1096. 36,
  1097. 26,
  1098. 11,
  1099. 23,
  1100. 7,
  1101. 13,
  1102. 33,
  1103. 39,
  1104. 40,
  1105. 41,
  1106. 45,
  1107. 9,
  1108. 32,
  1109. 38,
  1110. 47,
  1111. 6,
  1112. 19,
  1113. 4,
  1114. 24,
  1115. 27,
  1116. 2,
  1117. 17,
  1118. 29,
  1119. 46,
  1120. 5,
  1121. 48,
  1122. 49,
  1123. 50,
  1124. 37,
  1125. 51,
  1126. 52,
  1127. 42,
  1128. 44,
  1129. 43,
  1130. 22,
  1131. 35,
  1132. 34,
  1133. 25,
  1134. 1,
  1135. 21,
  1136. 18]).
  1137. bind_deck(21,[11,
  1138. 15,
  1139. 6,
  1140. 0,
  1141. 30,
  1142. 7,
  1143. 32,
  1144. 42,
  1145. 22,
  1146. 25,
  1147. 18,
  1148. 29,
  1149. 26,
  1150. 31,
  1151. 33,
  1152. 35,
  1153. 39,
  1154. 45,
  1155. 16,
  1156. 48,
  1157. 37,
  1158. 43,
  1159. 5,
  1160. 46,
  1161. 50,
  1162. 4,
  1163. 9,
  1164. 36,
  1165. 3,
  1166. 8,
  1167. 19,
  1168. 27,
  1169. 10,
  1170. 14,
  1171. 40,
  1172. 47,
  1173. 24,
  1174. 49,
  1175. 51,
  1176. 1,
  1177. 52,
  1178. 2,
  1179. 20,
  1180. 28,
  1181. 23,
  1182. 41,
  1183. 44,
  1184. 12,
  1185. 21,
  1186. 38,
  1187. 53,
  1188. 13,
  1189. 34,
  1190. 17]).
  1191. bind_deck(22,[1,
  1192. 53,
  1193. 18,
  1194. 30,
  1195. 52,
  1196. 51,
  1197. 50,
  1198. 16,
  1199. 0,
  1200. 6,
  1201. 15,
  1202. 31,
  1203. 7,
  1204. 4,
  1205. 10,
  1206. 11,
  1207. 38,
  1208. 41,
  1209. 39,
  1210. 49,
  1211. 3,
  1212. 48,
  1213. 13,
  1214. 34,
  1215. 47,
  1216. 42,
  1217. 36,
  1218. 14,
  1219. 37,
  1220. 46,
  1221. 40,
  1222. 25,
  1223. 23,
  1224. 8,
  1225. 45,
  1226. 44,
  1227. 43,
  1228. 22,
  1229. 20,
  1230. 19,
  1231. 26,
  1232. 28,
  1233. 29,
  1234. 35,
  1235. 33,
  1236. 27,
  1237. 32,
  1238. 24,
  1239. 2,
  1240. 9,
  1241. 12,
  1242. 5,
  1243. 17,
  1244. 21]).
  1245. bind_deck(23,[23,
  1246. 27,
  1247. 39,
  1248. 53,
  1249. 52,
  1250. 8,
  1251. 51,
  1252. 1,
  1253. 5,
  1254. 26,
  1255. 28,
  1256. 34,
  1257. 35,
  1258. 0,
  1259. 10,
  1260. 14,
  1261. 16,
  1262. 30,
  1263. 19,
  1264. 32,
  1265. 37,
  1266. 40,
  1267. 25,
  1268. 29,
  1269. 2,
  1270. 42,
  1271. 13,
  1272. 20,
  1273. 17,
  1274. 22,
  1275. 3,
  1276. 6,
  1277. 11,
  1278. 36,
  1279. 21,
  1280. 15,
  1281. 7,
  1282. 4,
  1283. 24,
  1284. 38,
  1285. 43,
  1286. 46,
  1287. 41,
  1288. 49,
  1289. 9,
  1290. 12,
  1291. 18,
  1292. 31,
  1293. 44,
  1294. 47,
  1295. 45,
  1296. 33,
  1297. 48,
  1298. 50]).
  1299. bind_deck(24,[44,
  1300. 49,
  1301. 53,
  1302. 11,
  1303. 25,
  1304. 28,
  1305. 52,
  1306. 39,
  1307. 50,
  1308. 51,
  1309. 48,
  1310. 6,
  1311. 27,
  1312. 47,
  1313. 20,
  1314. 23,
  1315. 34,
  1316. 46,
  1317. 29,
  1318. 2,
  1319. 3,
  1320. 12,
  1321. 0,
  1322. 5,
  1323. 7,
  1324. 13,
  1325. 17,
  1326. 9,
  1327. 22,
  1328. 1,
  1329. 30,
  1330. 8,
  1331. 31,
  1332. 35,
  1333. 4,
  1334. 21,
  1335. 36,
  1336. 18,
  1337. 37,
  1338. 24,
  1339. 15,
  1340. 38,
  1341. 40,
  1342. 10,
  1343. 41,
  1344. 19,
  1345. 14,
  1346. 26,
  1347. 42,
  1348. 32,
  1349. 43,
  1350. 45,
  1351. 33,
  1352. 16]).
  1353. bind_deck(25,[3,
  1354. 7,
  1355. 9,
  1356. 23,
  1357. 16,
  1358. 33,
  1359. 42,
  1360. 32,
  1361. 35,
  1362. 28,
  1363. 27,
  1364. 31,
  1365. 34,
  1366. 36,
  1367. 46,
  1368. 4,
  1369. 1,
  1370. 49,
  1371. 50,
  1372. 14,
  1373. 19,
  1374. 29,
  1375. 8,
  1376. 39,
  1377. 43,
  1378. 52,
  1379. 2,
  1380. 44,
  1381. 53,
  1382. 51,
  1383. 5,
  1384. 30,
  1385. 22,
  1386. 47,
  1387. 48,
  1388. 0,
  1389. 45,
  1390. 41,
  1391. 40,
  1392. 38,
  1393. 10,
  1394. 17,
  1395. 18,
  1396. 20,
  1397. 21,
  1398. 25,
  1399. 24,
  1400. 13,
  1401. 26,
  1402. 12,
  1403. 37,
  1404. 11,
  1405. 6,
  1406. 15]).
  1407. bind_deck(26,[2,
  1408. 26,
  1409. 22,
  1410. 3,
  1411. 43,
  1412. 53,
  1413. 8,
  1414. 0,
  1415. 34,
  1416. 38,
  1417. 52,
  1418. 49,
  1419. 11,
  1420. 24,
  1421. 45,
  1422. 10,
  1423. 51,
  1424. 13,
  1425. 30,
  1426. 20,
  1427. 44,
  1428. 7,
  1429. 48,
  1430. 50,
  1431. 47,
  1432. 21,
  1433. 46,
  1434. 9,
  1435. 42,
  1436. 23,
  1437. 41,
  1438. 40,
  1439. 25,
  1440. 28,
  1441. 27,
  1442. 35,
  1443. 14,
  1444. 5,
  1445. 15,
  1446. 17,
  1447. 4,
  1448. 18,
  1449. 19,
  1450. 16,
  1451. 29,
  1452. 12,
  1453. 32,
  1454. 37,
  1455. 1,
  1456. 6,
  1457. 31,
  1458. 33,
  1459. 36,
  1460. 39]).
  1461. bind_deck(27,[53,
  1462. 17,
  1463. 51,
  1464. 50,
  1465. 52,
  1466. 49,
  1467. 33,
  1468. 34,
  1469. 31,
  1470. 12,
  1471. 1,
  1472. 20,
  1473. 28,
  1474. 5,
  1475. 32,
  1476. 35,
  1477. 10,
  1478. 11,
  1479. 2,
  1480. 27,
  1481. 29,
  1482. 9,
  1483. 36,
  1484. 0,
  1485. 25,
  1486. 30,
  1487. 40,
  1488. 18,
  1489. 41,
  1490. 42,
  1491. 43,
  1492. 26,
  1493. 19,
  1494. 48,
  1495. 23,
  1496. 15,
  1497. 13,
  1498. 16,
  1499. 22,
  1500. 39,
  1501. 3,
  1502. 45,
  1503. 46,
  1504. 8,
  1505. 24,
  1506. 4,
  1507. 38,
  1508. 44,
  1509. 47,
  1510. 37,
  1511. 21,
  1512. 14,
  1513. 6,
  1514. 7]).
  1515. bind_deck(28,[15,
  1516. 19,
  1517. 20,
  1518. 30,
  1519. 27,
  1520. 7,
  1521. 31,
  1522. 6,
  1523. 13,
  1524. 34,
  1525. 42,
  1526. 16,
  1527. 5,
  1528. 28,
  1529. 43,
  1530. 40,
  1531. 44,
  1532. 45,
  1533. 46,
  1534. 49,
  1535. 11,
  1536. 33,
  1537. 47,
  1538. 51,
  1539. 26,
  1540. 3,
  1541. 10,
  1542. 32,
  1543. 38,
  1544. 41,
  1545. 52,
  1546. 53,
  1547. 50,
  1548. 48,
  1549. 9,
  1550. 12,
  1551. 17,
  1552. 0,
  1553. 8,
  1554. 21,
  1555. 23,
  1556. 1,
  1557. 29,
  1558. 35,
  1559. 2,
  1560. 36,
  1561. 14,
  1562. 4,
  1563. 39,
  1564. 22,
  1565. 25,
  1566. 24,
  1567. 18,
  1568. 37]).
  1569. bind_deck(29,[16,
  1570. 22,
  1571. 23,
  1572. 30,
  1573. 33,
  1574. 53,
  1575. 24,
  1576. 12,
  1577. 28,
  1578. 19,
  1579. 18,
  1580. 35,
  1581. 44,
  1582. 7,
  1583. 52,
  1584. 51,
  1585. 50,
  1586. 38,
  1587. 39,
  1588. 29,
  1589. 40,
  1590. 3,
  1591. 36,
  1592. 21,
  1593. 15,
  1594. 45,
  1595. 2,
  1596. 4,
  1597. 25,
  1598. 37,
  1599. 42,
  1600. 17,
  1601. 49,
  1602. 5,
  1603. 11,
  1604. 1,
  1605. 8,
  1606. 48,
  1607. 47,
  1608. 0,
  1609. 6,
  1610. 10,
  1611. 20,
  1612. 27,
  1613. 31,
  1614. 41,
  1615. 9,
  1616. 43,
  1617. 14,
  1618. 34,
  1619. 13,
  1620. 26,
  1621. 32,
  1622. 46]).
  1623. %/* not definition required RS6000 prolog */
  1624. %/*not(P) :- call(P), !, fail.
  1625. %not(P). */
  1626. %/* member and append predicates from the Art of Prolog. */ 
  1627. member_djd(X,[X|Xs]).
  1628. member_djd(X,[Y|Ys]) :- member_djd(X,Ys).
  1629. append_djd([],Ys,Ys).
  1630. append_djd([X|Xs],Ys,[X|Zs]) :- append_djd(Xs,Ys,Zs).
  1631. length_djd([],0).
  1632. length_djd([X],1).
  1633. length_djd([X|Xs],N1)  :- length_djd(Xs,N), (N = N1 - 1).
  1634. %/* predicate eq defined for use with not above */
  1635. %eq(A,B) :- A :== B.
  1636. %/**********************************************************************/
  1637. %/* deck representation follows                                        */
  1638. %/* for each suite these is a predicate which is true of cards of that */
  1639. %/* suite represented as a list of data for that card. The data is : */
  1640. %/* [card number(as represented in deck and other lists of cards ,   */
  1641. %/* sequence value in this suite,                                    */
  1642. %/* suite,                            */                                */
  1643. %/* name of card,                           */                            */
  1644. %/* points for taking this card,                                     */
  1645. %/* points for playing this card]                                     */
  1646. %/*******************************************************************/
  1647.  
  1648. heart([0,2,hearts,c_2_of_hearts,0,1]).
  1649. heart([1,3,hearts,c_3_of_hearts,0,0]).
  1650. heart([2,4,hearts,c_4_of_hearts,0,0]).
  1651. heart([3,5,hearts,c_5_of_hearts,0,0]).
  1652. heart([4,6,hearts,c_6_of_hearts,0,0]).
  1653. heart([5,7,hearts,c_7_of_hearts,0,0]).
  1654. heart([6,8,hearts,c_8_of_hearts,0,0]).
  1655. heart([7,9,hearts,c_9_of_hearts,0,0]).
  1656. heart([8,10,hearts,c_10_of_hearts,1,0]).
  1657. heart([52,11,hearts,low_joker,1,0]).
  1658. heart([53,12,hearts,high_joker,1,0]).
  1659. heart([22,13,hearts,j_of_diamonds,1,0]).
  1660. heart([9,14,hearts,j_of_hearts,1,0]).
  1661. heart([10,15,hearts,q_of_hearts,0.0]).
  1662. heart([11,16,hearts,k_of_hearts,0,0]).
  1663. heart([12,17,hearts,a_of_hearts,0,1]).
  1664. diamond([13,2,diamonds,c_2_of_diamonds,0,1]).
  1665. diamond([14,3,diamonds,c_3_of_diamonds,0,0]).
  1666. diamond([15,4,diamonds,c_4_of_diamonds,0,0]).
  1667. diamond([16,5,diamonds,c_5_of_diamonds,0,0]).
  1668. diamond([17,6,diamonds,c_6_of_diamonds,0,0]).
  1669. diamond([18,7,diamonds,c_7_of_diamonds,0,0]).
  1670. diamond([19,8,diamonds,c_8_of_diamonds,0,0]).
  1671. diamond([20,9,diamonds,c_9_of_diamonds,0,0]).
  1672. diamond([21,10,diamonds,c_10_of_diamonds,1,0]).
  1673. diamond([52,11,diamonds,low_joker,1,0]).
  1674. diamond([53,12,diamonds,high_joker,1,0]).
  1675. diamond([9,13,diamonds,j_of_hearts,1,0]).
  1676. diamond([22,14,diamonds,j_of_diamonds,1,0]).
  1677. diamond([23,15,diamonds,q_of_diamonds,0,0]).
  1678. diamond([24,16,diamonds,k_of_diamonds,0,0]).
  1679. diamond([25,17,diamonds,a_of_diamonds,0,1]).
  1680. spade([26,2,spades,c_2_of_spades,0,1]).
  1681. spade([27,3,spades,c_3_of_spades,0,0]).
  1682. spade([28,4,spades,c_4_of_spades,0,0]).
  1683. spade([29,5,spades,c_5_of_spades,0,0]).
  1684. spade([30,6,spades,c_6_of_spades,0,0]).
  1685. spade([31,7,spades,c_7_of_spades,0,0]).
  1686. spade([32,8,spades,c_8_of_spades,0,0]).
  1687. spade([33,9,spades,c_9_of_spades,0,0]).
  1688. spade([34,10,spades,c_10_of_spades,1,0]).
  1689. spade([52,11,spades,low_joker,1,0]).
  1690. spade([53,12,spades,high_joker,1,0]).
  1691. spade([48,13,spades,j_of_clubs,1,0]).
  1692. spade([35,14,spades,j_of_spades,1,0]).
  1693. spade([36,15,spades,q_of_spades,0,0]).
  1694. spade([37,16,spades,k_of_spades,0,0]).
  1695. spade([38,17,spades,a_of_spades,0,1]).
  1696. club([39,2,clubs,c_2_of_clubs,0,1]).
  1697. club([40,3,clubs,c_3_of_clubs,0,0]).
  1698. club([41,4,clubs,c_4_of_clubs,0,0]).
  1699. club([42,5,clubs,c_5_of_clubs,0,0]).
  1700. club([43,6,clubs,c_6_of_clubs,0,0]).
  1701. club([44,7,clubs,c_7_of_clubs,0,0]).
  1702. club([45,8,clubs,c_8_of_clubs,0,0]).
  1703. club([46,9,clubs,c_9_of_clubs,0,0]).
  1704. club([47,10,clubs,c_10_of_clubs,1,0]).
  1705. club([52,11,clubs,low_joker,1,0]).
  1706. club([53,12,clubs,high_joker,1,0]).
  1707. club([35,13,clubs,j_of_spades,1,0]).
  1708. club([48,14,clubs,j_of_clubs,1,0]).
  1709. club([49,15,clubs,q_of_clubs,0,0]).
  1710. club([50,16,clubs,k_of_clubs,0,0]).
  1711. club([51,17,clubs,a_of_clubs,0,1]).
  1712. valid_bid(Val) :- 2 =< Val , Val =< 7.
  1713. valid_bid(Val) :- Val = pass.
  1714. valid_suite(hearts).
  1715. valid_suite(diamonds).
  1716. valid_suite(spades).
  1717. valid_suite(clubs).
  1718.  
  1719. %/* the card predicate combines infomation of all suits */
  1720.  
  1721. card([No,Val,Suite,Name,Pt_taken,Pt_played]) :- 
  1722.         heart([No,Val,Suite,Name,Pt_taken,Pt_played]).
  1723. card([No,Val,Suite,Name,Pt_taken,Pt_played]) :- 
  1724.         diamond([No,Val,Suite,Name,Pt_taken,Pt_played]).
  1725. card([No,Val,Suite,Name,Pt_taken,Pt_played]) :- 
  1726.         spade([No,Val,Suite,Name,Pt_taken,Pt_played]).
  1727. card([No,Val,Suite,Name,Pt_taken,Pt_played]) :- 
  1728.         club([No,Val,Suite,Name,Pt_taken,Pt_played]).
  1729. valid_card(Name,Suite,H) :-        
  1730.        card([No,Val,Suite,Name,Pt_taken,Pt_played]),
  1731.        member_djd(No,H).
  1732. %/* some predicates follow which are used for initialization */
  1733.  
  1734. bind_teams([[dennis,dick],[sussy,john]]).
  1735. bind_players([dennis,sussy,dick,john]).
  1736. succ_player(dennis,sussy).
  1737. succ_player(sussy,dick).
  1738. succ_player(dick,john).
  1739. succ_player(john,dennis).
  1740. partner(dennis,dick).
  1741. partner(dick,dennis).
  1742. partner(sussy,john).
  1743. partner(john,sussy).
  1744. bind_dealer(dennis).
  1745. bind_played([[],[],[],[]]).
  1746. bind_taken([[],[],[],[]]).
  1747. bind_score([0,0]).
  1748. %/*******************************************************************/
  1749. %/* The main predicate for invoking a game of pitch follows        */
  1750. %/* to invoke a game the query - play_game(R,S). - may be used.     */
  1751. %/******************************************************************/
  1752.  
  1753. play_game(Teams,Scores) :- bind_teams(Teams),
  1754.         bind_players(Players),
  1755.         bind_score(Scores),bind_dealer(Dealer),
  1756. %        load("shuffle.lf"), 
  1757. %        open_out("pitch.log"),
  1758.         play_hand(Players,Teams,Scores,Dealer,Deck,0).
  1759. play_hand(Players,Teams,Scores,Dealer,Deck,Cnt) :- done(Teams,Scores).
  1760. play_hand(Players,Teams,Scores,Dealer,Deck,Cnt) :-
  1761.  
  1762.         bind_played(Played),
  1763. %        load("is_out.lf"),
  1764.         bind_taken(Taken),
  1765. %/*        shell('shuffle >shuffle.p'),  */
  1766.         bind_deck(Cnt,Deck),
  1767.         deal(Players,Deck,Newdeckx,Hands,Dealer),
  1768.         bid_lf(Players,Hands,Dealer,Bidder,Bid,Suite),
  1769.         write_bl(bid_is),
  1770.         write_bl(Bidder),
  1771.         write_bl(Bid),
  1772.         write_nl(Suite),
  1773.         discard(Players,Hands,Hands2,Suite),
  1774.         deal2(Players,Newdeckx,Hands2,Hands3,Dealer,Bidder),
  1775.         discard(Players,Hands3,Hands4,Suite),
  1776.         retract(is_out(dennis)),
  1777.         retract(is_out(sussy)),
  1778.         retract(is_out(john)),
  1779.         retract(is_out(dick)),
  1780. %        load("is_out.lf"), 
  1781.         play_cards(Players,Hands4,Played,Taken,Bidder,Suite,
  1782.                 Newplayed,Newtaken,Npret,Ntret),
  1783.         score(Players,Teams,Npret,Ntret,Scores,Newscores,Bidder,Bid,Suite), 
  1784.         succ_player(Dealer,Newdealer),
  1785.         (Cnt2 -> Cnt + 1), % was is changed to = for life
  1786.         play_hand(Players,Teams,Newscores,Newdealer,Newdeck,Cnt2).
  1787. %/* game is over when score reaches 21 */
  1788. done(Teams,[S1,S2]) :- S1 >= 21.
  1789. done(Teams,[S1,S2]) :- S2 >= 21. 
  1790. %/* deal cards 1st round.  Each player gets 9 cards */
  1791. deal(Players,Deck,Newdeckx,Hands,Dealer) :- write_nl(p_deal),
  1792.         Deck = [C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11,C12,C13,C14,C15,
  1793.         C16,C17,C18,C19,C20,C21,C22,C23,C24,C25,C26,C27,C28,C29,C30,
  1794.         C31,C32,C33,C34,C35,C36,C37,C38,C39,C40,C41,C42,C43,C44,C45,
  1795.         C46,C47,C48,C49,C50,C51,C52,C53,C54],
  1796.         !,
  1797.         
  1798.         Newdeckx = [C37,C38,C39,C40,C41,C42,C43,C44,
  1799.         C45,C46,C47,C48,C49,C50,C51,C52,C53,C54],
  1800.         
  1801.         Hands = [[C1,C2,C3,C13,C14,C15,C25,C26,C27],
  1802.         [C4,C5,C6,C16,C17,C18,C28,C29,C30],
  1803.         [C7,C8,C9,C19,C20,C21,C31,C32,C33],
  1804.         [C10,C11,C12,C22,C23,C24,C34,C35,C36]],
  1805.         write_nl(Hands).
  1806. %/* rules foer what a player can bid follow */
  1807. %/*
  1808. %can_bid(4,Hand,Suite1,Bidder) :- 
  1809. %        member_djd(No1,Hand),
  1810. %        member_djd(No2,Hand),
  1811. %        card([No1,2,Suite1,Name1,Pt_taken1,Pt_played1]),
  1812. %        card([No2,17,Suite2,Name2,Pt_taken2,Pt_played2]),
  1813. %        Suite1 = Suite2.
  1814. %can_bid(3,Hand,Suite,Bidder) :- 
  1815. %        member_djd(No1,Hand),
  1816. %        card([No1,17,Suite,Name1,Pt_taken1,Pt_played1]).
  1817. %can_bid(2,Hand,Suite1,Bidder) :- 
  1818. %        member_djd(No1,Hand),
  1819. %        member_djd(No2,Hand),
  1820. %        card([No1,2,Suite1,Name1,Pt_taken1,Pt_played1]),
  1821. %        card([No2,Val2,Suite2,Name2,Pt_taken2,Pt_played2]),
  1822. %        Val2 >= 10,
  1823. %        Suite1 = Suite2.
  1824. %can_bid(0,Hand,pass,Bidder).
  1825. %*/
  1826. %/* the bidding process is described below */
  1827. bid_lf(Players,Hands,Dealer,Bidder,Bid,Suite) :- write_nl(p_bid),
  1828.         succ_player(Dealer,Bidder1),
  1829.         get_hand(Players,Hands,Bidder1,Hand1),
  1830.         trybid(Bidder1,Hand1,0,pass,pass,Maxbidder1,Maxbid1,Maxsuite1),
  1831.         succ_player(Bidder1,Bidder2),
  1832.         get_hand(Players,Hands,Bidder2,Hand2),
  1833.         trybid(Bidder2,Hand2,Maxbid1,Maxbidder1,Maxsuite1,
  1834.                 Maxbidder2,Maxbid2,Maxsuite2),
  1835.         succ_player(Bidder2,Bidder3),
  1836.         get_hand(Players,Hands,Bidder3,Hand3),
  1837.         trybid(Bidder3,Hand3,Maxbid2,Maxbidder2,Maxsuite2,
  1838.                 Maxbidder3,Maxbid3,Maxsuite3),
  1839.         succ_player(Bidder3,Bidder4),
  1840.         get_hand(Players,Hands,Bidder4,Hand4),
  1841.         trybid(Bidder4,Hand4,Maxbid3,Maxbidder3,Maxsuite3,
  1842.                 Bidder5,Bid5,Suite5),
  1843.         no_bid(Dealer,Bidder5,Bid5,Suite5,Bidder,Bid,Suite).
  1844. no_bid(Dealer,Bidder5,Bid5,Suite5,Bidder,Bid,Suite) :-
  1845.      Bid5 = 0,
  1846.      Bidder = Dealer,
  1847.      Bid = 2,
  1848.      Suite = spades.
  1849. no_bid(Dealer,Bidder5,Bid5,Suite5,Bidder,Bid,Suite) :-
  1850.      \+ (Bid5 = 0),
  1851.      Bidder = Bidder5,
  1852.      Bid = Bid5,
  1853.      Suite = Suite5.
  1854.      
  1855. %/* get hand provodes a list of cards associated with a player */
  1856. get_hand(Players,Hands,P1,H1) :-
  1857.         Players = [P1,P2,P3,P4],
  1858.         Hands = [H1,H2,H3,H4].
  1859. get_hand(Players,Hands,P2,H2) :-
  1860.         Players = [P1,P2,P3,P4],
  1861.         Hands = [H1,H2,H3,H4].
  1862. get_hand(Players,Hands,P3,H3) :-
  1863.         Players = [P1,P2,P3,P4],
  1864.         Hands = [H1,H2,H3,H4].
  1865. get_hand(Players,Hands,P4,H4) :-
  1866.         Players = [P1,P2,P3,P4],
  1867.         Hands = [H1,H2,H3,H4].
  1868. %/* put_hand updates a list of cards associated with a player */
  1869. put_hand(Players,Hands,P1,Hand,Newhands) :-
  1870.         Players = [P1,P2,P3,P4],
  1871.         Hands = [H1,H2,H3,H4],
  1872.         Newhands = [Hand,H2,H3,H4].
  1873. put_hand(Players,Hands,P2,Hand,Newhands) :-
  1874.         Players = [P1,P2,P3,P4],
  1875.         Hands = [H1,H2,H3,H4],
  1876.         Newhands = [H1,Hand,H3,H4].
  1877. put_hand(Players,Hands,P3,Hand,Newhands) :-
  1878.         Players = [P1,P2,P3,P4],
  1879.         Hands = [H1,H2,H3,H4],
  1880.         Newhands = [H1,H2,Hand,H4].
  1881. put_hand(Players,Hands,P4,Hand,Newhands) :-
  1882.         Players = [P1,P2,P3,P4],
  1883.         Hands = [H1,H2,H3,H4],
  1884.         Newhands = [H1,H2,H3,Hand].
  1885. %/* current player can bid higher than high bid so far */
  1886. trybid(Bidder2,Hand2,Maxbid1,Maxbidder1,Maxsuite1,
  1887.         Maxbidder2,Maxbid2,Maxsuite2) :-
  1888.         dennis :\==Bidder2,
  1889.         max_bid(Bidval,Hand2,Suite,Bidder2),
  1890.         Bidval > Maxbid1, 
  1891.         write_bl(Bidder2),
  1892.         write_bl(bids),
  1893.         write_nl(Bidval),
  1894.         Maxbidder2 = Bidder2,
  1895.         Maxbid2 = Bidval,
  1896.         Maxsuite2 = Suite.
  1897. %/* current player can not bid higher than high bid so far */
  1898. trybid(Bidder2,Hand2,Maxbid1,Maxbidder1,Maxsuite1,
  1899.         Maxbidder2,Maxbid2,Maxsuite2) :-
  1900.         dennis :\== Bidder2,
  1901.         max_bid(Bidval,Hand2,Suite,Bidder2),
  1902.         Bidval =< Maxbid1,
  1903.         Maxbidder2 = Maxbidder1,
  1904.         Maxbid2 = Maxbid1,
  1905.         Maxsuite2 = Maxsuite1.
  1906. %/* rule repeated 3 times for 3 chances for valid answer */
  1907. trybid(dennis,Hand2,Maxbid1,Maxbidder1,Maxsuite1,
  1908.         Maxbidder2,Maxbid2,Maxsuite2) :-
  1909.         display_hand(Hand2),
  1910.         write_bl(enter),
  1911.         write_bl(bid),
  1912.         write_nl(value),
  1913.         read(Bidval),
  1914.         valid_bid(Bidval),
  1915.         write_bl(enter),
  1916.         write_bl(bid),
  1917.         write_nl(suite),
  1918.         read(Suite),
  1919.         valid_suite(Suite),!,
  1920.         trybid_b(dennis,Hand2,Maxbid1,Maxbidder1,Maxsuite1,
  1921.         Maxbidder2,Maxbid2,Maxsuite2,Bidval,Suite).
  1922. trybid(dennis,Hand2,Maxbid1,Maxbidder1,Maxsuite1,
  1923.         Maxbidder2,Maxbid2,Maxsuite2) :-
  1924.         display_hand(Hand2),
  1925.         write_bl(enter),
  1926.         write_bl(bid),
  1927.         write_nl(value),
  1928.         read(Bidval),
  1929.         valid_bid(Bidval),
  1930.         write_bl(enter),
  1931.         write_bl(bid),
  1932.         write_nl(suite),
  1933.         read(Suite),
  1934.         valid_suite(Suite),!,
  1935.         trybid_b(dennis,Hand2,Maxbid1,Maxbidder1,Maxsuite1,
  1936.         Maxbidder2,Maxbid2,Maxsuite2,Bidval,Suite).
  1937. trybid(dennis,Hand2,Maxbid1,Maxbidder1,Maxsuite1,
  1938.         Maxbidder2,Maxbid2,Maxsuite2) :-
  1939.         display_hand(Hand2),
  1940.         write_bl(enter),
  1941.         write_bl(bid),
  1942.         write_nl(value),
  1943.         read(Bidval),
  1944.         valid_bid(Bidval),
  1945.         write_bl(enter),
  1946.         write_bl(bid),
  1947.         write_nl(suite),
  1948.         read(Suite),
  1949.         valid_suite(Suite),!,
  1950.         trybid_b(dennis,Hand2,Maxbid1,Maxbidder1,Maxsuite1,
  1951.         Maxbidder2,Maxbid2,Maxsuite2,Bidval,Suite).
  1952. trybid_b(dennis,Hand2,Maxbid1,Maxbidder1,Maxsuite1,
  1953.         Maxbidder2,Maxbid2,Maxsuite2,Bidval,Suite) :-
  1954.         Bidval > Maxbid1, 
  1955.         write_bl(Bidder2),
  1956.         write_bl(bids),
  1957.         write_nl(Bidval),
  1958.         Maxbidder2 = dennis,
  1959.         Maxbid2 = Bidval,
  1960.         Maxsuite2 = Suite.
  1961. trybid_b(dennis,Hand2,Maxbid1,Maxbidder1,Maxsuite1,
  1962.         Maxbidder2,Maxbid2,Maxsuite2,Bidval,Suite) :-
  1963.         Bidval = pass,
  1964.         Maxbidder2 = Maxbidder1,
  1965.         Maxbid2 = Maxbid1,
  1966.         Maxsuite2 = Maxsuite1.
  1967.  
  1968. %/* max bid appear in order lowest to highest */
  1969.  
  1970.  
  1971. max_bid(7,Hand,Suite,Bidder) :- can_bid(7,Hand,Suite,Bidder),!.
  1972. max_bid(6,Hand,Suite,Bidder) :- can_bid(6,Hand,Suite,Bidder),!.
  1973. max_bid(5,Hand,Suite,Bidder) :- can_bid(5,Hand,Suite,Bidder),!.
  1974. max_bid(4,Hand,Suite,Bidder) :- can_bid(4,Hand,Suite,Bidder),!.
  1975. max_bid(3,Hand,Suite,Bidder) :- can_bid(3,Hand,Suite,Bidder),!.
  1976. max_bid(2,Hand,Suite,Bidder) :- can_bid(2,Hand,Suite,Bidder),!.
  1977. max_bid(0,Hand,Suite,Bidder) :- can_bid(0,Hand,Suite,Bidder),!.
  1978.  
  1979. %/* delete item (card) from list of items (cards) */
  1980. delete(Item,List,Newlist) :-
  1981.         discard_item(Item,List,Nl,[],Newlist).
  1982.                  
  1983.                  
  1984. discard_item(Item,List,Nl,Partl,Newlist) :-
  1985.         List = [Item | Nl],
  1986.         Partl2 = Partl,
  1987.         discard_item(Item,Nl,Nl2,Partl2,Newlist).
  1988. discard_item(Item,List,Nl,Partl,Newlist) :-
  1989.         List = [Item],
  1990.         Partl2 = Partl,
  1991.         discard_item(Item,[],Nl2,Partl2,Newlist).
  1992.  
  1993. discard_item(Item,List,Nl,Partl,Newlist) :-
  1994.         List = [I | Nl],
  1995.         I :\== Item, 
  1996.         Partl2 = [I | Partl],
  1997.         discard_item(Item,Nl,Nl2,Partl2,Newlist).
  1998. discard_item(Item,List,Nl,Partl,Newlist) :-
  1999.         List = [I],
  2000.         I :\== Item,
  2001.         Partl2 = [I,Part],
  2002.         discard_item(Item,[],Nl2,Partl2,Newlist).
  2003.  
  2004. discard_item(Item,List,Nl,Partl,Newlist) :-
  2005.         List = [],!,
  2006.         Newlist = Partl.
  2007. %/* once suite is determined by high bidder players must discard cards
  2008. %not of that suite (except left jack & jokers) & also not retain more 
  2009. %than 6 cards*/
  2010. discard(Players,Hands,Hands2,Suite) :- write_nl(p_discard),
  2011.         Hands = [H1,H2,H3,H4],
  2012.         discard_non_suite(H1,Nh1,[],Hand1,Suite),
  2013.         discard_non_suite(H2,Nh2,[],Hand2,Suite),
  2014.         discard_non_suite(H3,Nh3,[],Hand3,Suite),
  2015.         discard_non_suite(H4,Nh4,[],Hand4,Suite),
  2016.         discard_excess(Hand1,Newhand1,Suite),
  2017.         discard_excess(Hand2,Newhand2,Suite),
  2018.         discard_excess(Hand3,Newhand3,Suite),
  2019.         discard_excess(Hand4,Newhand4,Suite),
  2020.         Hands2 = [Newhand1,Newhand2,Newhand3,Newhand4],
  2021.         write_nl(Hands2).
  2022. discard_non_suite(H,Nh,Parthand,Hand,Suite) :-
  2023.         H = [No | Nh],
  2024.         card([No,Val,Suite2,Name,Pt_taken,Pt_played]),
  2025.         Suite = Suite2,
  2026.         append_djd(Parthand , [No] ,Parthand2),
  2027.         discard_non_suite(Nh,Nh2,Parthand2,Hand,Suite).
  2028. discard_non_suite(H,Nh,Parthand,Hand,Suite) :-
  2029.         H = [No | Nh],
  2030.         \+(card([No,Val,Suite,Name,Pt_taken,Pt_played])),
  2031.      %/*   write_nl(discarded),
  2032. %        write_nl(Name), */
  2033.         discard_non_suite(Nh,Nh2,Parthand,Hand,Suite).
  2034. discard_non_suite(H,Nh,Parthand,Hand,Suite) :-
  2035.         Hand = Parthand, !.
  2036. discard_excess(Hand,Newhand,Suite) :-
  2037.         length_djd(Hand,Len),
  2038.         Len =< 6, 
  2039.         Newhand = Hand.
  2040. discard_excess(Hand,Newhand,Suite) :-
  2041.         length_djd(Hand,Len),
  2042.         Len > 6,
  2043.         card([No,Val,Suite,Name,Pt_taken,Pt_played]),
  2044.         member_djd(No,Hand),
  2045.         2 < Val,
  2046.         10 > Val,
  2047.     %/*    write_nl(excess),
  2048. %        write_nl(Name), */
  2049.         delete(No,Hand,Newhand2),
  2050.         discard_excess(Newhand2,Newhand,Suite).
  2051. discard_excess(Hand,Newhand,Suite) :-
  2052.         length_djd(Hand,Len),
  2053.         Len > 6,
  2054.         card([No,Val,Suite,Name,Pt_taken,Pt_played]),
  2055.         member_djd(No,Hand),
  2056.         15 = Val,
  2057.      %/*   write_nl(excess2),
  2058.  %       write_nl(Name), */
  2059.         delete(No,Hand,Newhand2),
  2060.         discard_excess(Newhand2,Newhand,Suite).
  2061. discard_excess(Hand,Newhand,Suite) :-
  2062.         length_djd(Hand,Len),
  2063.         Len > 6,
  2064.         card([No,Val,Suite,Name,Pt_taken,Pt_played]),
  2065.         member_djd(No,Hand),
  2066.         16 = Val,
  2067.         delete(No,Hand,Newhand2),
  2068.         discard_excess(Newhand2,Newhand,Suite).
  2069. discard_excess(Hand,Newhand,Suite) :-
  2070.         length_djd(Hand,Len),
  2071.         Len > 6,
  2072.         card([No,Val,Suite,Name,Pt_taken,Pt_played]),
  2073.         member_djd(No,Hand),
  2074.         2 = Val,
  2075.         delete(No,Hand,Newhand2),
  2076.         discard_excess(Newhand2,Newhand,Suite).
  2077.         
  2078. %/* after discarding players (other than the bidder) receive enough
  2079. %cards th raise their total cards to 6.  The bidder gets to look through
  2080. %whatever is then left */
  2081.  
  2082. deal2(Players,Newdeck,Hands2,Hands3,Dealer,Bidder) :- 
  2083.         write_nl(p_deal2),
  2084.         succ_player(Dealer,P1),
  2085.         extras(Players,Newdeck,Newdeck2,Hands2,Hands2a,P1,Bidder),
  2086.         succ_player(P1,P2),
  2087.         extras(Players,Newdeck2,Newdeck3,Hands2a,Hands2b,P2,Bidder),
  2088.         succ_player(P2,P3),
  2089.         extras(Players,Newdeck3,Newdeck4,Hands2b,Hands2c,P3,Bidder),
  2090.         succ_player(P3,P4),
  2091.         extras(Players,Newdeck4,Newdeck5,Hands2c,Hands2d,P4,Bidder),
  2092.         remaining(Players,Newdeck5,Hands2d,Hands3,Bidder),
  2093.         write_nl(final_hands),
  2094.         write_nl(Hands3).
  2095.         
  2096. extras(Players,Newdeck,Newdeck2,Hands2,Hands2a,P1,Bidder) :-
  2097.         P1 = Bidder, ! ,
  2098.         Newdeck2 = Newdeck,
  2099.         Hands2a = Hands2.
  2100. extras(Players,Newdeck,Newdeck2,Hands2,Hands2a,P1,Bidder) :-
  2101.         Newdeck = [], ! ,
  2102.         Newdeck2 = Newdeck,
  2103.         Hands2a = Hands2.
  2104. extras(Players,Newdeck,Newdeck2,Hands2,Hands2a,P1,Bidder) :-
  2105.         get_hand(Players,Hands2,P1,H1),
  2106.         length_djd(H1,Len),
  2107.         Len = 6, ! ,
  2108.         Newdeck2 = Newdeck,
  2109.         Hands2a = Hands2.
  2110. extras(Players,Newdeck,Newdeck2,Hands2,Hands2a,P1,Bidder) :-
  2111.         get_hand(Players,Hands2,P1,H1),
  2112.         length_djd(H1,Len),
  2113.         Len < 6,
  2114.         Newdeck = [No | Newdeck3],
  2115.         H1a = [No | H1],
  2116.         put_hand(Players,Hands2,P1,H1a,Hands3),
  2117.         extras(Players,Newdeck3,Newdeck2,Hands3,Hands2a,P1,Bidder).
  2118.         
  2119.         
  2120. remaining(Players,Newdeck5,Hands2d,Hands3,Bidder) :-
  2121.         get_hand(Players,Hands2d,Bidder,H1),
  2122.         append_djd(H1,Newdeck5,H1a),
  2123.         put_hand(Players,Hands2d,Bidder,H1a,Hands3).
  2124.         
  2125. %/* each player plays a card the highest card wins */
  2126. play_cards(Players,Hands,Played,Taken,Leader,Suite,Newplayed,Newtaken,
  2127.         Npret,Ntret) :- 
  2128.         Hands = [H1,H2,H3,H4],
  2129.         sort_by_val(H1,H1s,Suite),
  2130.         sort_by_val(H2,H2s,Suite),
  2131.         sort_by_val(H3,H3s,Suite),
  2132.         sort_by_val(H4,H4s,Suite),
  2133.         Hands2 = [H1s,H2s,H3s,H4s], %/* sorted hands */
  2134.         write_bl(dennis),
  2135.         write_nl(hand),
  2136.         display_hand(H1s),
  2137.     %/*    write_nl('sussy hand2'),
  2138. %        display_hand(H2s),
  2139. %        write_nl('dick hand3'),
  2140. %        display_hand(H3s),
  2141. %        write_nl('john hand4'),
  2142. %        display_hand(H4s), */
  2143.         play_card([Players,Hands2,Played,Taken,Leader,
  2144.         Newhands,Newplayed,Newtaken,Newleader,Suite]),
  2145.         play_cards(Players,Newhands,Newplayed,Newtaken,Newleader,Suite,
  2146.                 Np,Nt,Npret,Ntret).  
  2147. %/* a hand ends when all players are out of cards */
  2148. play_cards(Players,Hands,Played,Taken,Leader,Suite,Newplayed,Newtaken,
  2149.         Npret,Ntret) :- 
  2150.         out(Players,Hands), !,
  2151.         Npret =Played,
  2152.         Ntret = Taken.
  2153.         
  2154. out(Players,Hands) :- 
  2155.         Hands = [[],[],[],[]], !,
  2156.                 write_nl(p_out).
  2157. play_card([Players,Hands,Played,Taken,Leader,Newhands,Newplayed,
  2158.         Newtaken,Newleader,Suite]) :-
  2159.         play_1card([Players,Hands,Played,Leader,Newhands1,Newplayed1,
  2160.         0,none,Newhigh1,Newwhohigh1,[],Newcards1,Suite]),
  2161.         succ_player(Leader,P2),
  2162.         play_1card([Players,Newhands1,Newplayed1,P2,Newhands2,Newplayed2,
  2163.         Newhigh1,Newwhohigh1,Newhigh2,Newwhohigh2,
  2164.         Newcards1,Newcards2,Suite]),
  2165.         succ_player(P2,P3),
  2166.         play_1card([Players,Newhands2,Newplayed2,P3,Newhands3,Newplayed3,
  2167.         Newhigh2,Newwhohigh2,Newhigh3,Newwhohigh3,
  2168.         Newcards2,Newcards3,Suite]),
  2169.         succ_player(P3,P4),
  2170.         play_1card([Players,Newhands3,Newplayed3,P4,Newhands,Newplayed,
  2171.         Newhigh3,Newwhohigh3,Newhigh4,Newwhohigh4,
  2172.         Newcards3,Newcards4,Suite]),
  2173.         summary_cards_taken([Players,Taken,Newtaken,Newhigh4,Newwhohigh4,
  2174.         Newcards4,Newleader]).
  2175. play_1card([Players,Newhands1,Newplayed1,P2,Newhands2,Newplayed2,
  2176.         Newhigh1,Newwhohigh1,Newhigh2,Newwhohigh2,
  2177.         Newcards1,Newcards2,Suite]) :-
  2178.         P2 :\== dennis,
  2179.         get_hand(Players,Newhands1,P2,H2),
  2180.         best_card(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,Card1,
  2181.         Suite,Newhigh1,Newwhohigh1),
  2182.         card([Card1,Val,Suite,Name,Pt_taken,Pt_played]),
  2183.         Val > Newhigh1, ! ,
  2184.         write_bl(P2),
  2185.         write_bl(plays),
  2186.         write_nl(Name),
  2187.         delete(Card1,H2,Nh2),
  2188.         Newhigh2 = Val,
  2189.         Newwhohigh2 = P2,
  2190.         put_hand(Players,Newhands1,P2,Nh2,Newhands2),
  2191.         get_hand(Players,Newplayed1,P2,Pl1),
  2192.         Pl2 = [Card1 | Pl1],
  2193.         Newcards2 = [Card1 | Newcards1],
  2194.   %/*      write_bl(newcards2),write_nl(Newcards2), */
  2195.         put_hand(Players,Newplayed1,P2,Pl2,Newplayed2). %/* was , */
  2196.     %/*    write_bl(newplayed2),write_nl(Newplayed2). */
  2197. play_1card([Players,Newhands1,Newplayed1,P2,Newhands2,Newplayed2,
  2198.         Newhigh1,Newwhohigh1,Newhigh2,Newwhohigh2,
  2199.         Newcards1,Newcards2,Suite]) :-
  2200.         P2 :\== dennis,
  2201.         get_hand(Players,Newhands1,P2,H2),
  2202.         best_card(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,Card1,
  2203.         Suite,Newhigh1,Newwhohigh1),
  2204.         card([Card1,Val,Suite,Name,Pt_taken,Pt_played]),
  2205.         Val < Newhigh1, ! ,
  2206.         write_bl(P2),
  2207.         write_bl(plays),
  2208.         write_nl(Name),
  2209.         delete(Card1,H2,Nh2),
  2210.         Newhigh2 = Newhigh1,
  2211.         Newwhohigh2 = Newwhohigh1,
  2212.         put_hand(Players,Newhands1,P2,Nh2,Newhands2),
  2213.         get_hand(Players,Newplayed1,P2,Pl1),
  2214.         Pl2 = [Card1 | Pl1],
  2215.         Newcards2 = [Card1 | Newcards1],
  2216.    %/*     write_bl(newcards2),write_nl(Newcards2), */
  2217.         put_hand(Players,Newplayed1,P2,Pl2,Newplayed2). %/* was , */
  2218.    %/*     write_bl(newplayed2),write_nl(Newplayed2). */
  2219. play_1card([Players,Newhands1,Newplayed1,P2,Newhands2,Newplayed2,
  2220.         Newhigh1,Newwhohigh1,Newhigh2,Newwhohigh2,
  2221.         Newcards1,Newcards2,Suite]) :-
  2222.         get_hand(Players,Newhands1,P2,H2),
  2223.         H2 = [],!,
  2224.         asserta(is_out(P2)), 
  2225.                 write_bl(P2),
  2226.                 write_nl(is_out),
  2227.         Newhigh2 = Newhigh1,
  2228.         Newhands2 = Newhands1,
  2229.         Newplayed2 = Newplayed1,
  2230.         Newcards2 = Newcards1, 
  2231.         Newwhohigh2 = Newwhohigh1.
  2232. %/* rule repeated 3 times for 3 chances */
  2233. play_1card([Players,Newhands1,Newplayed1,dennis,Newhands2,Newplayed2,
  2234.         Newhigh1,Newwhohigh1,Newhigh2,Newwhohigh2,
  2235.         Newcards1,Newcards2,Suite]) :-
  2236.         get_hand(Players,Newhands1,dennis,H2),
  2237.         write_bl(play),
  2238.         write_bl(what),
  2239.         write_nl(card),
  2240.         read(Name),
  2241.         valid_card(Name,Suite,H2),!,
  2242.         play_1card_b([Players,Newhands1,Newplayed1,dennis,Newhands2,Newplayed2,
  2243.         Newhigh1,Newwhohigh1,Newhigh2,Newwhohigh2,
  2244.         Newcards1,Newcards2,Suite],Name,H2).
  2245. play_1card([Players,Newhands1,Newplayed1,dennis,Newhands2,Newplayed2,
  2246.         Newhigh1,Newwhohigh1,Newhigh2,Newwhohigh2,
  2247.         Newcards1,Newcards2,Suite]) :-
  2248.         get_hand(Players,Newhands1,dennis,H2),
  2249.         write_bl(play),
  2250.         write_bl(what),
  2251.         write_nl(card),
  2252.         read(Name),
  2253.         valid_card(Name,Suite,H2),!,
  2254.         play_1card_b([Players,Newhands1,Newplayed1,dennis,Newhands2,Newplayed2,
  2255.         Newhigh1,Newwhohigh1,Newhigh2,Newwhohigh2,
  2256.         Newcards1,Newcards2,Suite],Name,H2).
  2257. play_1card([Players,Newhands1,Newplayed1,dennis,Newhands2,Newplayed2,
  2258.         Newhigh1,Newwhohigh1,Newhigh2,Newwhohigh2,
  2259.         Newcards1,Newcards2,Suite]) :-
  2260.         get_hand(Players,Newhands1,dennis,H2),
  2261.         write_bl(play),
  2262.         write_bl(what),
  2263.         write_nl(card),
  2264.         read(Name),
  2265.         valid_card(Name,Suite,H2),!,
  2266.         play_1card_b([Players,Newhands1,Newplayed1,dennis,Newhands2,Newplayed2,
  2267.         Newhigh1,Newwhohigh1,Newhigh2,Newwhohigh2,
  2268.         Newcards1,Newcards2,Suite],Name,H2).
  2269.  
  2270. play_1card_b([Players,Newhands1,Newplayed1,dennis,Newhands2,Newplayed2,
  2271.         Newhigh1,Newwhohigh1,Newhigh2,Newwhohigh2,
  2272.         Newcards1,Newcards2,Suite],Name,H2) :-
  2273.         card([Card1,Val,Suite,Name,Pt_taken,Pt_played]),
  2274.         Val > Newhigh1, ! ,
  2275.         write_bl(dennis),
  2276.         write_bl(plays),
  2277.         write_nl(Name),
  2278.         delete(Card1,H2,Nh2),
  2279.         Newhigh2 = Val,
  2280.         Newwhohigh2 = dennis,
  2281.         put_hand(Players,Newhands1,dennis,Nh2,Newhands2),
  2282.         get_hand(Players,Newplayed1,dennis,Pl1),
  2283.         Pl2 = [Card1 | Pl1],
  2284.         Newcards2 = [Card1 | Newcards1],
  2285.   %/*      write_bl(newcards2),write_nl(Newcards2), */
  2286.         put_hand(Players,Newplayed1,dennis,Pl2,Newplayed2). %/* was , */
  2287.     %/*    write_bl(newplayed2),write_nl(Newplayed2). */
  2288.         
  2289.  
  2290. play_1card_b([Players,Newhands1,Newplayed1,dennis,Newhands2,Newplayed2,
  2291.         Newhigh1,Newwhohigh1,Newhigh2,Newwhohigh2,
  2292.         Newcards1,Newcards2,Suite],Name,H2) :-
  2293.         card([Card1,Val,Suite,Name,Pt_taken,Pt_played]),
  2294.         Val < Newhigh1, ! ,
  2295.         write_bl(dennis),
  2296.         write_bl(plays),
  2297.         write_nl(Name),
  2298.         delete(Card1,H2,Nh2),
  2299.         Newhigh2 = Newhigh1,
  2300.         Newwhohigh2 = Newwhohigh1,
  2301.         put_hand(Players,Newhands1,dennis,Nh2,Newhands2),
  2302.         get_hand(Players,Newplayed1,dennis,Pl1),
  2303.         Pl2 = [Card1 | Pl1],
  2304.         Newcards2 = [Card1 | Newcards1],
  2305.    %/*     write_bl(newcards2),write_nl(Newcards2), */
  2306.         put_hand(Players,Newplayed1,dennis,Pl2,Newplayed2). %/* was , */
  2307.    %/*     write_bl(newplayed2),write_nl(Newplayed2). */
  2308.  
  2309. summary_cards_taken([Players,Taken,Newtaken,Newhigh4,Newwhohigh4,
  2310.         Newcards4,Newleader]):-
  2311.         get_hand(Players,Taken,Newwhohigh4,H2),
  2312.         append_djd(H2,Newcards4,H3),
  2313.                 write_bl(Newwhohigh4),
  2314.                 write_nl(takes_the_hand),
  2315.         Newleader = Newwhohigh4,
  2316.         put_hand(Players,Taken,Newwhohigh4,H3,Newtaken). %/* was , */
  2317.    %/*     write_bl(newtaken),write_nl(Newtaken). */
  2318. write_nl(X) :- write(X), put(46), put(10), put(13).
  2319. %                write(Log,X), put(Log,46), put(Log,10), put(Log,13).
  2320. write_bl(X) :- write(X), put(32).
  2321. %                 write(Log,X), put(Log,32).
  2322.         
  2323.         
  2324. score(Players,Teams,Played,Taken,Scores,Newscores,Bidder,Bid,Suite) :- 
  2325.         Scores = [S1,S2],
  2326.                 Players = [P1,P2,P3,P4],
  2327.                 get_hand(Players,Taken,P1,Card1s_taken1),
  2328.                 pts_taken(Card1s_taken1,Suite,Score_addt1,0),
  2329.                 get_hand(Players,Played,P1,Card1s_played1),
  2330.                 pts_played(Card1s_played1,Suite,Score_addp1,0),
  2331.                 get_hand(Players,Taken,P2,Card1s_taken2),
  2332.                 pts_taken(Card1s_taken2,Suite,Score_addt2,0),
  2333.                 get_hand(Players,Played,P2,Card1s_played2),
  2334.                 pts_played(Card1s_played2,Suite,Score_addp2,0),
  2335.                 get_hand(Players,Taken,P3,Card1s_taken3),
  2336.                 pts_taken(Card1s_taken3,Suite,Score_addt3,0),
  2337.                 get_hand(Players,Played,P3,Card1s_played3),
  2338.                 pts_played(Card1s_played3,Suite,Score_addp3,0),
  2339.                 get_hand(Players,Taken,P4,Card1s_taken4),
  2340.                 pts_taken(Card1s_taken4,Suite,Score_addt4,0),
  2341.                 get_hand(Players,Played,P4,Card1s_played4),
  2342.                 pts_played(Card1s_played4,Suite,Score_addp4,0),
  2343.                 (Pts1 -> Score_addt1 + Score_addp1 + Score_addt3 + 
  2344.                  Score_addp3),
  2345.                 (Pts2 -> Score_addt2 + Score_addp2 + Score_addt4 + 
  2346.                 Score_addp4),
  2347.                 Teams = [T1,T2],
  2348.                 member_djd(Bidder,T1),
  2349.                 Pts1 >= Bid, 
  2350.         (S1a -> S1 + Pts1),
  2351.         (S2a -> S2 + Pts2), 
  2352.         Newscores = [S1a,S2a],
  2353.         write_nl(p_score),
  2354.         write_nl(Teams),
  2355.         write_nl(Scores),
  2356.         write_nl(Newscores).
  2357.  
  2358. score(Players,Teams,Played,Taken,Scores,Newscores,Bidder,Bid,Suite) :- 
  2359.         Scores = [S1,S2],
  2360.                 Players = [P1,P2,P3,P4],
  2361.                 get_hand(Players,Taken,P1,Card1s_taken1),
  2362.                 pts_taken(Card1s_taken1,Suite,Score_addt1,0),
  2363.                 get_hand(Players,Played,P1,Card1s_played1),
  2364.                 pts_played(Card1s_played1,Suite,Score_addp1,0),
  2365.                 get_hand(Players,Taken,P2,Card1s_taken2),
  2366.                 pts_taken(Card1s_taken2,Suite,Score_addt2,0),
  2367.                 get_hand(Players,Played,P2,Card1s_played2),
  2368.                 pts_played(Card1s_played2,Suite,Score_addp2,0),
  2369.                 get_hand(Players,Taken,P3,Card1s_taken3),
  2370.                 pts_taken(Card1s_taken3,Suite,Score_addt3,0),
  2371.                 get_hand(Players,Played,P3,Card1s_played3),
  2372.                 pts_played(Card1s_played3,Suite,Score_addp3,0),
  2373.                 get_hand(Players,Taken,P4,Card1s_taken4),
  2374.                 pts_taken(Card1s_taken4,Suite,Score_addt4,0),
  2375.                 get_hand(Players,Played,P4,Card1s_played4),
  2376.                 pts_played(Card1s_played4,Suite,Score_addp4,0),
  2377.                 (Pts1 -> Score_addt1 + Score_addp1 + Score_addt3 + 
  2378.                 Score_addp3),
  2379.                 (Pts2 -> Score_addt2 + Score_addp2 + Score_addt4 + 
  2380.                 Score_addp4),
  2381.                 Teams = [T1,T2],
  2382.                 member_djd(Bidder,T2),
  2383.                 Pts2 >= Bid, 
  2384.         (S1a -> S1 + Pts1),
  2385.         (S2a -> S2 + Pts2), 
  2386.         Newscores = [S1a,S2a],
  2387.         write_nl(p_score),
  2388.         write_nl(Teams),
  2389.         write_nl(Scores),
  2390.         write_nl(Newscores).
  2391.  
  2392. score(Players,Teams,Played,Taken,Scores,Newscores,Bidder,Bid,Suite) :- 
  2393.         Scores = [S1,S2],
  2394.                 Players = [P1,P2,P3,P4],
  2395.                 get_hand(Players,Taken,P1,Card1s_taken1),
  2396.                 pts_taken(Card1s_taken1,Suite,Score_addt1,0),
  2397.                 get_hand(Players,Played,P1,Card1s_played1),
  2398.                 pts_played(Card1s_played1,Suite,Score_addp1,0),
  2399.                 get_hand(Players,Taken,P2,Card1s_taken2),
  2400.                 pts_taken(Card1s_taken2,Suite,Score_addt2,0),
  2401.                 get_hand(Players,Played,P2,Card1s_played2),
  2402.                 pts_played(Card1s_played2,Suite,Score_addp2,0),
  2403.                 get_hand(Players,Taken,P3,Card1s_taken3),
  2404.                 pts_taken(Card1s_taken3,Suite,Score_addt3,0),
  2405.                 get_hand(Players,Played,P3,Card1s_played3),
  2406.                 pts_played(Card1s_played3,Suite,Score_addp3,0),
  2407.                 get_hand(Players,Taken,P4,Card1s_taken4),
  2408.                 pts_taken(Card1s_taken4,Suite,Score_addt4,0),
  2409.                 get_hand(Players,Played,P4,Card1s_played4),
  2410.                 pts_played(Card1s_played4,Suite,Score_addp4,0),
  2411.                 (Pts1 -> Score_addt1 + Score_addp1 + Score_addt3 + 
  2412.                 Score_addp3),
  2413.                 (Pts2 -> Score_addt2 + Score_addp2 + Score_addt4 + 
  2414.                 Score_addp4),
  2415.                 Teams = [T1,T2],
  2416.                 member_djd(Bidder,T1),
  2417.                 Pts1 < Bid, 
  2418.         (S1a -> S1 - Bid),
  2419.         (S2a -> S2 + Pts2), 
  2420.         Newscores = [S1a,S2a],
  2421.         write_nl(bidder_went_set),
  2422.         write_nl(p_score),
  2423.         write_nl(Teams),
  2424.         write_nl(Scores),
  2425.         write_nl(Newscores).
  2426.  
  2427. score(Players,Teams,Played,Taken,Scores,Newscores,Bidder,Bid,Suite) :- 
  2428.         Scores = [S1,S2],
  2429.                 Players = [P1,P2,P3,P4],
  2430.                 get_hand(Players,Taken,P1,Card1s_taken1),
  2431.                 pts_taken(Card1s_taken1,Suite,Score_addt1,0),
  2432.                 get_hand(Players,Played,P1,Card1s_played1),
  2433.                 pts_played(Card1s_played1,Suite,Score_addp1,0),
  2434.                 get_hand(Players,Taken,P2,Card1s_taken2),
  2435.                 pts_taken(Card1s_taken2,Suite,Score_addt2,0),
  2436.                 get_hand(Players,Played,P2,Card1s_played2),
  2437.                 pts_played(Card1s_played2,Suite,Score_addp2,0),
  2438.                 get_hand(Players,Taken,P3,Card1s_taken3),
  2439.                 pts_taken(Card1s_taken3,Suite,Score_addt3,0),
  2440.                 get_hand(Players,Played,P3,Card1s_played3),
  2441.                 pts_played(Card1s_played3,Suite,Score_addp3,0),
  2442.                 get_hand(Players,Taken,P4,Card1s_taken4),
  2443.                 pts_taken(Card1s_taken4,Suite,Score_addt4,0),
  2444.                 get_hand(Players,Played,P4,Card1s_played4),
  2445.                 pts_played(Card1s_played4,Suite,Score_addp4,0),
  2446.                 (Pts1 -> Score_addt1 + Score_addp1 + Score_addt3 + 
  2447.                 Score_addp3),
  2448.                 (Pts2 -> Score_addt2 + Score_addp2 + Score_addt4 + 
  2449.                 Score_addp4),
  2450.                 Teams = [T1,T2],
  2451.                 member_djd(Bidder,T2),
  2452.                 Pts2 < Bid, 
  2453.         (S1a -> S1 + Pts1),
  2454.         (S2a -> S2 - Bid), 
  2455.         Newscores = [S1a,S2a],
  2456.         write_nl(bidder_went_set),
  2457.         write_nl(p_score),
  2458.         write_nl(Teams),
  2459.         write_nl(Scores),
  2460.         write_nl(Newscores).
  2461.  
  2462. pts_taken(Card1s_taken1,Suite,Score_add1,Temp) :-
  2463.         Card1s_taken1 = [Card1 | Card1s_left],
  2464.     card([Card1,Val,Suite,Name,Pt_taken,Pt_played]),
  2465.         (Temp2 = Temp + Pt_taken),
  2466.         pts_taken(Card1s_left,Suite,Score_add1,Temp2).
  2467. pts_taken(Card1s_taken1,Suite,Score_add1,Temp) :-
  2468.         Card1s_taken1 = [], ! ,
  2469.         Score_add1 = Temp.
  2470.         
  2471. pts_played(Card1s_played1,Suite,Score_add1,Temp) :-
  2472.         Card1s_played1 = [Card1 | Card1s_left],
  2473.     card([Card1,Val,Suite,Name,Pt_taken,Pt_played]),
  2474.         (Temp2 = Temp + Pt_played),
  2475.         pts_played(Card1s_left,Suite,Score_add1,Temp2).
  2476. pts_played(Card1s_played1,Suite,Score_add1,Temp) :-
  2477.         Card1s_played1 = [], ! ,
  2478.         Score_add1 = Temp.
  2479.  
  2480. %/* lead highest card left */
  2481. best_card(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,Card1,
  2482.     Suite,Newhigh1,Newwhohigh1) :-
  2483.     \+(am_last_to_play(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2484.     Card1,Suite)),
  2485.     have_highest_card_left(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2486.     Cardx,Suite),
  2487.     Card1 = Cardx,
  2488. %/*    write_nl(have_highest_card), */
  2489.     card([Card1,Val,Suite,Name,Pt_taken,Pt_played]).
  2490. %/* take point card - last (with smallest card that woll take because sorted*/
  2491. best_card(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,Card1,
  2492.     Suite,Newhigh1,Newwhohigh1) :-
  2493.     am_last_to_play(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2494.     Card1,Suite),
  2495.     pt_card_played(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2496.     Cardp,Suite),
  2497.     have_higher_card_left(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2498.     Cardx,Suite),
  2499.     \+(partner(P2,Newwhohigh1)),
  2500.     Card1 = Cardx,
  2501. %/*    write_nl(take_pt_card_last), */
  2502.     card([Card1,Val,Suite,Name,Pt_taken,Pt_played]).
  2503. %/* save point cards playing last */
  2504. best_card(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,Card1,
  2505.     Suite,Newhigh1,Newwhohigh1) :-
  2506.     am_last_to_play(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2507.     Card1,Suite),
  2508.     can_save_point(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2509.     Cardx,Suite),
  2510.     Card1 = Cardx,
  2511. %/*    write_nl(can_save_point), */
  2512.     card([Card1,Val,Suite,Name,Pt_taken,Pt_played]).
  2513. %/* opponent has played high card - plays small card */
  2514. best_card(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,Card1,
  2515.     Suite,Newhigh1,Newwhohigh1) :-
  2516.     \+(have_highest_card_left(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2517.     Cardw,Suite)),
  2518.     \+(partner(P2,Newwhohigh1)),
  2519.     have_small_card(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2520.     Cardx,Suite),
  2521.     Card1 = Cardx,
  2522.     card([Card1,Val,Suite,Name,Pt_taken,Pt_played]).
  2523. %/*    write_nl(play_small_card). */
  2524.     
  2525. %/* partner has played high card - plays point card */
  2526. best_card(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,Card1,
  2527.     Suite,Newhigh1,Newwhohigh1) :-
  2528.     \+(have_highest_card_left(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2529.     Cardw,Suite)),
  2530.     partner(P2,Newwhohigh1),
  2531.     have_point_card(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2532.     Cardx,Suite),
  2533.     Card1 = Cardx,
  2534.     card([Card1,Val,Suite,Name,Pt_taken,Pt_played]).
  2535. %/*    write_nl(play_point_card). */
  2536.     
  2537. %/* no special rule applied so play any card */
  2538. best_card(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,Card1,
  2539.     Suite,Newhigh1,Newwhohigh1) :-
  2540.         H2 = [Card1 | H3],
  2541.         card([Card1,Val,Suite,Name,Pt_taken,Pt_played]).
  2542.         
  2543. have_highest_card_left(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2544.     Cardx,Suite) :-
  2545.     member_djd(Cardx,H2),
  2546.     card([Cardx,Val,Suite,Name,Pt_taken,Pt_played]),
  2547.     \+(exists_higher_card_not_in_list(Newcards1,Suite,Val,Newplayed1)).
  2548. exists_higher_card_not_in_list(Newcards1,Suite,Val,Newplayed1) :-
  2549.     card([Card2,Val2,Suite,Name,Pt_taken,Pt_played]),
  2550.     Val2 > Val,
  2551.     \+(sub_member(Card2,Newplayed1,Newcards1)).
  2552. sub_member(Card2,Newplayed1,Newcards1) :-
  2553.     member_djd(Pl,Newplayed1),
  2554.     \+(member_djd(Card2,Newcards1)),
  2555.     member_djd(Card2,Pl).
  2556.  
  2557. point_card_played(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2558.     Card1,Suite) :-
  2559.     member_djd(Card,Newcards1),
  2560.     card([Card,Val,Suite,Name,Pt_taken,Pt_played]),
  2561.     Pt_taken > 0.
  2562. am_first_to_play(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2563.     Card1,Suite) :-
  2564.     length_djd(Newcards1,Len),
  2565.     Len = 0.    
  2566. am_last_to_play(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2567.     Card1,Suite) :-
  2568.     length_djd(Newcards1,Len),
  2569.     Len = 3.    
  2570. am_last_to_play(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2571.     Card1,Suite) :-
  2572.     length_djd(Newcards1,Len),
  2573.     succ_player(P2,P3),
  2574.     is_out(P3),
  2575.     Len = 2.    
  2576. am_last_to_play(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2577.     Card1,Suite) :-
  2578.     length_djd(Newcards1,Len),
  2579.     succ_player(P2,P3),
  2580.     is_out(P3),
  2581.     succ_player(P3,P4),
  2582.     is_out(P4),
  2583.     Len = 1.    
  2584. point_card_may_be_played(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2585.     Card1,Suite) :-
  2586.     \+(am_last_to_play(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2587.     Card1,Suite)),
  2588.     card([Card2,Val2,Suite,Name,Pt_taken,Pt_played]),
  2589.     Pt_taken > 0,
  2590.     \+(sub_member(Card2,Newplayed1)).
  2591. can_save_point(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2592.     Cardx,Suite) :-
  2593.     am_last_to_play(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2594.     Cardx,Suite),
  2595.     member_djd(Cardx,H2),
  2596.     card([Cardx,Val,Suite,Name,Pt_taken,Pt_played]),
  2597.     Pt_taken > 0,
  2598.     \+(exists_higher_card_in_list(Val,Newcards1,Suite)).
  2599. exists_higher_card_in_list(Val,Newcards1,Suite) :-
  2600.     member_djd(Card2,Newcards1),
  2601.     card([Card2,Val2,Suite,Name,Pt_taken,Pt_played]),
  2602.     Val2 > Val.
  2603.     
  2604. partner_played_highest_card_so_far(Players,P2,H2,Newplayed1,Newtaken1,
  2605.     Newcards1,Card1,Suite,Newhigh1,Newwhohigh1) :-
  2606.     partner(P2,Newwhohigh1).
  2607.     
  2608. have_small_card(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2609.     Cardx,Suite) :-
  2610.     member_djd(Cardx,H2),
  2611.     card([Cardx,Val,Suite,Name,Pt_taken,Pt_played]),
  2612.     Val < 10.
  2613. have_point_card(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2614.     Cardx,Suite) :-
  2615.     member_djd(Cardx,H2),
  2616.     card([Cardx,Val,Suite,Name,Pt_taken,Pt_played]),
  2617.     Pt_taken > 0.
  2618.     
  2619.     
  2620. display_hand(H) :-
  2621.     H = [C | H2],
  2622.     card([C,Val,Suite,Name,Pt_taken,Pt_played]),
  2623.     write_bl(C),
  2624.     write_nl(Name),
  2625.     display_hand(H2).
  2626. display_hand([]).
  2627.  
  2628. pt_card_played(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2629. Cardp,Suite) :-
  2630.     member_djd(Cardp,Newcards1),
  2631.     card([Cardp,Val,Suite,Name,Pt_taken,Pt_played]),
  2632.     Pt_taken > 0.
  2633.     
  2634. have_higher_card_left(Players,P2,H2,Newplayed1,Newtaken1,Newcards1,
  2635. Cardx,Suite) :-
  2636.     member_djd(Cardx,H2),
  2637.     card([Cardx,Val,Suite,Name,Pt_taken,Pt_played]),
  2638.     \+(exists_higher_card_in_list(Newcards1,Suite,Val)).
  2639.     
  2640. exists_higher_card_in_list(Newcards1,Suite,Val) :-
  2641.     card([Card2,Val2,Suite,Name,Pt_taken,Pt_played]),
  2642.     Val2 > Val,
  2643.     member_djd(Card2,Newcards1).
  2644. sort_by_val(H,Hs,Suite) :-
  2645.     get_vals(H,V,Suite),
  2646.     sort(V,Vs),
  2647.     get_nos(Vs,Hs,Suite).
  2648. get_vals([],[],Suite).
  2649. get_vals(H,V,Suite) :-
  2650.     H = [No | Nos],
  2651.     card([No,Val,Suite,Name,Pt_taken,Pt_played]),
  2652.     get_vals(Nos,Vals,Suite),
  2653.     V = [Val | Vals].
  2654. get_nos([],[],Suite).
  2655. get_nos(V,H,Suite) :-
  2656.     V = [Val | Vals],
  2657.     card([No,Val,Suite,Name,Pt_taken,Pt_played]),
  2658.     get_nos(Vals,Nos,Suite),
  2659.     H = [No | Nos].
  2660. minimimd(N1,N2,N1) :- N1 =< N2.
  2661. minimimd(N1,N2,N2) :- N2 =< N1.
  2662. can_bid(Guess,Hand,Suite1,Bidder) :-
  2663.     member_djd(S,[diamonds,clubs,spades,hearts]),
  2664.     can_bid_suite(Guess2,Hand,S,Bidder),
  2665.     Suite1 = S,
  2666.     minimimd(7,Guess2,Guess).
  2667. can_bid(0,Hand,pass,Bidder).
  2668. bind_cs(0.6,0.04,0.04,1.0,0.2,dennis).
  2669. bind_cs(0.6,0.04,0.04,1.0,0.2,dick).
  2670. bind_cs(0.5,0.05,0.05,1.0,0.2,sussy).
  2671. bind_cs(0.5,0.05,0.05,1.0,0.2,john).
  2672. can_bid_suite(Guess,Hand,Suite1,Bidder) :- 
  2673.     discard_non_suite(Hand,Nh1,[],Handsuite,Suite1),
  2674.     get_vals(Handsuite,Vals,Suite1),
  2675.     no_high_cards(Vals,No_high),
  2676. %/*    write_bl(no_high),write_nl(No_high), */
  2677.     tot_face(Vals,Tot_face),
  2678. %/*    write_bl(no_face),write_nl(Tot_face), */
  2679.     tot_pts(Vals,Tot_pts),
  2680. %/*    write_bl(no_pts),write_nl(Tot_pts), */
  2681.     no_sure(Vals,No_sure),
  2682. %/*    write_bl(no_sure),write_nl(No_sure), */
  2683.     length_djd(Vals,No_cds),
  2684. %/*    write_bl(no_cds),write_nl(No_cds), */
  2685.     bind_cs(C1,C2,C3,C4,C5,Bidder),
  2686.     (Guessf1 = C1 * No_high) ,
  2687.         (Guessf2 = Guessf1 + C2 * Tot_face),
  2688.     (Guessf3 = Guessf2 + C3 * Tot_pts),
  2689.     (Guessf4 = Guessf3 + C4 * No_sure),
  2690.     (Guessf5 = Guessf4 + C5 * No_cds),
  2691.     (Guess = floor(Guessf5)).
  2692.  
  2693. no_high_cards(Vals,6) :-
  2694.     member_djd(17,Vals),
  2695.     member_djd(16,Vals),
  2696.     member_djd(15,Vals),
  2697.     member_djd(14,Vals),
  2698.     member_djd(13,Vals),
  2699.     member_djd(12,Vals),!.
  2700. no_high_cards(Vals,5) :-
  2701.     member_djd(17,Vals),
  2702.     member_djd(16,Vals),
  2703.     member_djd(15,Vals),
  2704.     member_djd(14,Vals),
  2705.     member_djd(13,Vals),!.
  2706. no_high_cards(Vals,4) :-
  2707.     member_djd(17,Vals),
  2708.     member_djd(16,Vals),
  2709.     member_djd(15,Vals),
  2710.     member_djd(14,Vals),!.
  2711. no_high_cards(Vals,3) :-
  2712.     member_djd(17,Vals),
  2713.     member_djd(16,Vals),
  2714.     member_djd(15,Vals),!.
  2715. no_high_cards(Vals,2) :-
  2716.     member_djd(17,Vals),
  2717.     member_djd(16,Vals),!.
  2718. no_high_cards(Vals,1) :-
  2719.     member_djd(17,Vals),!.
  2720. no_high_cards(Vals,0) :-
  2721.     \+(member_djd(17,Vals)),!.
  2722.     
  2723. tot_face([],0). 
  2724. tot_face(Vals,Tot_face) :-
  2725.     Vals = [V1 | Vs],
  2726.     V1 > 10,!,
  2727.     tot_face(Vs,Tot2),
  2728.     (Tot_face = V1 + Tot2). 
  2729. tot_face(Vals,Tot_face) :-
  2730.     Vals = [V1 | Vs],
  2731.     V1 =< 10,!,
  2732.     tot_face(Vs,Tot2),
  2733.     Tot_face = Tot2.
  2734. tot_pts([],0).
  2735. tot_pts(Vals,Tot_pts) :-
  2736.     Vals = [V1 | Vs],
  2737.     V1 > 9,
  2738.     V1 < 14,!,
  2739.     tot_pts(Vs,Tot2),
  2740.     (Tot_pts = V1 + Tot2). 
  2741. tot_pts(Vals,Tot_pts) :-
  2742.     Vals = [V1 | Vs],
  2743.     V1 < 10,!,
  2744.     tot_pts(Vs,Tot2),
  2745.     Tot_pts = Tot2. 
  2746. tot_pts(Vals,Tot_pts) :-
  2747.     Vals = [V1 | Vs],
  2748.     V1 < 10,!,
  2749.     tot_pts(Vs,Tot2),
  2750.     Tot_pts = Tot2. 
  2751. no_sure(Vals,2) :-
  2752.     member_djd(2,Vals),
  2753.     member_djd(17,Vals),!.
  2754. no_sure(Vals,1) :-
  2755.     member_djd(2,Vals),
  2756.     \+(member_djd(17,Vals)),!.
  2757. no_sure(Vals,1) :-
  2758.     \+(member_djd(2,Vals)),
  2759.     member_djd(17,Vals),!.
  2760. no_sure(Vals,0) :-
  2761.     \+(member_djd(2,Vals)),
  2762.     \+(member_djd(17,Vals)),!.
  2763. %trace(true)?
  2764.  
  2765. play_game(R,S)?
  2766. retract_out(Players) :- 
  2767.