Research portable Memory game | Исследовать портируемую игру Память
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

6 ay önce
6 ay önce
6 ay önce
6 ay önce
6 ay önce
6 ay önce
6 ay önce
6 ay önce
6 ay önce
6 ay önce
6 ay önce
6 ay önce
6 ay önce
6 ay önce
6 ay önce
6 ay önce
6 ay önce
6 ay önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. from memory_Context import *
  2. from llm import *
  3. # Greet the user
  4. #
  5. # Conditions:
  6. # 1. Just launched
  7. @llm_by_value
  8. def cli_greetUser(
  9. c: memory_Context
  10. ) -> memory_Context:
  11. if (
  12. c.recentField == "didLaunch" and
  13. c.didLaunch == True
  14. ):
  15. c.outputGreeting = "OGS Memory Command Line Interface"
  16. c.recentField = "outputGreeting"
  17. return c
  18. #}
  19. c.recentField = "none"
  20. return c
  21. #}
  22. # Show help (aka commands)
  23. #
  24. # Conditions:
  25. # 1. Just launched
  26. # 1. `h` or `help` was entered
  27. @llm_by_value
  28. def cli_showHelp(
  29. c: memory_Context
  30. ) -> memory_Context:
  31. if (
  32. (
  33. c.recentField == "didLaunch" and
  34. c.didLaunch == True
  35. ) or
  36. (
  37. c.recentField == "input" and
  38. c.input == "h"
  39. ) or
  40. (
  41. c.recentField == "input" and
  42. c.input == "help"
  43. )
  44. ):
  45. c.outputHelp = "Commands:\n\te, exit, q, quit\n\t\tExit\n\th, help\n\t\tList commands\n\t1, 2, 3, ...\n\t\tSelect item\nEnter your choice:"
  46. c.recentField = "outputHelp"
  47. return c
  48. #}
  49. c.recentField = "none"
  50. return c
  51. #}
  52. ## Select item
  53. ##
  54. ## Conditions:
  55. ## 1. Id is digit, in bounds and not hidden
  56. #@llm_by_value
  57. #def cli_selectItem(
  58. # c: cli_Context
  59. #) -> cli_Context:
  60. # if (
  61. # c.input.isdigit()
  62. # ):
  63. # # User ids start with 1 while memory module has ids starting with 0
  64. # # Convert cli item id to memory item id
  65. # c.cMemory.selectedId = int(c.input) - 1
  66. # c.cMemory = memory_selectItem(c.cMemory)
  67. # c.recentField = "cMemory"
  68. # return c
  69. # #}
  70. # c.recentField = "none"
  71. # return c
  72. ##}
  73. #
  74. ## Ask user to select another item to have a pair of selected items
  75. #@llm_by_value
  76. #def cli_shouldPromptSelection(
  77. # c: cli_Context
  78. #) -> cli_Context:
  79. # if (
  80. # c.recentField == "cMemory" and
  81. # c.cMemory.recentField == "selectedItems" and
  82. # len(c.cMemory.selectedItems) == 1
  83. # ):
  84. # c.outputPromptSelection = "Select the second item now:"
  85. # c.recentField = "outputPromptSelection"
  86. # return c
  87. # #}
  88. # c.recentField = "none"
  89. # return c
  90. ##}
  91. #
  92. ## Report matched items
  93. #@llm_by_value
  94. #def cli_shouldReportMatchedItems(
  95. # c: cli_Context
  96. #) -> cli_Context:
  97. # if (
  98. # c.recentField == "cMemory" and
  99. # c.cMemory.recentField == "hiddenItems"
  100. # ):
  101. # c.outputMatchedItems = "Items matched! Go on:"
  102. # c.recentField = "outputMatchedItems"
  103. # return c
  104. # #}
  105. # c.recentField = "none"
  106. # return c
  107. ##}
  108. #
  109. ## Report mismatched items
  110. #@llm_by_value
  111. #def cli_shouldReportMismatchedItems(
  112. # c: cli_Context
  113. #) -> cli_Context:
  114. # if (
  115. # c.recentField == "cMemory" and
  116. # c.cMemory.recentField == "mismatchedItems"
  117. # ):
  118. # c.outputMatchedItems = "Wrong! Try again:"
  119. # c.recentField = "outputMismatchedItems"
  120. # return c
  121. # #}
  122. # c.recentField = "none"
  123. # return c
  124. ##}
  125. #
  126. ## Report selection of invalid item ids
  127. ##
  128. ## Conditions:
  129. ## 1. Index out of bounds: less than minimum
  130. ## 2. Index out of bounds: greater than maximum
  131. ## 3. Item is already hidden
  132. ##@llm_by_value
  133. ##def cli_shouldReportInvalidItemSelection(
  134. ## c: cli_Context
  135. ##) -> cli_Context:
  136. ## if (
  137. ## c.recentField == "cMemory" and
  138. ## c.cMemory.recentField == "selectedItems" and
  139. ## len(c.cMemory.selectedItems) == 1
  140. ## ):
  141. ## c.outputPromptSelection = "Select the second item now:"
  142. ## c.recentField = "outputPromptSelection"
  143. ## return c
  144. ## #}
  145. ## c.recentField = "none"
  146. ## return c
  147. ###}