Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %--------------------------------------
- %Frames go here
- frame global ;
- default worldExtent is 5 and
- default current_name is none and
- default temp_x is 0 and
- default temp_y is 0 and
- default wtemp_x is none and
- default wtemp_y is none and
- default cof_temp_x is 0 and
- default cof_temp_y is 0 and
- default cof_name is none and
- default cw_temp_x is 0 and
- default cw_temp_y is 0 and
- default cw_name is none and
- default rm_x is 0 and
- default rm_x is 0 and
- default rm_next is none and
- default damage_caused is 15 and
- default wumpus_move is none and
- default moved is no and
- default drainSanity is none and
- default soundDirection is none and
- default is_s is none and
- default random_number is 0 and
- default random_num_two is 0 and
- default elementNum is 5 and
- default elementNumTwo is 6 and
- default remove_wumpus is none and
- default old_temp_x is 0 and
- default old_temp_y is 0 and
- default moved_taken is ok.
- action yea;
- echo (elementNum).
- frame cell ;
- default x_value is 0 and
- default y_value is 0 and
- default id is empty and
- default visited is false and
- default object_1 is empty and
- default object_2 is empty and
- default object_3 is empty.
- frame actor ;
- default x_value is 0 and
- default y_value is 0 and
- default sanity is 100.
- frame wumpus ;
- default x_value is 0 and
- default y_value is 0 and
- default status is dead and
- default wumpusName is none.
- frame trap_coffee ;
- default x_value is 0 and
- default y_value is 0 and
- default trapName is none.
- frame trap_coursework ;
- default x_value is 0 and
- default y_value is 0 and
- default trapName is none.
- frame item;
- default x_value is 0 and
- default y_value is 0 and
- default item_name is none and
- default value is 0.
- %--------------------------------------
- %Instances of frames go here
- instance hero is an actor ;
- x_value is 0 and
- y_value is 0 and
- next_x_value is 0 and
- next_y_value is 0 and
- next_direction is 0 and
- sanity is 100 and
- held_item_0 is empty and
- held_item_1 is empty and
- held_item_2 is empty and
- held_item_3 is empty and
- held_item_4 is empty and
- held_item_5 is empty.
- instance stairs is an item;
- x_value is 0 and
- y_value is 0 and
- item_name is none and
- value is 0.
- instance marked_coursework is an item;
- x_value is 0 and
- y_value is 0 and
- item_name is none and
- value is 0.
- instance health_pack is an item;
- x_value is 0 and
- y_value is 0 and
- item_name is none and
- value is 0.
- instance rubber_wellies is an item;
- x_value is 0 and
- y_value is 0 and
- item_name is none and
- value is 0.
- instance lost_usb is an item;
- x_value is 0 and
- y_value is 0 and
- item_name is none and
- value is 0.
- instance found_usb is an item;
- x_value is 0 and
- y_value is 0 and
- item_name is none and
- value is 0.
- action gen_random;
- is(X, rand(5)) and
- random_number becomes X and
- invoke ruleset numberRounding.
- action gen_random_two;
- is(X, rand(4)) and
- random_num_two becomes X and
- invoke ruleset numberRoundingTwo and
- echo(random_num_two).
- %--------------------------------------
- %This is called by the java frontend to
- %get up to date world info
- action updateInfo ;
- do for every S is an instance of cell
- do write( S`s x_value ) and
- do write( ';' ) and
- do write( S`s y_value ) and
- do write( ';' ) and
- do write( S`s id ) and
- do write( ';' ) and
- do write( S`s visited ) and
- do write( ';' ) and
- do write( S`s object_1 ) and
- do write( ';' ) and
- do write( S`s object_2 ) and
- do write( ';' ) and
- do write( S`s object_3 ) and
- do write( '&' )
- end for.
- action updateStatus ;
- write( hero`s sanity ) and
- write( ';' ) and
- write( hero`s held_item_0 ) and
- write( ';' ) and
- write( hero`s held_item_1 ) and
- write( ';' ) and
- write( hero`s held_item_2 ) and
- write( ';' ) and
- write( hero`s held_item_3 ) and
- write( ';' ) and
- write( hero`s held_item_4 ) and
- write( ';' ) and
- write( hero`s held_item_5 ) .
- %--------------------------------------
- %This will generate a random wumpus onto
- %the grid.
- action place_wumpus;
- do for A from 1 to elementNum-4
- do new_instance(A,wumpus) and
- gen_random and
- A`s x_value becomes random_number and
- gen_random and
- A`s y_value becomes random_number and
- A`s wumpusName becomes wumpusLoc and
- temp_x becomes A`s x_value and
- temp_y becomes A`s y_value and
- current_name becomes A`s wumpusName and
- updateWumpusLocation
- end for and
- write('added wumpus').
- action move_wumpus_random;
- do for every X is some instance of wumpus
- do
- wtemp_x becomes X`s x_value and
- wtemp_y becomes X`s y_value and
- temp_x becomes wtemp_x and
- temp_y becomes wtemp_y and
- invoke ruleset moveWumpusRemove and
- randomWumpusLocation and
- invoke ruleset collisionCheckw and
- invoke ruleset moveWumpusUpDate and
- X`s x_value becomes wtemp_x and
- X`s y_value becomes wtemp_y and
- moved_taken becomes ok and
- invoke ruleset wumpusSanity
- end for.
- action randomWumpusLocation;
- write('called') and
- gen_random_two and
- wumpus_move becomes random_num_two and
- invoke ruleset randomWumpusMove and
- invoke ruleset checkWumpExtent.
- ruleset wumpusSanity
- contains takeAway;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule takeAway
- if wtemp_x is hero`s x_value and
- wtemp_y is hero`s y_value then
- remove_sanity.
- ruleset randomWumpusMove
- contains wumpUp, wumpRight, wumpDown, wumpLeft;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule wumpUp
- if wumpus_move is 0 and moved is no and is_s is none then
- wtemp_y becomes wtemp_y+1.
- rule wumpRight
- if wumpus_move is 1 and moved is no and is_s is none then
- wtemp_x becomes wtemp_x+1.
- rule wumpDown
- if wumpus_move is 2 and moved is no and is_s is none then
- wtemp_y becomes wtemp_y-1.
- rule wumpLeft
- if wumpus_move is 3 and moved is no and is_s is none then
- wtemp_x becomes wtemp_x-1.
- ruleset moveWumpusUpDate
- contains moveWumpusUpdateAdd, alreadyTakenW;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule moveWumpusUpdateAdd
- if X is an instance of cell and
- X`s x_value is wtemp_x and
- X`s y_value is wtemp_y and
- X`s object_1 is empty and
- moved_taken is ok and
- is_s is none then
- X`s object_1 becomes wumpusLoc and
- moved_taken becomes ok.
- rule alreadyTakenW
- if X is an instance of cell and
- X`s x_value is temp_x and
- X`s y_value is temp_y and
- moved_taken is not_ok and
- is_s is none then
- X`s object_1 becomes wumpusLoc and
- moved_taken becomes not_ok and
- wtemp_x becomes temp_x and
- wtemp_y becomes temp_y.
- ruleset moveWumpusRemove
- contains moveWumpusUpdateRemove;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule moveWumpusUpdateRemove
- if X is an instance of cell and
- X`s x_value is wtemp_x and
- X`s y_value is wtemp_y and
- X`s object_1 is wumpusLoc then
- X`s object_1 becomes empty.
- ruleset checkWumpExtent
- contains wumpExtentMove_X_above, wumpExtentMove_Y_above, wumpExtentMove_X_below, wumpExtentMove_Y_below;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule wumpExtentMove_X_above
- if wtemp_x is not less than worldExtent then
- wtemp_x becomes worldExtent-2 and remove_wumpus becomes move.
- rule wumpExtentMove_Y_above
- if wtemp_y is not less than worldExtent then
- wtemp_y becomes worldExtent-2 and remove_wumpus becomes move.
- rule wumpExtentMove_X_below
- if wtemp_x is not greater than or equal to 0 then
- wtemp_x becomes 1 and remove_wumpus becomes move.
- rule wumpExtentMove_Y_below
- if wtemp_y is not greater than or equal to 0 then
- wtemp_y becomes 1 and remove_wumpus becomes move.
- ruleset collisionCheckw
- contains checkCoffeeColw, checkUnCourseworkColw, checkHealthColw, checkMissingUSBColw, checkUSBColw, checkWelliesColw, checkStairsColw;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- %Collision with traps/monsters - Without item
- action remove_sanity;
- hero`s sanity becomes (hero`s sanity-50).
- rule checkHealthColw
- if X is an instance of cell and
- X`s x_value is wtemp_x and
- X`s y_value is wtemp_y and
- X`s object_1 is healthLoc then
- moved_taken becomes not_ok.
- rule checkCoffeeColw
- if X is an instance of cell and
- X`s x_value is wtemp_x and
- X`s y_value is wtemp_y and
- X`s object_1 is coffeeLoc then
- moved_taken becomes not_ok.
- rule checkUnCourseworkColw
- if X is an instance of cell and
- X`s x_value is wtemp_x and
- X`s y_value is wtemp_y and
- X`s object_1 is courseworkLoc then
- moved_taken becomes not_ok.
- rule checkMissingUSBColw
- if X is an instance of cell and
- X`s x_value is wtemp_x and
- X`s y_value is wtemp_y and
- X`s object_1 is usbLoc then
- moved_taken becomes not_ok.
- %Collision with traps/monsters - With item
- rule checkWelliesColw
- if X is an instance of cell and
- X`s x_value is wtemp_x and
- X`s y_value is wtemp_y and
- X`s object_1 is welliesLoc then
- moved_taken becomes not_ok.
- rule checkUSBColw
- if X is an instance of cell and
- X`s x_value is wtemp_x and
- X`s y_value is wtemp_y and
- X`s object_1 is usbFoundLoc then
- moved_taken becomes not_ok.
- rule checkStairsColw
- if X is an instance of cell and
- X`s x_value is wtemp_x and
- X`s y_value is wtemp_y and
- X`s object_1 is stairsLoc then
- moved_taken becomes not_ok.
- %-------------------------------------
- %This will place the items onto the
- %grid
- action place_item_health;
- gen_random and
- health_pack`s x_value becomes random_number and
- gen_random and
- health_pack`s y_value becomes random_number and
- health_pack`s value becomes 25 and
- health_pack`s item_name becomes health_pack and
- temp_x becomes health_pack`s x_value and
- temp_y becomes health_pack`s y_value and
- current_name becomes health_pack`s item_name and
- updateItemHealthLocation and
- write('added health item').
- action place_item_wellies;
- gen_random and
- rubber_wellies`s x_value becomes random_number and
- gen_random and
- rubber_wellies`s y_value becomes random_number and
- rubber_wellies`s value becomes 25 and
- rubber_wellies`s item_name becomes rubber_wellies and
- temp_x becomes rubber_wellies`s x_value and
- temp_y becomes rubber_wellies`s y_value and
- current_name becomes rubber_wellies`s item_name and
- updateItemWelliesLocation and
- write('added wellies item').
- action place_item_lost_usb;
- gen_random and
- lost_usb`s x_value becomes random_number and
- gen_random and
- lost_usb`s y_value becomes random_number and
- lost_usb`s value becomes 25 and
- lost_usb`s item_name becomes lost_usb and
- temp_x becomes lost_usb`s x_value and
- temp_y becomes lost_usb`s y_value and
- current_name becomes lost_usb`s item_name and
- updateItemUsbLocation and
- write('added usb item').
- action place_item_found_usb;
- gen_random and
- found_usb`s x_value becomes random_number and
- gen_random and
- found_usb`s y_value becomes random_number and
- found_usb`s value becomes 25 and
- found_usb`s item_name becomes found_usb and
- temp_x becomes found_usb`s x_value and
- temp_y becomes found_usb`s y_value and
- current_name becomes found_usb`s item_name and
- updateItemFoundUsbLocation and
- write('added found usb item').
- action place_coffee_spill;
- do for A from 1001 to 1000+(elementNum-4)
- do new_instance(A,trap_coffee) and
- gen_random and
- A`s x_value becomes random_number and
- gen_random and
- A`s y_value becomes random_number and
- A`s damage becomes 10 and
- A`s trapName becomes A and
- cof_temp_x becomes A`s x_value and
- cof_temp_y becomes A`s y_value and
- cof_name becomes A`s trapName and
- updateCoffeeLocation
- end for and
- write('added trap').
- action place_unmarked_coursework;
- do for A from 5001 to 5000+(elementNum-4)
- do new_instance(A,trap_coursework) and
- gen_random and
- A`s x_value becomes random_number and
- gen_random and
- A`s y_value becomes random_number and
- A`s damage becomes 15 and
- A`s trapName becomes A and
- cw_temp_x becomes A`s x_value and
- cw_temp_y becomes A`s y_value and
- cw_name becomes A`s trapName and
- updateCourseworkLocation
- end for and
- write('added trap').
- %--------------------------------------
- %This is called by the java frontend to
- %create the world. This only creates it
- %it does not populate with objects
- action clearEverything;
- do for every X is an instance of cell
- do X`s object_1 becomes empty and
- X`s object_2 becomes empty and
- X`s visited becomes false and
- hero`s x_value becomes 0 and
- hero`s y_value becomes 0
- end for.
- action createWorldLevel1;
- do for A from 0 to worldExtent^2 step worldExtent
- do for X from 0 to worldExtent-1
- do create_instance_name(X+A,Y) and
- new_instance(Y,cell) and
- Y`s x_value becomes X and
- Y`s y_value becomes A/worldExtent and
- Y`s visited becomes false
- end for
- end for and
- updateHeroLocation and
- cell_0`s visited becomes true and
- cell_0`s object_1 becomes heroLocation and
- cell_24`s object_1 becomes stairsLoc and
- addShit.
- action createWorldLevel2;
- write('level 2 created') and
- clearEverything and
- invoke ruleset removeSoundsSet and
- updateHeroLocation and
- cell_0`s visited becomes true and
- cell_0`s object_1 becomes heroLocation and
- cell_24`s object_1 becomes stairsLoc and
- addShit and
- increase.
- action createWorldLevel3;
- write('level 3 created') and
- clearEverything and
- invoke ruleset removeSoundsSet and
- updateHeroLocation and
- cell_0`s visited becomes true and
- cell_0`s object_1 becomes heroLocation and
- cell_24`s object_1 becomes stairsLoc and
- addShit and
- increase.
- action addShit;
- place_wumpus and
- place_item_wellies and
- place_item_health and
- place_coffee_spill and
- place_unmarked_coursework and
- place_item_lost_usb and
- place_item_found_usb.
- action create_instance_name(X,Y);
- do number_atom(X,Z) and
- cat({'cell_',Z},Y,L) .
- action create_wumpus_name(X,Y);
- do number_atom(X,Z) and
- cat({'wumpus_',Z},Y).
- %--------------------------------------
- %Hero Movement control here
- action moveUp;
- hero`s next_direction becomes up and
- next_y_value becomes hero`s y_value - 1 and
- invoke ruleset moveCheck and
- hero`s y_value becomes next_y_value and
- updateHeroLocation and
- move_wumpus_random.
- action moveDown;
- hero`s next_direction becomes down and
- next_y_value becomes hero`s y_value + 1 and
- invoke ruleset moveCheck and
- hero`s y_value becomes next_y_value and
- updateHeroLocation and
- move_wumpus_random.
- action moveLeft;
- hero`s next_direction becomes left and
- next_x_value becomes hero`s x_value - 1 and
- invoke ruleset moveCheck and
- hero`s x_value becomes next_x_value and
- updateHeroLocation and
- move_wumpus_random.
- action moveRight;
- hero`s next_direction becomes right and
- next_x_value becomes hero`s x_value + 1 and
- invoke ruleset moveCheck and
- hero`s x_value becomes next_x_value and
- updateHeroLocation and
- move_wumpus_random.
- ruleset moveCheck
- contains moveUpCheck, moveDownCheck, moveLeftCheck, moveRightCheck ;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule moveUpCheck
- if the next_direction of hero is up and
- next_y_value is -1
- then next_y_value becomes 0 and
- write('fail') and nl.
- rule moveDownCheck
- if the next_direction of hero is down and
- next_y_value is equal to worldExtent
- then next_y_value becomes worldExtent-1 and
- write('fail') and nl.
- rule moveLeftCheck
- if the next_direction of hero is left and
- next_x_value is equal to -1
- then next_x_value becomes 0 and
- write('fail') and nl.
- rule moveRightCheck
- if the next_direction of hero is right and
- next_x_value is equal to worldExtent
- then next_x_value becomes worldExtent-1 and
- write('fail') and nl.
- %--------------------------------------
- %Main game logic goes here
- action takeHealth ;
- hero`s sanity becomes (hero`s sanity-damage_caused) and
- write(hero`s sanity).
- action updateHeroLocation;
- write('called') and
- invoke ruleset updateCheck and
- invoke ruleset removeSoundsSet and
- temp_x becomes hero`s x_value and
- temp_y becomes hero`s y_value and
- temp_y becomes temp_y+1 and
- invoke ruleset sounds and
- temp_y becomes temp_y-2 and
- invoke ruleset sounds and
- temp_y becomes temp_y+1 and
- temp_x becomes temp_x-1 and
- invoke ruleset sounds and
- temp_x becomes temp_x+2 and
- invoke ruleset sounds and
- invoke ruleset sanityCheck.
- action updateWumpusLocation;
- write('called') and
- invoke ruleset wumpusCheck.
- action updateCoffeeLocation;
- write('called') and
- invoke ruleset coffeeCheck.
- action updateCourseworkLocation;
- write('called') and
- invoke ruleset courseworkCheck.
- action updateItemHealthLocation;
- write('called') and
- invoke ruleset itemHealthCheck.
- action updateItemWelliesLocation;
- write('called') and
- invoke ruleset itemWelliesCheck.
- action updateItemUsbLocation;
- write('called') and
- invoke ruleset itemUsbCheck.
- action updateItemFoundUsbLocation;
- write('called') and
- invoke ruleset itemFoundUsbCheck.
- %Can be expanded for things like object collision
- %monsters/items/traps etc
- ruleset updateCheck
- contains checkSanity, heroUpdateRemove, heroUpdateCollision, heroUpdateAdd;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule heroUpdateRemove
- %First removes where the hero was
- if X is an instance of cell and
- X`s object_1 is heroLocation then
- X`s object_1 becomes empty.
- rule heroUpdateCollision
- %If the hero moves into a square occupied by something,
- %logic jazz is called from this rule
- if X is an instance of cell and
- X`s x_value is hero`s x_value and
- X`s y_value is hero`s y_value and
- X`s object_1 is not empty then
- invoke ruleset collisionCheck.
- rule checkSanity
- %If the hero moves into a square occupied by something,
- %logic jazz is called from this rule
- if hero`s sanity is less than or equal to 0 then
- write('You lost all your sanity!') and
- invoke ruleset dead.
- ruleset sanityCheck
- contains sanCheck;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule sanCheck
- %If the hero moves into a square occupied by something,
- %logic jazz is called from this rule
- if hero`s sanity is less than or equal to 0 then
- loseGame.
- rule heroUpdateAdd
- %Assuming no monster collision, moves into the empty square
- if X is an instance of cell and
- X`s x_value is hero`s x_value and
- X`s y_value is hero`s y_value and
- X`s object_1 is empty then
- X`s object_1 becomes heroLocation and
- X`s visited becomes true.
- ruleset wumpusCheck
- contains wumpusPlace, wumpusUpdateAdd;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule wumpusPlace
- if X is an instance of cell and
- X`s x_value is temp_x and
- X`s y_value is temp_y and
- X`s object_1 is not empty then
- write('Cant add wumpus here').
- rule wumpusUpdateAdd
- if X is an instance of cell and
- X`s x_value is temp_x and
- X`s y_value is temp_y and
- X`s object_1 is empty then
- X`s object_1 becomes wumpusLoc.
- ruleset coffeeCheck
- contains coffeePlace, coffeeUpdateAdd;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule coffeePlace
- if X is an instance of cell and
- X`s x_value is cof_temp_x and
- X`s y_value is cof_temp_y and
- X`s object_1 is empty then
- write('Can trap here').
- rule coffeeUpdateAdd
- if X is an instance of cell and
- X`s x_value is cof_temp_x and
- X`s y_value is cof_temp_y and
- X`s object_1 is empty then
- X`s object_1 becomes coffeeLoc.
- ruleset courseworkCheck
- contains courseworkPlace, courseworkUpdateAdd;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule courseworkPlace
- if X is an instance of cell and
- X`s x_value is cw_temp_x and
- X`s y_value is cw_temp_y and
- X`s object_1 is empty then
- write('Can trap here').
- rule courseworkUpdateAdd
- if X is an instance of cell and
- X`s x_value is cw_temp_x and
- X`s y_value is cw_temp_y and
- X`s object_1 is empty then
- X`s object_1 becomes courseworkLoc.
- ruleset itemHealthCheck
- contains itemHealthPlace, itemHealthUpdateAdd;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule itemHealthPlace
- if X is an instance of cell and
- X`s x_value is temp_x and
- X`s y_value is temp_y and
- X`s object_1 is empty then
- write('Can item here').
- rule itemHealthUpdateAdd
- if X is an instance of cell and
- X`s x_value is temp_x and
- X`s y_value is temp_y and
- X`s object_1 is empty then
- X`s object_1 becomes healthLoc.
- ruleset itemWelliesCheck
- contains itemWelliesPlace, itemWelliesUpdateAdd;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule itemWelliesPlace
- if X is an instance of cell and
- X`s x_value is temp_x and
- X`s y_value is temp_y and
- X`s object_1 is empty then
- write('Can item here').
- rule itemWelliesUpdateAdd
- if X is an instance of cell and
- X`s x_value is temp_x and
- X`s y_value is temp_y and
- X`s object_1 is empty then
- X`s object_1 becomes welliesLoc.
- ruleset itemUsbCheck
- contains itemUsbPlace, itemUsbUpdateAdd;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule itemUsbPlace
- if X is an instance of cell and
- X`s x_value is temp_x and
- X`s y_value is temp_y and
- X`s object_1 is empty then
- write('Can item here').
- rule itemUsbUpdateAdd
- if X is an instance of cell and
- X`s x_value is temp_x and
- X`s y_value is temp_y and
- X`s object_1 is empty then
- X`s object_1 becomes usbLoc.
- ruleset itemFoundUsbCheck
- contains itemFoundUsbPlace, itemFoundUsbUpdateAdd;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule itemFoundUsbPlace
- if X is an instance of cell and
- X`s x_value is temp_x and
- X`s y_value is temp_y and
- X`s object_1 is empty then
- write('Can item here').
- rule itemFoundUsbUpdateAdd
- if X is an instance of cell and
- X`s x_value is temp_x and
- X`s y_value is temp_y and
- X`s object_1 is empty then
- X`s object_1 becomes usbFoundLoc.
- %--------------------------------------
- %Wumpus Movement control here
- ruleset sounds
- contains addSounds;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule addSounds
- if X is an instance of cell and
- X`s x_value is temp_x and
- X`s y_value is temp_y then
- X`s object_2 becomes soundLoc and
- X`s visited becomes true.
- ruleset removeSoundsSet
- contains removeSoundOne, removeSoundTwo, removeSoundThree, removeSoundFour;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule removeSoundOne
- if X is an instance of cell then
- X`s object_2 becomes empty.
- rule removeSoundTwo
- if X is an instance of cell then
- X`s object_2 becomes empty.
- rule removeSoundThree
- if X is an instance of cell then
- X`s object_2 becomes empty.
- rule removeSoundFour
- if X is an instance of cell then
- X`s object_2 becomes empty.
- ruleset numberRounding
- contains roundZero, roundOne, roundTwo, roundThree, roundFour;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule roundZero
- if random_number is greater than 0 and
- random_number is less than 1 then
- random_number becomes 0.
- rule roundOne
- if random_number is greater than 1 and
- random_number is less than 2 then
- random_number becomes 1.
- rule roundTwo
- if random_number is greater than 2 and
- random_number is less than 3 then
- random_number becomes 2.
- rule roundThree
- if random_number is greater than 3 and
- random_number is less than 4 then
- random_number becomes 3.
- rule roundFour
- if random_number is greater than 4 and
- random_number is less than 5 then
- random_number becomes 4.
- ruleset numberRoundingTwo
- contains roundZeroTwo, roundOneTwo, roundTwoTwo, roundThreeTwo;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule roundZeroTwo
- if random_num_two is greater than 0 and
- random_num_two is less than 1 then
- random_num_two becomes 0.
- rule roundOneTwo
- if random_num_two is greater than 1 and
- random_num_two is less than 2 then
- random_num_two becomes 1.
- rule roundTwoTwo
- if random_num_two is greater than 2 and
- random_num_two is less than 3 then
- random_num_two becomes 2.
- rule roundThreeTwo
- if random_num_two is greater than 3 and
- random_num_two is less than 4 then
- random_num_two becomes 3.
- %Collision rules
- ruleset collisionCheck
- contains checkWumpusCol, checkHealthCol, checkCoffeeCol, checkUnCourseworkCol, checkMissingUSBCol, checkMissingUSBWithItemCol, checkCoffeeWithItemCol, checkUSBCol, checkWelliesCol, checkStairsToTwoCol, checkStairsToThreeCol, checkStairsToEnd, checkSanityLevel;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- %Collision with traps/monsters - Without item
- rule checkWumpusCol
- if X is an instance of cell and
- X`s x_value is hero`s x_value and
- X`s y_value is hero`s y_value and
- X`s object_1 is wumpusLoc then
- hero`s sanity becomes (hero`s sanity - 50) and
- X`s object_1 becomes heroLocation.
- rule checkCoffeeCol
- if X is an instance of cell and
- X`s x_value is hero`s x_value and
- X`s y_value is hero`s y_value and
- hero`s held_item_0 is empty and
- X`s object_1 is coffeeLoc then
- hero`s sanity becomes (hero`s sanity-25) and
- X`s object_1 becomes heroLocation.
- rule checkUnCourseworkCol
- if X is an instance of cell and
- X`s x_value is hero`s x_value and
- X`s y_value is hero`s y_value and
- X`s object_1 is courseworkLoc then
- hero`s sanity becomes (hero`s sanity-25) and
- X`s object_1 becomes heroLocation.
- rule checkMissingUSBCol
- if X is an instance of cell and
- X`s x_value is hero`s x_value and
- X`s y_value is hero`s y_value and
- hero`s held_item_1 is empty and
- X`s object_1 is usbLoc then
- hero`s sanity becomes (hero`s sanity-30) and
- X`s object_1 becomes heroLocation.
- %Collision with traps/monsters - With item
- rule checkCoffeeWithItemCol
- if X is an instance of cell and
- X`s x_value is hero`s x_value and
- X`s y_value is hero`s y_value and
- hero`s held_item_0 is welliesLoc and
- X`s object_1 is coffeeLoc then
- X`s object_1 becomes heroLocation and
- hero`s held_item_0 becomes empty.
- rule checkMissingUSBWithItemCol
- if X is an instance of cell and
- X`s x_value is hero`s x_value and
- X`s y_value is hero`s y_value and
- hero`s held_item_1 is usbFoundLoc and
- X`s object_1 is usbLoc then
- X`s object_1 becomes heroLocation and
- hero`s held_item_1 becomes empty.
- %Collision with items
- rule checkHealthCol
- if X is an instance of cell and
- X`s x_value is hero`s x_value and
- X`s y_value is hero`s y_value and
- X`s object_1 is healthLoc then
- hero`s sanity becomes 100 and
- X`s object_1 becomes heroLocation.
- rule checkWelliesCol
- if X is an instance of cell and
- X`s object_1 is welliesLoc and
- X`s x_value is hero`s x_value and
- X`s y_value is hero`s y_value then
- hero`s held_item_0 becomes welliesLoc and
- X`s object_1 becomes heroLocation.
- rule checkUSBCol
- if X is an instance of cell and
- X`s object_1 is usbFoundLoc and
- X`s x_value is hero`s x_value and
- X`s y_value is hero`s y_value then
- hero`s held_item_1 becomes usbFoundLoc and
- X`s object_1 becomes heroLocation.
- %Collision with stairs
- rule checkStairsToTwoCol
- if X is an instance of cell and
- X`s object_1 is stairsLoc and
- X`s x_value is hero`s x_value and
- elementNum is equal to 5 and
- X`s y_value is hero`s y_value then
- createWorldLevel2.
- action increase;
- elementNum becomes elementNum+1.
- rule checkStairsToThreeCol
- if X is an instance of cell and
- X`s object_1 is stairsLoc and
- X`s x_value is hero`s x_value and
- elementNum is equal to 6 and
- X`s y_value is hero`s y_value then
- createWorldLevel3.
- rule checkStairsToEnd
- if X is an instance of cell and
- X`s object_1 is stairsLoc and
- X`s x_value is hero`s x_value and
- elementNum is equal to 7 and
- X`s y_value is hero`s y_value then
- winGame.
- ruleset checkDeath
- contains checkSanityLevel;
- select rule using first come first served ;
- update ruleset by removing each selected rule.
- rule checkSanityLevel
- if hero`s sanity is less than or equal to 0 then
- echo('DEATH') and
- loseGame.
- action winGame;
- do for every X is an instance of cell
- do X`s object_1 becomes winLoc and
- X`s visited becomes true and
- hero`s x_value becomes none and
- hero`s y_value becomes none
- end for.
- action loseGame;
- do for every X is an instance of cell
- do X`s object_1 becomes deadLoc and
- X`s visited becomes true and
- hero`s x_value becomes none and
- hero`s y_value becomes none
- end for.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement