Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.26 KB | None | 0 0
  1. %--------------------------------------
  2. %Frames go here
  3. frame global ;
  4. default worldExtent is 5 and
  5. default current_name is none and
  6. default temp_x is 0 and
  7. default temp_y is 0 and
  8. default wtemp_x is none and
  9. default wtemp_y is none and
  10. default cof_temp_x is 0 and
  11. default cof_temp_y is 0 and
  12. default cof_name is none and
  13. default cw_temp_x is 0 and
  14. default cw_temp_y is 0 and
  15. default cw_name is none and
  16. default rm_x is 0 and
  17. default rm_x is 0 and
  18. default rm_next is none and
  19. default damage_caused is 15 and
  20. default wumpus_move is none and
  21. default moved is no and
  22. default drainSanity is none and
  23. default soundDirection is none and
  24. default is_s is none and
  25. default random_number is 0 and
  26. default random_num_two is 0 and
  27. default elementNum is 5 and
  28. default elementNumTwo is 6 and
  29. default remove_wumpus is none and
  30. default old_temp_x is 0 and
  31. default old_temp_y is 0 and
  32. default moved_taken is ok.
  33.  
  34. action yea;
  35. echo (elementNum).
  36.  
  37.  
  38. frame cell ;
  39. default x_value is 0 and
  40. default y_value is 0 and
  41. default id is empty and
  42. default visited is false and
  43. default object_1 is empty and
  44. default object_2 is empty and
  45. default object_3 is empty.
  46.  
  47. frame actor ;
  48. default x_value is 0 and
  49. default y_value is 0 and
  50. default sanity is 100.
  51.  
  52. frame wumpus ;
  53. default x_value is 0 and
  54. default y_value is 0 and
  55. default status is dead and
  56. default wumpusName is none.
  57.  
  58. frame trap_coffee ;
  59. default x_value is 0 and
  60. default y_value is 0 and
  61. default trapName is none.
  62.  
  63. frame trap_coursework ;
  64. default x_value is 0 and
  65. default y_value is 0 and
  66. default trapName is none.
  67.  
  68. frame item;
  69. default x_value is 0 and
  70. default y_value is 0 and
  71. default item_name is none and
  72. default value is 0.
  73.  
  74.  
  75. %--------------------------------------
  76. %Instances of frames go here
  77.  
  78. instance hero is an actor ;
  79. x_value is 0 and
  80. y_value is 0 and
  81. next_x_value is 0 and
  82. next_y_value is 0 and
  83. next_direction is 0 and
  84. sanity is 100 and
  85. held_item_0 is empty and
  86. held_item_1 is empty and
  87. held_item_2 is empty and
  88. held_item_3 is empty and
  89. held_item_4 is empty and
  90. held_item_5 is empty.
  91.  
  92. instance stairs is an item;
  93. x_value is 0 and
  94. y_value is 0 and
  95. item_name is none and
  96. value is 0.
  97.  
  98. instance marked_coursework is an item;
  99. x_value is 0 and
  100. y_value is 0 and
  101. item_name is none and
  102. value is 0.
  103.  
  104. instance health_pack is an item;
  105. x_value is 0 and
  106. y_value is 0 and
  107. item_name is none and
  108. value is 0.
  109.  
  110. instance rubber_wellies is an item;
  111. x_value is 0 and
  112. y_value is 0 and
  113. item_name is none and
  114. value is 0.
  115.  
  116. instance lost_usb is an item;
  117. x_value is 0 and
  118. y_value is 0 and
  119. item_name is none and
  120. value is 0.
  121.  
  122. instance found_usb is an item;
  123. x_value is 0 and
  124. y_value is 0 and
  125. item_name is none and
  126. value is 0.
  127.  
  128. action gen_random;
  129. is(X, rand(5)) and
  130. random_number becomes X and
  131. invoke ruleset numberRounding.
  132.  
  133. action gen_random_two;
  134. is(X, rand(4)) and
  135. random_num_two becomes X and
  136. invoke ruleset numberRoundingTwo and
  137. echo(random_num_two).
  138.  
  139. %--------------------------------------
  140. %This is called by the java frontend to
  141. %get up to date world info
  142. action updateInfo ;
  143. do for every S is an instance of cell
  144. do write( S`s x_value ) and
  145. do write( ';' ) and
  146. do write( S`s y_value ) and
  147. do write( ';' ) and
  148. do write( S`s id ) and
  149. do write( ';' ) and
  150. do write( S`s visited ) and
  151. do write( ';' ) and
  152. do write( S`s object_1 ) and
  153. do write( ';' ) and
  154. do write( S`s object_2 ) and
  155. do write( ';' ) and
  156. do write( S`s object_3 ) and
  157. do write( '&' )
  158. end for.
  159.  
  160. action updateStatus ;
  161. write( hero`s sanity ) and
  162. write( ';' ) and
  163. write( hero`s held_item_0 ) and
  164. write( ';' ) and
  165. write( hero`s held_item_1 ) and
  166. write( ';' ) and
  167. write( hero`s held_item_2 ) and
  168. write( ';' ) and
  169. write( hero`s held_item_3 ) and
  170. write( ';' ) and
  171. write( hero`s held_item_4 ) and
  172. write( ';' ) and
  173. write( hero`s held_item_5 ) .
  174.  
  175. %--------------------------------------
  176. %This will generate a random wumpus onto
  177. %the grid.
  178. action place_wumpus;
  179. do for A from 1 to elementNum-4
  180. do new_instance(A,wumpus) and
  181. gen_random and
  182. A`s x_value becomes random_number and
  183. gen_random and
  184. A`s y_value becomes random_number and
  185. A`s wumpusName becomes wumpusLoc and
  186. temp_x becomes A`s x_value and
  187. temp_y becomes A`s y_value and
  188. current_name becomes A`s wumpusName and
  189. updateWumpusLocation
  190. end for and
  191. write('added wumpus').
  192.  
  193. action move_wumpus_random;
  194. do for every X is some instance of wumpus
  195. do
  196. wtemp_x becomes X`s x_value and
  197. wtemp_y becomes X`s y_value and
  198. temp_x becomes wtemp_x and
  199. temp_y becomes wtemp_y and
  200. invoke ruleset moveWumpusRemove and
  201. randomWumpusLocation and
  202. invoke ruleset collisionCheckw and
  203. invoke ruleset moveWumpusUpDate and
  204. X`s x_value becomes wtemp_x and
  205. X`s y_value becomes wtemp_y and
  206. moved_taken becomes ok and
  207. invoke ruleset wumpusSanity
  208. end for.
  209.  
  210. action randomWumpusLocation;
  211. write('called') and
  212. gen_random_two and
  213. wumpus_move becomes random_num_two and
  214. invoke ruleset randomWumpusMove and
  215. invoke ruleset checkWumpExtent.
  216.  
  217. ruleset wumpusSanity
  218. contains takeAway;
  219. select rule using first come first served ;
  220. update ruleset by removing each selected rule.
  221.  
  222. rule takeAway
  223. if wtemp_x is hero`s x_value and
  224. wtemp_y is hero`s y_value then
  225. remove_sanity.
  226.  
  227. ruleset randomWumpusMove
  228. contains wumpUp, wumpRight, wumpDown, wumpLeft;
  229. select rule using first come first served ;
  230. update ruleset by removing each selected rule.
  231.  
  232. rule wumpUp
  233. if wumpus_move is 0 and moved is no and is_s is none then
  234. wtemp_y becomes wtemp_y+1.
  235.  
  236. rule wumpRight
  237. if wumpus_move is 1 and moved is no and is_s is none then
  238. wtemp_x becomes wtemp_x+1.
  239.  
  240. rule wumpDown
  241. if wumpus_move is 2 and moved is no and is_s is none then
  242. wtemp_y becomes wtemp_y-1.
  243.  
  244. rule wumpLeft
  245. if wumpus_move is 3 and moved is no and is_s is none then
  246. wtemp_x becomes wtemp_x-1.
  247.  
  248. ruleset moveWumpusUpDate
  249. contains moveWumpusUpdateAdd, alreadyTakenW;
  250. select rule using first come first served ;
  251. update ruleset by removing each selected rule.
  252.  
  253. rule moveWumpusUpdateAdd
  254. if X is an instance of cell and
  255. X`s x_value is wtemp_x and
  256. X`s y_value is wtemp_y and
  257. X`s object_1 is empty and
  258. moved_taken is ok and
  259. is_s is none then
  260. X`s object_1 becomes wumpusLoc and
  261. moved_taken becomes ok.
  262.  
  263. rule alreadyTakenW
  264. if X is an instance of cell and
  265. X`s x_value is temp_x and
  266. X`s y_value is temp_y and
  267. moved_taken is not_ok and
  268. is_s is none then
  269. X`s object_1 becomes wumpusLoc and
  270. moved_taken becomes not_ok and
  271. wtemp_x becomes temp_x and
  272. wtemp_y becomes temp_y.
  273.  
  274.  
  275. ruleset moveWumpusRemove
  276. contains moveWumpusUpdateRemove;
  277. select rule using first come first served ;
  278. update ruleset by removing each selected rule.
  279.  
  280. rule moveWumpusUpdateRemove
  281. if X is an instance of cell and
  282. X`s x_value is wtemp_x and
  283. X`s y_value is wtemp_y and
  284. X`s object_1 is wumpusLoc then
  285. X`s object_1 becomes empty.
  286.  
  287. ruleset checkWumpExtent
  288. contains wumpExtentMove_X_above, wumpExtentMove_Y_above, wumpExtentMove_X_below, wumpExtentMove_Y_below;
  289. select rule using first come first served ;
  290. update ruleset by removing each selected rule.
  291.  
  292. rule wumpExtentMove_X_above
  293. if wtemp_x is not less than worldExtent then
  294. wtemp_x becomes worldExtent-2 and remove_wumpus becomes move.
  295.  
  296. rule wumpExtentMove_Y_above
  297. if wtemp_y is not less than worldExtent then
  298. wtemp_y becomes worldExtent-2 and remove_wumpus becomes move.
  299.  
  300. rule wumpExtentMove_X_below
  301. if wtemp_x is not greater than or equal to 0 then
  302. wtemp_x becomes 1 and remove_wumpus becomes move.
  303.  
  304. rule wumpExtentMove_Y_below
  305. if wtemp_y is not greater than or equal to 0 then
  306. wtemp_y becomes 1 and remove_wumpus becomes move.
  307.  
  308. ruleset collisionCheckw
  309. contains checkCoffeeColw, checkUnCourseworkColw, checkHealthColw, checkMissingUSBColw, checkUSBColw, checkWelliesColw, checkStairsColw;
  310. select rule using first come first served ;
  311. update ruleset by removing each selected rule.
  312.  
  313. %Collision with traps/monsters - Without item
  314.  
  315.  
  316. action remove_sanity;
  317. hero`s sanity becomes (hero`s sanity-50).
  318.  
  319. rule checkHealthColw
  320. if X is an instance of cell and
  321. X`s x_value is wtemp_x and
  322. X`s y_value is wtemp_y and
  323. X`s object_1 is healthLoc then
  324. moved_taken becomes not_ok.
  325.  
  326. rule checkCoffeeColw
  327. if X is an instance of cell and
  328. X`s x_value is wtemp_x and
  329. X`s y_value is wtemp_y and
  330. X`s object_1 is coffeeLoc then
  331. moved_taken becomes not_ok.
  332.  
  333. rule checkUnCourseworkColw
  334. if X is an instance of cell and
  335. X`s x_value is wtemp_x and
  336. X`s y_value is wtemp_y and
  337. X`s object_1 is courseworkLoc then
  338. moved_taken becomes not_ok.
  339.  
  340. rule checkMissingUSBColw
  341. if X is an instance of cell and
  342. X`s x_value is wtemp_x and
  343. X`s y_value is wtemp_y and
  344. X`s object_1 is usbLoc then
  345. moved_taken becomes not_ok.
  346. %Collision with traps/monsters - With item
  347.  
  348.  
  349. rule checkWelliesColw
  350. if X is an instance of cell and
  351. X`s x_value is wtemp_x and
  352. X`s y_value is wtemp_y and
  353. X`s object_1 is welliesLoc then
  354. moved_taken becomes not_ok.
  355.  
  356. rule checkUSBColw
  357. if X is an instance of cell and
  358. X`s x_value is wtemp_x and
  359. X`s y_value is wtemp_y and
  360. X`s object_1 is usbFoundLoc then
  361. moved_taken becomes not_ok.
  362.  
  363. rule checkStairsColw
  364. if X is an instance of cell and
  365. X`s x_value is wtemp_x and
  366. X`s y_value is wtemp_y and
  367. X`s object_1 is stairsLoc then
  368. moved_taken becomes not_ok.
  369.  
  370.  
  371. %-------------------------------------
  372. %This will place the items onto the
  373. %grid
  374.  
  375. action place_item_health;
  376. gen_random and
  377. health_pack`s x_value becomes random_number and
  378. gen_random and
  379. health_pack`s y_value becomes random_number and
  380. health_pack`s value becomes 25 and
  381. health_pack`s item_name becomes health_pack and
  382. temp_x becomes health_pack`s x_value and
  383. temp_y becomes health_pack`s y_value and
  384. current_name becomes health_pack`s item_name and
  385. updateItemHealthLocation and
  386. write('added health item').
  387.  
  388. action place_item_wellies;
  389. gen_random and
  390. rubber_wellies`s x_value becomes random_number and
  391. gen_random and
  392. rubber_wellies`s y_value becomes random_number and
  393. rubber_wellies`s value becomes 25 and
  394. rubber_wellies`s item_name becomes rubber_wellies and
  395. temp_x becomes rubber_wellies`s x_value and
  396. temp_y becomes rubber_wellies`s y_value and
  397. current_name becomes rubber_wellies`s item_name and
  398. updateItemWelliesLocation and
  399. write('added wellies item').
  400.  
  401. action place_item_lost_usb;
  402. gen_random and
  403. lost_usb`s x_value becomes random_number and
  404. gen_random and
  405. lost_usb`s y_value becomes random_number and
  406. lost_usb`s value becomes 25 and
  407. lost_usb`s item_name becomes lost_usb and
  408. temp_x becomes lost_usb`s x_value and
  409. temp_y becomes lost_usb`s y_value and
  410. current_name becomes lost_usb`s item_name and
  411. updateItemUsbLocation and
  412. write('added usb item').
  413.  
  414. action place_item_found_usb;
  415. gen_random and
  416. found_usb`s x_value becomes random_number and
  417. gen_random and
  418. found_usb`s y_value becomes random_number and
  419. found_usb`s value becomes 25 and
  420. found_usb`s item_name becomes found_usb and
  421. temp_x becomes found_usb`s x_value and
  422. temp_y becomes found_usb`s y_value and
  423. current_name becomes found_usb`s item_name and
  424. updateItemFoundUsbLocation and
  425. write('added found usb item').
  426.  
  427.  
  428. action place_coffee_spill;
  429. do for A from 1001 to 1000+(elementNum-4)
  430. do new_instance(A,trap_coffee) and
  431. gen_random and
  432. A`s x_value becomes random_number and
  433. gen_random and
  434. A`s y_value becomes random_number and
  435. A`s damage becomes 10 and
  436. A`s trapName becomes A and
  437. cof_temp_x becomes A`s x_value and
  438. cof_temp_y becomes A`s y_value and
  439. cof_name becomes A`s trapName and
  440. updateCoffeeLocation
  441. end for and
  442. write('added trap').
  443.  
  444. action place_unmarked_coursework;
  445. do for A from 5001 to 5000+(elementNum-4)
  446. do new_instance(A,trap_coursework) and
  447. gen_random and
  448. A`s x_value becomes random_number and
  449. gen_random and
  450. A`s y_value becomes random_number and
  451. A`s damage becomes 15 and
  452. A`s trapName becomes A and
  453. cw_temp_x becomes A`s x_value and
  454. cw_temp_y becomes A`s y_value and
  455. cw_name becomes A`s trapName and
  456. updateCourseworkLocation
  457. end for and
  458. write('added trap').
  459.  
  460. %--------------------------------------
  461. %This is called by the java frontend to
  462. %create the world. This only creates it
  463. %it does not populate with objects
  464.  
  465. action clearEverything;
  466. do for every X is an instance of cell
  467. do X`s object_1 becomes empty and
  468. X`s object_2 becomes empty and
  469. X`s visited becomes false and
  470. hero`s x_value becomes 0 and
  471. hero`s y_value becomes 0
  472. end for.
  473.  
  474. action createWorldLevel1;
  475. do for A from 0 to worldExtent^2 step worldExtent
  476. do for X from 0 to worldExtent-1
  477. do create_instance_name(X+A,Y) and
  478. new_instance(Y,cell) and
  479. Y`s x_value becomes X and
  480. Y`s y_value becomes A/worldExtent and
  481. Y`s visited becomes false
  482. end for
  483. end for and
  484. updateHeroLocation and
  485. cell_0`s visited becomes true and
  486. cell_0`s object_1 becomes heroLocation and
  487. cell_24`s object_1 becomes stairsLoc and
  488. addShit.
  489.  
  490.  
  491.  
  492. action createWorldLevel2;
  493. write('level 2 created') and
  494. clearEverything and
  495. invoke ruleset removeSoundsSet and
  496. updateHeroLocation and
  497. cell_0`s visited becomes true and
  498. cell_0`s object_1 becomes heroLocation and
  499. cell_24`s object_1 becomes stairsLoc and
  500. addShit and
  501. increase.
  502.  
  503. action createWorldLevel3;
  504. write('level 3 created') and
  505. clearEverything and
  506. invoke ruleset removeSoundsSet and
  507. updateHeroLocation and
  508. cell_0`s visited becomes true and
  509. cell_0`s object_1 becomes heroLocation and
  510. cell_24`s object_1 becomes stairsLoc and
  511. addShit and
  512. increase.
  513.  
  514. action addShit;
  515. place_wumpus and
  516. place_item_wellies and
  517. place_item_health and
  518. place_coffee_spill and
  519. place_unmarked_coursework and
  520. place_item_lost_usb and
  521. place_item_found_usb.
  522.  
  523. action create_instance_name(X,Y);
  524. do number_atom(X,Z) and
  525. cat({'cell_',Z},Y,L) .
  526.  
  527. action create_wumpus_name(X,Y);
  528. do number_atom(X,Z) and
  529. cat({'wumpus_',Z},Y).
  530.  
  531. %--------------------------------------
  532. %Hero Movement control here
  533.  
  534. action moveUp;
  535. hero`s next_direction becomes up and
  536. next_y_value becomes hero`s y_value - 1 and
  537. invoke ruleset moveCheck and
  538. hero`s y_value becomes next_y_value and
  539. updateHeroLocation and
  540. move_wumpus_random.
  541.  
  542. action moveDown;
  543. hero`s next_direction becomes down and
  544. next_y_value becomes hero`s y_value + 1 and
  545. invoke ruleset moveCheck and
  546. hero`s y_value becomes next_y_value and
  547. updateHeroLocation and
  548. move_wumpus_random.
  549.  
  550. action moveLeft;
  551. hero`s next_direction becomes left and
  552. next_x_value becomes hero`s x_value - 1 and
  553. invoke ruleset moveCheck and
  554. hero`s x_value becomes next_x_value and
  555. updateHeroLocation and
  556. move_wumpus_random.
  557.  
  558. action moveRight;
  559. hero`s next_direction becomes right and
  560. next_x_value becomes hero`s x_value + 1 and
  561. invoke ruleset moveCheck and
  562. hero`s x_value becomes next_x_value and
  563. updateHeroLocation and
  564. move_wumpus_random.
  565.  
  566. ruleset moveCheck
  567. contains moveUpCheck, moveDownCheck, moveLeftCheck, moveRightCheck ;
  568. select rule using first come first served ;
  569. update ruleset by removing each selected rule.
  570.  
  571. rule moveUpCheck
  572. if the next_direction of hero is up and
  573. next_y_value is -1
  574. then next_y_value becomes 0 and
  575. write('fail') and nl.
  576.  
  577. rule moveDownCheck
  578. if the next_direction of hero is down and
  579. next_y_value is equal to worldExtent
  580. then next_y_value becomes worldExtent-1 and
  581. write('fail') and nl.
  582.  
  583. rule moveLeftCheck
  584. if the next_direction of hero is left and
  585. next_x_value is equal to -1
  586. then next_x_value becomes 0 and
  587. write('fail') and nl.
  588.  
  589. rule moveRightCheck
  590. if the next_direction of hero is right and
  591. next_x_value is equal to worldExtent
  592. then next_x_value becomes worldExtent-1 and
  593. write('fail') and nl.
  594.  
  595. %--------------------------------------
  596. %Main game logic goes here
  597.  
  598. action takeHealth ;
  599. hero`s sanity becomes (hero`s sanity-damage_caused) and
  600. write(hero`s sanity).
  601.  
  602. action updateHeroLocation;
  603. write('called') and
  604. invoke ruleset updateCheck and
  605. invoke ruleset removeSoundsSet and
  606. temp_x becomes hero`s x_value and
  607. temp_y becomes hero`s y_value and
  608. temp_y becomes temp_y+1 and
  609. invoke ruleset sounds and
  610. temp_y becomes temp_y-2 and
  611. invoke ruleset sounds and
  612. temp_y becomes temp_y+1 and
  613. temp_x becomes temp_x-1 and
  614. invoke ruleset sounds and
  615. temp_x becomes temp_x+2 and
  616. invoke ruleset sounds and
  617. invoke ruleset sanityCheck.
  618.  
  619. action updateWumpusLocation;
  620. write('called') and
  621. invoke ruleset wumpusCheck.
  622.  
  623. action updateCoffeeLocation;
  624. write('called') and
  625. invoke ruleset coffeeCheck.
  626.  
  627. action updateCourseworkLocation;
  628. write('called') and
  629. invoke ruleset courseworkCheck.
  630.  
  631. action updateItemHealthLocation;
  632. write('called') and
  633. invoke ruleset itemHealthCheck.
  634.  
  635. action updateItemWelliesLocation;
  636. write('called') and
  637. invoke ruleset itemWelliesCheck.
  638.  
  639. action updateItemUsbLocation;
  640. write('called') and
  641. invoke ruleset itemUsbCheck.
  642.  
  643. action updateItemFoundUsbLocation;
  644. write('called') and
  645. invoke ruleset itemFoundUsbCheck.
  646.  
  647.  
  648.  
  649. %Can be expanded for things like object collision
  650. %monsters/items/traps etc
  651. ruleset updateCheck
  652. contains checkSanity, heroUpdateRemove, heroUpdateCollision, heroUpdateAdd;
  653. select rule using first come first served ;
  654. update ruleset by removing each selected rule.
  655.  
  656. rule heroUpdateRemove
  657. %First removes where the hero was
  658. if X is an instance of cell and
  659. X`s object_1 is heroLocation then
  660. X`s object_1 becomes empty.
  661.  
  662. rule heroUpdateCollision
  663. %If the hero moves into a square occupied by something,
  664. %logic jazz is called from this rule
  665. if X is an instance of cell and
  666. X`s x_value is hero`s x_value and
  667. X`s y_value is hero`s y_value and
  668. X`s object_1 is not empty then
  669. invoke ruleset collisionCheck.
  670.  
  671. rule checkSanity
  672. %If the hero moves into a square occupied by something,
  673. %logic jazz is called from this rule
  674. if hero`s sanity is less than or equal to 0 then
  675. write('You lost all your sanity!') and
  676. invoke ruleset dead.
  677.  
  678. ruleset sanityCheck
  679. contains sanCheck;
  680. select rule using first come first served ;
  681. update ruleset by removing each selected rule.
  682.  
  683. rule sanCheck
  684. %If the hero moves into a square occupied by something,
  685. %logic jazz is called from this rule
  686. if hero`s sanity is less than or equal to 0 then
  687. loseGame.
  688.  
  689.  
  690.  
  691.  
  692. rule heroUpdateAdd
  693. %Assuming no monster collision, moves into the empty square
  694. if X is an instance of cell and
  695. X`s x_value is hero`s x_value and
  696. X`s y_value is hero`s y_value and
  697. X`s object_1 is empty then
  698. X`s object_1 becomes heroLocation and
  699. X`s visited becomes true.
  700.  
  701. ruleset wumpusCheck
  702. contains wumpusPlace, wumpusUpdateAdd;
  703. select rule using first come first served ;
  704. update ruleset by removing each selected rule.
  705.  
  706. rule wumpusPlace
  707. if X is an instance of cell and
  708. X`s x_value is temp_x and
  709. X`s y_value is temp_y and
  710. X`s object_1 is not empty then
  711. write('Cant add wumpus here').
  712.  
  713. rule wumpusUpdateAdd
  714. if X is an instance of cell and
  715. X`s x_value is temp_x and
  716. X`s y_value is temp_y and
  717. X`s object_1 is empty then
  718. X`s object_1 becomes wumpusLoc.
  719.  
  720. ruleset coffeeCheck
  721. contains coffeePlace, coffeeUpdateAdd;
  722. select rule using first come first served ;
  723. update ruleset by removing each selected rule.
  724.  
  725. rule coffeePlace
  726. if X is an instance of cell and
  727. X`s x_value is cof_temp_x and
  728. X`s y_value is cof_temp_y and
  729. X`s object_1 is empty then
  730. write('Can trap here').
  731.  
  732. rule coffeeUpdateAdd
  733. if X is an instance of cell and
  734. X`s x_value is cof_temp_x and
  735. X`s y_value is cof_temp_y and
  736. X`s object_1 is empty then
  737. X`s object_1 becomes coffeeLoc.
  738.  
  739. ruleset courseworkCheck
  740. contains courseworkPlace, courseworkUpdateAdd;
  741. select rule using first come first served ;
  742. update ruleset by removing each selected rule.
  743.  
  744. rule courseworkPlace
  745. if X is an instance of cell and
  746. X`s x_value is cw_temp_x and
  747. X`s y_value is cw_temp_y and
  748. X`s object_1 is empty then
  749. write('Can trap here').
  750.  
  751. rule courseworkUpdateAdd
  752. if X is an instance of cell and
  753. X`s x_value is cw_temp_x and
  754. X`s y_value is cw_temp_y and
  755. X`s object_1 is empty then
  756. X`s object_1 becomes courseworkLoc.
  757.  
  758.  
  759. ruleset itemHealthCheck
  760. contains itemHealthPlace, itemHealthUpdateAdd;
  761. select rule using first come first served ;
  762. update ruleset by removing each selected rule.
  763.  
  764. rule itemHealthPlace
  765. if X is an instance of cell and
  766. X`s x_value is temp_x and
  767. X`s y_value is temp_y and
  768. X`s object_1 is empty then
  769. write('Can item here').
  770.  
  771. rule itemHealthUpdateAdd
  772. if X is an instance of cell and
  773. X`s x_value is temp_x and
  774. X`s y_value is temp_y and
  775. X`s object_1 is empty then
  776. X`s object_1 becomes healthLoc.
  777.  
  778.  
  779. ruleset itemWelliesCheck
  780. contains itemWelliesPlace, itemWelliesUpdateAdd;
  781. select rule using first come first served ;
  782. update ruleset by removing each selected rule.
  783.  
  784. rule itemWelliesPlace
  785. if X is an instance of cell and
  786. X`s x_value is temp_x and
  787. X`s y_value is temp_y and
  788. X`s object_1 is empty then
  789. write('Can item here').
  790.  
  791. rule itemWelliesUpdateAdd
  792. if X is an instance of cell and
  793. X`s x_value is temp_x and
  794. X`s y_value is temp_y and
  795. X`s object_1 is empty then
  796. X`s object_1 becomes welliesLoc.
  797.  
  798.  
  799. ruleset itemUsbCheck
  800. contains itemUsbPlace, itemUsbUpdateAdd;
  801. select rule using first come first served ;
  802. update ruleset by removing each selected rule.
  803.  
  804. rule itemUsbPlace
  805. if X is an instance of cell and
  806. X`s x_value is temp_x and
  807. X`s y_value is temp_y and
  808. X`s object_1 is empty then
  809. write('Can item here').
  810.  
  811. rule itemUsbUpdateAdd
  812. if X is an instance of cell and
  813. X`s x_value is temp_x and
  814. X`s y_value is temp_y and
  815. X`s object_1 is empty then
  816. X`s object_1 becomes usbLoc.
  817.  
  818. ruleset itemFoundUsbCheck
  819. contains itemFoundUsbPlace, itemFoundUsbUpdateAdd;
  820. select rule using first come first served ;
  821. update ruleset by removing each selected rule.
  822.  
  823. rule itemFoundUsbPlace
  824. if X is an instance of cell and
  825. X`s x_value is temp_x and
  826. X`s y_value is temp_y and
  827. X`s object_1 is empty then
  828. write('Can item here').
  829.  
  830. rule itemFoundUsbUpdateAdd
  831. if X is an instance of cell and
  832. X`s x_value is temp_x and
  833. X`s y_value is temp_y and
  834. X`s object_1 is empty then
  835. X`s object_1 becomes usbFoundLoc.
  836.  
  837.  
  838. %--------------------------------------
  839. %Wumpus Movement control here
  840.  
  841.  
  842.  
  843. ruleset sounds
  844. contains addSounds;
  845. select rule using first come first served ;
  846. update ruleset by removing each selected rule.
  847.  
  848. rule addSounds
  849. if X is an instance of cell and
  850. X`s x_value is temp_x and
  851. X`s y_value is temp_y then
  852. X`s object_2 becomes soundLoc and
  853. X`s visited becomes true.
  854.  
  855. ruleset removeSoundsSet
  856. contains removeSoundOne, removeSoundTwo, removeSoundThree, removeSoundFour;
  857. select rule using first come first served ;
  858. update ruleset by removing each selected rule.
  859.  
  860. rule removeSoundOne
  861. if X is an instance of cell then
  862. X`s object_2 becomes empty.
  863.  
  864. rule removeSoundTwo
  865. if X is an instance of cell then
  866. X`s object_2 becomes empty.
  867.  
  868. rule removeSoundThree
  869. if X is an instance of cell then
  870. X`s object_2 becomes empty.
  871.  
  872. rule removeSoundFour
  873. if X is an instance of cell then
  874. X`s object_2 becomes empty.
  875.  
  876.  
  877. ruleset numberRounding
  878. contains roundZero, roundOne, roundTwo, roundThree, roundFour;
  879. select rule using first come first served ;
  880. update ruleset by removing each selected rule.
  881.  
  882. rule roundZero
  883. if random_number is greater than 0 and
  884. random_number is less than 1 then
  885. random_number becomes 0.
  886.  
  887. rule roundOne
  888. if random_number is greater than 1 and
  889. random_number is less than 2 then
  890. random_number becomes 1.
  891.  
  892. rule roundTwo
  893. if random_number is greater than 2 and
  894. random_number is less than 3 then
  895. random_number becomes 2.
  896.  
  897. rule roundThree
  898. if random_number is greater than 3 and
  899. random_number is less than 4 then
  900. random_number becomes 3.
  901.  
  902. rule roundFour
  903. if random_number is greater than 4 and
  904. random_number is less than 5 then
  905. random_number becomes 4.
  906.  
  907. ruleset numberRoundingTwo
  908. contains roundZeroTwo, roundOneTwo, roundTwoTwo, roundThreeTwo;
  909. select rule using first come first served ;
  910. update ruleset by removing each selected rule.
  911.  
  912. rule roundZeroTwo
  913. if random_num_two is greater than 0 and
  914. random_num_two is less than 1 then
  915. random_num_two becomes 0.
  916.  
  917. rule roundOneTwo
  918. if random_num_two is greater than 1 and
  919. random_num_two is less than 2 then
  920. random_num_two becomes 1.
  921.  
  922. rule roundTwoTwo
  923. if random_num_two is greater than 2 and
  924. random_num_two is less than 3 then
  925. random_num_two becomes 2.
  926.  
  927. rule roundThreeTwo
  928. if random_num_two is greater than 3 and
  929. random_num_two is less than 4 then
  930. random_num_two becomes 3.
  931.  
  932. %Collision rules
  933. ruleset collisionCheck
  934. contains checkWumpusCol, checkHealthCol, checkCoffeeCol, checkUnCourseworkCol, checkMissingUSBCol, checkMissingUSBWithItemCol, checkCoffeeWithItemCol, checkUSBCol, checkWelliesCol, checkStairsToTwoCol, checkStairsToThreeCol, checkStairsToEnd, checkSanityLevel;
  935. select rule using first come first served ;
  936. update ruleset by removing each selected rule.
  937.  
  938. %Collision with traps/monsters - Without item
  939. rule checkWumpusCol
  940. if X is an instance of cell and
  941. X`s x_value is hero`s x_value and
  942. X`s y_value is hero`s y_value and
  943. X`s object_1 is wumpusLoc then
  944. hero`s sanity becomes (hero`s sanity - 50) and
  945. X`s object_1 becomes heroLocation.
  946.  
  947. rule checkCoffeeCol
  948. if X is an instance of cell and
  949. X`s x_value is hero`s x_value and
  950. X`s y_value is hero`s y_value and
  951. hero`s held_item_0 is empty and
  952. X`s object_1 is coffeeLoc then
  953. hero`s sanity becomes (hero`s sanity-25) and
  954. X`s object_1 becomes heroLocation.
  955.  
  956. rule checkUnCourseworkCol
  957. if X is an instance of cell and
  958. X`s x_value is hero`s x_value and
  959. X`s y_value is hero`s y_value and
  960. X`s object_1 is courseworkLoc then
  961. hero`s sanity becomes (hero`s sanity-25) and
  962. X`s object_1 becomes heroLocation.
  963.  
  964. rule checkMissingUSBCol
  965. if X is an instance of cell and
  966. X`s x_value is hero`s x_value and
  967. X`s y_value is hero`s y_value and
  968. hero`s held_item_1 is empty and
  969. X`s object_1 is usbLoc then
  970. hero`s sanity becomes (hero`s sanity-30) and
  971. X`s object_1 becomes heroLocation.
  972. %Collision with traps/monsters - With item
  973. rule checkCoffeeWithItemCol
  974. if X is an instance of cell and
  975. X`s x_value is hero`s x_value and
  976. X`s y_value is hero`s y_value and
  977. hero`s held_item_0 is welliesLoc and
  978. X`s object_1 is coffeeLoc then
  979. X`s object_1 becomes heroLocation and
  980. hero`s held_item_0 becomes empty.
  981.  
  982. rule checkMissingUSBWithItemCol
  983. if X is an instance of cell and
  984. X`s x_value is hero`s x_value and
  985. X`s y_value is hero`s y_value and
  986. hero`s held_item_1 is usbFoundLoc and
  987. X`s object_1 is usbLoc then
  988. X`s object_1 becomes heroLocation and
  989. hero`s held_item_1 becomes empty.
  990.  
  991. %Collision with items
  992. rule checkHealthCol
  993. if X is an instance of cell and
  994. X`s x_value is hero`s x_value and
  995. X`s y_value is hero`s y_value and
  996. X`s object_1 is healthLoc then
  997. hero`s sanity becomes 100 and
  998. X`s object_1 becomes heroLocation.
  999.  
  1000. rule checkWelliesCol
  1001. if X is an instance of cell and
  1002. X`s object_1 is welliesLoc and
  1003. X`s x_value is hero`s x_value and
  1004. X`s y_value is hero`s y_value then
  1005. hero`s held_item_0 becomes welliesLoc and
  1006. X`s object_1 becomes heroLocation.
  1007.  
  1008. rule checkUSBCol
  1009. if X is an instance of cell and
  1010. X`s object_1 is usbFoundLoc and
  1011. X`s x_value is hero`s x_value and
  1012. X`s y_value is hero`s y_value then
  1013. hero`s held_item_1 becomes usbFoundLoc and
  1014. X`s object_1 becomes heroLocation.
  1015.  
  1016. %Collision with stairs
  1017. rule checkStairsToTwoCol
  1018. if X is an instance of cell and
  1019. X`s object_1 is stairsLoc and
  1020. X`s x_value is hero`s x_value and
  1021. elementNum is equal to 5 and
  1022. X`s y_value is hero`s y_value then
  1023. createWorldLevel2.
  1024.  
  1025. action increase;
  1026. elementNum becomes elementNum+1.
  1027.  
  1028. rule checkStairsToThreeCol
  1029. if X is an instance of cell and
  1030. X`s object_1 is stairsLoc and
  1031. X`s x_value is hero`s x_value and
  1032. elementNum is equal to 6 and
  1033. X`s y_value is hero`s y_value then
  1034. createWorldLevel3.
  1035.  
  1036. rule checkStairsToEnd
  1037. if X is an instance of cell and
  1038. X`s object_1 is stairsLoc and
  1039. X`s x_value is hero`s x_value and
  1040. elementNum is equal to 7 and
  1041. X`s y_value is hero`s y_value then
  1042. winGame.
  1043.  
  1044.  
  1045.  
  1046. ruleset checkDeath
  1047. contains checkSanityLevel;
  1048. select rule using first come first served ;
  1049. update ruleset by removing each selected rule.
  1050.  
  1051.  
  1052. rule checkSanityLevel
  1053. if hero`s sanity is less than or equal to 0 then
  1054. echo('DEATH') and
  1055. loseGame.
  1056.  
  1057. action winGame;
  1058. do for every X is an instance of cell
  1059. do X`s object_1 becomes winLoc and
  1060. X`s visited becomes true and
  1061. hero`s x_value becomes none and
  1062. hero`s y_value becomes none
  1063. end for.
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069. action loseGame;
  1070. do for every X is an instance of cell
  1071. do X`s object_1 becomes deadLoc and
  1072. X`s visited becomes true and
  1073. hero`s x_value becomes none and
  1074. hero`s y_value becomes none
  1075. end for.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement