Computing pre-release material AQA A

Computer Science and ICT discussion, revision, exam and homework help.

Announcements Posted on
Enter our travel-writing competition for the chance to win a Nikon 1 J3 camera 20-05-2013
IMPORTANT: You must wait until midnight (morning exams)/4.30AM (afternoon exams) to discuss Edexcel exams and until 1pm/6pm the following day for STEP and IB exams. Please read before posting, including for rules for practical and oral exams. 28-04-2013
Sign in to Reply
  1. Bavsterx1495's Avatar
    • New Member
    • Posts: 9
    Re: Computing pre-release material AQA A
    Thanks TopGeeeza
  2. D-Box's Avatar
    • Adored and Respected Member
    • Posts: 459
    Re: Computing pre-release material AQA A
    The training game should probably display the locations of the traps, monster and flask to the player. I think this is vaguely described in the pre-release pdf document.
  3. andythebrit's Avatar
    • New Member
    • Posts: 2
    Re: Computing pre-release material AQA A
    For the training game just go to line 148 and add 'M','T' and 'F'.

    Just here like this.

    Code:
    if Cavern[Count1][Count2] in [' ','*','M','T','F'] or ((Cavern[Count1][Count2] == 'M') and MonsterAwake.Is):
    Also would be kind of neat if there was this command that you could type in during the game to activate "Cheat Mode" if you like.
  4. andythebrit's Avatar
    • New Member
    • Posts: 2
    Re: Computing pre-release material AQA A
    Oh yeah for changing the size of the map you'll probably want to scale the number of traps accordingly. To do this you'll have to use the NO_OF_TRAPS variable down in the PlayGame function as they've only coded in the activation of two traps.

    Code:
    if not MonsterAwake.Is and not FlaskFound and not Eaten:
            MonsterAwake.Is = CheckIfSameCell(PlayerPosition, TrapPositions[1])
            if not MonsterAwake.Is:
              MonsterAwake.Is = CheckIfSameCell(PlayerPosition, TrapPositions[2])
    Right there. I'm not so sure how you'd go about doing this but me and my computing teacher probably think that the coders delibratly didn't put NO_OF_TRAPS in the PlayGame function.

    Just something to think about if you're considering implementing changeable map size.
  5. mister c's Avatar
    • Junior Member
    • Posts: 30
    Re: Computing pre-release material AQA A
    (Original post by andythebrit)
    Oh yeah for changing the size of the map you'll probably want to scale the number of traps accordingly. To do this you'll have to use the NO_OF_TRAPS variable down in the PlayGame function as they've only coded in the activation of two traps.

    Code:
    if not MonsterAwake.Is and not FlaskFound and not Eaten:
            MonsterAwake.Is = CheckIfSameCell(PlayerPosition, TrapPositions[1])
            if not MonsterAwake.Is:
              MonsterAwake.Is = CheckIfSameCell(PlayerPosition, TrapPositions[2])
    Right there. I'm not so sure how you'd go about doing this but me and my computing teacher probably think that the coders delibratly didn't put NO_OF_TRAPS in the PlayGame function.

    Just something to think about if you're considering implementing changeable map size.
    i think that the fact that NO_OF_TRAPS is a constant at the start of the code and yet it's not consistently used as in the example above is bound to come up in one way or another. Either as a programming task (increase the number of traps, test, find it's not as simple as changing the number, fix) or perhaps it will just be a question that does not require coding but needs you to explain why this approach isn't so good and what measures would be needed to fix it.

    SetUpTrainingGame, LoadGame, SaveGame, PlayGame all have the number of traps hard coded to 2 and so would not work as expected if NO_OF_TRAPS was increased or decreased. In fact decreasing it to 1 makes the game crash.
  6. drackiseries's Avatar
    • New Member
    • Posts: 1
    Re: Computing pre-release material AQA A
    I'm using Pascal as my programming language. Me and my class know of the following:
    1) Board limits validation (So player does not walk off)
    2) Menu validation input
    3) Case difficulties when using not a capital letter
    4) Something kinda funky - CIRCULAR MODE - If player meets the boundary of the dungeon then it would go through the wall and come out at the opposite wall.
    5) Difficulty settings by adding a parameter to SetUpGame and PlayGame.
    6) Implementing a move counter that only counts when a valid move is done.
    7) Generating a score for the player?? We thought the score could be based on how many moves you took to find the flask (score := movecounter * 5).
    8) Diagonal Moves (Plus using string input, instead of char)
    9) Displaying the Trap positions of the last game as a menu option.
    10) Storing Name of Player and Score in a file (using records and arrays etc....)
    11) Multiplayer support?? (UNLIKELY)
    12) An idea of a 3D Dungeon??? (Probably going to be asked at the end of the paper)
    13) Undo Move??
    Last edited by drackiseries; 22-03-2012 at 15:02.
  7. joemch's Avatar
    • New Member
    • Posts: 6
    Re: Computing pre-release material AQA A
    (Original post by Ali_1)
    Do any of you think that they will ask us to make it a 3d array and we will have to make rooms up a ladder for example or not?
    To make the game 3d all you would have to do is add a line to the cellReference dateType (structure). e.g. NoOfLevels.

    whereever there is a "cellsNS" or "cellsWE" assignment you would also add a "Level" assignement. I haven't been through to see if this is practical in terms of time.. But it could always be asked as a "what would you do" question.. i.e. not actually coding the solution just outlining the steps.

    Hope this helps

    JoeMch
  8. joemch's Avatar
    • New Member
    • Posts: 6
    Re: Computing pre-release material AQA A
    (Original post by mister c)
    not sure that's right. this is from the python version. function SetPositionOfItem

    while Cavern[Position.NoOfCellsSouth][Position.NoOfCellsEast] != ' ':
    Position = GetNewRandomPosition()

    this loops until the random position is empty. try reducing the map size to 3x2, you always get two traps.

    also, if you want to see where everything is, look at the function DisplayCavern. there will be a line in there somewhere to match this python line:


    if Cavern[Count1][Count2] in [' ','*'] or ((Cavern[Count1][Count2] == 'M') and MonsterAwake.Is):

    so basically, if the Cavern item is a space or an * or if the monster is awake and the item is an M, it gets printed. Just update this line so that it includes all the other items. in python, that means the line starts like this:

    if Cavern[Count1][Count2] in [' ','*','M','T','F']

    alternatively just add another OR statement that says or True at the end or comment out that IF statement altogether. some of these methods will be easier than others depending on the language you're using.
    I guess that does means that if there are not enough free spaces for the randomly placed objects it will go to an infinite loop? it might be worth making sure you could add a check to see if noOfTraps+3 <= (NoOfCellsNS*NoOfCellsWE)

    I know you would have to have a very small grid or lots of traps but if it's possible!
  9. TipTapToe's Avatar
    • Junior Member
    • Posts: 59
    Re: Computing pre-release material AQA A
    How would I catch the error / validate when loading from a file that doesn't exist? (in Pascal).
  10. D-Box's Avatar
    • Adored and Respected Member
    • Posts: 459
    Re: Computing pre-release material AQA A
    (Original post by TipTapToe)
    How would I catch the error / validate when loading from a file that doesn't exist? (in Pascal).
    Is there not a Try...Catch equivalent for Pascal? Either that, or a built in Boolean function to test if a file exists.
  11. TipTapToe's Avatar
    • Junior Member
    • Posts: 59
    Re: Computing pre-release material AQA A
    ^ There's Try - Except or Try - Finally. I've tried them both, but don't know exactly where to put them as I've never used the try command before.


    EDIT:

    Got it working using this
    Code:
    Function FileExists(Filename: String): boolean;
    var
       f: file of byte;
    begin
       Assign(f,filename);
       {$I-}
       Reset(f);
       {$I+}
          if (IOResult = 0) then
          begin
             close(f);
             fileExists:=true;
          end
          else
             fileExists:=false;
    end;
    Last edited by TipTapToe; 24-03-2012 at 21:46.
  12. D-Box's Avatar
    • Adored and Respected Member
    • Posts: 459
    Re: Computing pre-release material AQA A
    (Original post by TipTapToe)
    ^ There's Try - Except or Try - Finally. I've tried them both, but don't know exactly where to put them as I've never used the try command before.
    The vb.NET one works like this:

    Code:
    Try
    [Open the file]
    
    Catch ex as Exception
    [Display an error message]
    
    End Try
    I imagine Pascal would be something like this:

    Code:
    Try [Open the file]; Except [Display an error message]; end;
  13. TipTapToe's Avatar
    • Junior Member
    • Posts: 59
    Re: Computing pre-release material AQA A
    ^ Thanks. That should theoretically work, but apparently you need to disable something called Integrated debugging - which I can't seem to find how. So I just used the code in my edited original post.
  14. Bavsterx1495's Avatar
    • New Member
    • Posts: 9
    Re: Computing pre-release material AQA A
    Has anyone managed to change the number of traps successfully in the VB code?
  15. D-Box's Avatar
    • Adored and Respected Member
    • Posts: 459
    Re: Computing pre-release material AQA A
    (Original post by Bavsterx1495)
    Has anyone managed to change the number of traps successfully in the VB code?
    Yep - Just edit the constant to 3 (for example). Then edit the code around line 305:

    Code:
    If Not MonsterAwake And Not FlaskFound And Not Eaten Then
                        MonsterAwake = CheckIfSameCell(PlayerPosition, TrapPositions(1))
                        If Not MonsterAwake Then
                            MonsterAwake = CheckIfSameCell(PlayerPosition, TrapPositions(2))
                        End If
                        If Not MonsterAwake Then
                            MonsterAwake = CheckIfSameCell(PlayerPosition, TrapPositions(3))
                        End If
                        If MonsterAwake Then
                            DisplayTrapMessage()
                            DisplayCavern(Cavern, MonsterAwake)
                        End If
                    End If
    Add the bit in bold, and it'll work.
  16. h2shin's Avatar
    • Adored and Respected Member
    • Posts: 596
    Re: Computing pre-release material AQA A
    (Original post by Bavsterx1495)
    Has anyone managed to change the number of traps successfully in the VB code?
    All you need to edit is the check if same cell for player position and traps. To make the number of traps editing more flexible, you can do the check using a for loop.

    For i = 1 to NoOfTraps
    MonsterAwake = CheckIfSameCell(PlayerPosition, Trappositions(i))
    If MonsterAwake = True Then Exit For
    Next i

    This means you can even had the player decide how many traps there are.

    To make the program properly support multiple traps, you need to add NoOfTraps variable to the Game Data so that you can save and load the number of traps.

    This also means, ReDim TrapPositions() in the SetUPGame procedure, since LoadGame uses this procedure so that TrapPositions can hold the necessary amount of traps.
    Last edited by h2shin; 25-03-2012 at 20:12.
  17. Bavsterx1495's Avatar
    • New Member
    • Posts: 9
    Re: Computing pre-release material AQA A
    Thanks for the Input
  18. Bavsterx1495's Avatar
    • New Member
    • Posts: 9
    Re: Computing pre-release material AQA A
    (Original post by D-Box)
    Yep - Just edit the constant to 3 (for example). Then edit the code around line 305:

    Code:
    If Not MonsterAwake And Not FlaskFound And Not Eaten Then
                        MonsterAwake = CheckIfSameCell(PlayerPosition, TrapPositions(1))
                        If Not MonsterAwake Then
                            MonsterAwake = CheckIfSameCell(PlayerPosition, TrapPositions(2))
                        End If
                        If Not MonsterAwake Then
                            MonsterAwake = CheckIfSameCell(PlayerPosition, TrapPositions(3))
                        End If
                        If MonsterAwake Then
                            DisplayTrapMessage()
                            DisplayCavern(Cavern, MonsterAwake)
                        End If
                    End If
    Add the bit in bold, and it'll work.
    Your Code doesn't seem to work properly, at first it wont have increased the number of traps, but for some reason it does increase the traps once you have played a game and gone back to the main menu and start another game. the reason I know this is that I've edited the code to see the traps.
  19. Punitn's Avatar
    • Junior Member
    • Posts: 29
    Re: Computing pre-release material AQA A
    From a previous user that entered possible change with the program... i have include some more after playing around found a few shocking things.

    I need help resolving most of this...

    Potential Changes to Code:
    -Update the code to accept upper and lower case direction inputs
    -Stop player moving off edge of map, catch the error
    -Collect menu choices as char rather than integer so that they can be validated and letter entry doesn't crash the program
    -Make it so an innapropriate menu entry brings up an error message
    -When saving in the main menu give the option to resume the game
    -Allow the player to move diagonally
    -Count the number of moves taken before the player is eaten or finds the lamp and display this
    -During a game press "T" to teleport, this can only be used once
    -"display story" menu item
    -Add an option to the menu that resumes a game if they are in save mode
    -Change the size of the map
    -Make it so selecting to load a non-existent file doesn't crash the program

    Problems i found

    -Once you win the game and return to the main, then save the file and re-load the file that was saved, the game is was won, can still play without a flask
    -If you lose the game return home, then save and re-load your still able to play the game alive and not eaten, also the monster is awake again
    -add an option to show all the saved files so it can be selected and prevent saved file form being over written, if the save has the same name as another file the exist.
    -Changing the quit option to option 5 instead of 9
    -change difficult levels by allowing more movement for the monster
  20. Click Me's Avatar
    • New Member
    • Location: Nottingham
    • Posts: 12
    Re: Computing pre-release material AQA A
    Would anyone mind being a cool guy and posting the java code for me?

    My teacher hasn't sent it me yet
Sign in to Reply
Share this discussion:  
Article updates
Moderators

We have a brilliant team of more than 60 volunteers looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

Reputation gems:
The Reputation gems seen here indicate how well reputed the user is, red gem indicate negative reputation and green indicates a good rep.
Post rating score:
These scores show if a post has been positively or negatively rated by our members.