Computing pre-release material AQA A

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

Announcements Posted on
TSR launches Learn Together! - Our new subscription to help improve your learning 16-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. Topgeeza's Avatar
    • New Member
    • Posts: 6
    Re: Computing pre-release material AQA A
    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
  2. Ali_1's Avatar
    • Junior Member
    • Posts: 59
    Re: Computing pre-release material AQA A
    This is the pre-release material as a pdf:
    http://www.2shared.com/document/L2zs...2012__1_.html?
  3. ElMoro's Avatar
    • TSR Idol
    • Posts: 8,643
    Re: Computing pre-release material AQA A
    (Original post by Ali_1)
    This is the pre-release material as a pdf:
    http://www.2shared.com/document/L2zs...2012__1_.html?
    Thank you very much!
  4. compy's Avatar
    • Full Member
    • Posts: 114
    Re: Computing pre-release material AQA A
    (Original post by Topgeeza)
    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
    This is all from wikibooks, where there are now a few solutions as well that you can test yourself with.
  5. 101101's Avatar
    • Benevolent Member
    • Posts: 834
    Re: Computing pre-release material AQA A
    To anyone doing python:
    Line 58:
    PHP Code:
    def GetMainMenuChoice():
      
    Choice = eval(input())
      print(
    '')
      return 
    Choice 
    I dont understand the purpose of 'eval' here. On the main menu if you type in text
    instead of a number the program crashes.

    However if you type in one of the fixed variables exactly, for example "NO_OF_TRAPS = 2". The program then goes on to lead menu option 2, which is load a file. This happens as the variable is set to 2.

    Why have they coded the "eval" line to produce that result, must be to do with something they want us to do.
  6. mister c's Avatar
    • Junior Member
    • Posts: 30
    Re: Computing pre-release material AQA A
    (Original post by 101101)
    To anyone doing python:
    Line 58:
    PHP Code:
    def GetMainMenuChoice():
      
    Choice = eval(input())
      print(
    '')
      return 
    Choice 
    I dont understand the purpose of 'eval' here. On the main menu if you type in text
    instead of a number the program crashes.

    However if you type in one of the fixed variables exactly, for example "NO_OF_TRAPS = 2". The program then goes on to lead menu option 2, which is load a file. This happens as the variable is set to 2.

    Why have they coded the "eval" line to produce that result, must be to do with something they want us to do.
    eval is an alternative to int(). if you use eval on a string, it returns a numeric evaluation. so you could say:
    a = "1+1"
    b = eval(a)

    b will now equal 2. you can test this, on the menu, instead of entering 4, enter "2+2" and you'll get option 4.

    i rather suspect that the python code wasn't written by a native python programmer, rather translated from a different language hence the use of eval() rather than int() and the Logical() class for Monster.Is which seems totally unnecessary to me, lastly using pickle instead of writing a CSV text file which would be more in keeping with the spec " Read/write from/to a text file (including csv file)"

    i digress (rant over)

    to summarise, i don't think it's going to be significant that they used eval rather than int. they both crash for the same reason and since the menu choices aren't treated numerically, it's totally pointless to convert them to integers. They could have just had the menu saying if Choice == "1". If I was writing the exam, I'd ask about this.
  7. tgeorge2's Avatar
    • New Member
    • Posts: 4
    Re: Computing pre-release material AQA A
    (Original post by aidenbains)
    this is unlikely, but i was thinking there is the possibility that you'll need to add a multiplayer component.

    idea one - one player controls player, the other controls the monster
    idea two - one player 'designs' the level (potion, monster and trap locations), kind of like a level editor.
    such a great idea. Youre my hero.:d
  8. tgeorge2's Avatar
    • New Member
    • Posts: 4
    Re: Computing pre-release material AQA A
    Has any body figured out how to display the 'M' sign at all times when in the training game? im using Delphi/ Pascal
  9. 101101's Avatar
    • Benevolent Member
    • Posts: 834
    Re: Computing pre-release material AQA A
    (Original post by mister c)
    eval is an alternative to int(). if you use eval on a string, it returns a numeric evaluation. so you could say:
    a = "1+1"
    b = eval(a)

    b will now equal 2. you can test this, on the menu, instead of entering 4, enter "2+2" and you'll get option 4.

    i rather suspect that the python code wasn't written by a native python programmer, rather translated from a different language hence the use of eval() rather than int() and the Logical() class for Monster.Is which seems totally unnecessary to me, lastly using pickle instead of writing a CSV text file which would be more in keeping with the spec " Read/write from/to a text file (including csv file)"

    i digress (rant over)

    to summarise, i don't think it's going to be significant that they used eval rather than int. they both crash for the same reason and since the menu choices aren't treated numerically, it's totally pointless to convert them to integers. They could have just had the menu saying if Choice == "1". If I was writing the exam, I'd ask about this.
    Thanks for the help, I was getting quite confused as to why that was done, but you make a good point.
  10. joyciejibble's Avatar
    • New Member
    • Posts: 3
    Re: Computing pre-release material AQA A
    I'm doing this exam using Java. One of the classes used is Logical.is as a boolean for checking if the monster is awake. My teacher rewrote the code to see if you can just use a normal boolean variable rather than a class. It worked fine. Does anyone have any idea why they would use a class rather than just a boolean variable?
  11. SuperRidler's Avatar
    • New Member
    • Posts: 2
    Re: Computing pre-release material AQA A
    Can anybody send me the Java Pre-Release Material? Thanks!
  12. sean_bulley's Avatar
    • New Member
    • Location: Reading
    • Posts: 11
    Re: Computing pre-release material AQA A
    I noticed that if you don't use a valid letter in the menu it will break the code and the game will stop functioning.

    Perhaps they will ask that we ad an error check to make sure the menu choice is part of the options.

    (Python)
  13. mister c's Avatar
    • Junior Member
    • Posts: 30
    Re: Computing pre-release material AQA A
    (Original post by sean_bulley)
    I noticed that if you don't use a valid letter in the menu it will break the code and the game will stop functioning.

    Perhaps they will ask that we ad an error check to make sure the menu choice is part of the options.

    (Python)
    we fixed this today by not using eval at all. there is no need to have the menu input converted to an integer, leave it as a string then look at the last part of the code where the menu choice is implemented and change

    if Choice == 1
    to
    if Choice == "1"

    and everything works fine again (if you apply that method to all the IF statements). Oh yeah, you have to change the while loop as well to while Choice != "9"
  14. mister c's Avatar
    • Junior Member
    • Posts: 30
    Re: Computing pre-release material AQA A
    Right. Here's a high probability question for you all. The function/procedure CheckValidMove seems to take two arguments - PlayerPosition and Direction. It returns a boolean but currently it does so only by checking that Direction is N, S, E or W.

    This is clearly going to be asked about, they've done this in the past with a validation question where a function took two arguments but didn't use one of them.

    You're going to have to add validation that checks where the player is and returns False if the direction given means that they walk off the edge of the map.

    Make sure that you do this using the global variables for N_S_DISTANCE and W_E_DISTANCE so you're not hard coding the current size of the game only.

    If this doesn't come up in the exam, I'll eat a raspberry pi
  15. D-Box's Avatar
    • Adored and Respected Member
    • Posts: 457
    Re: Computing pre-release material AQA A
    When the traps are generated, there's a possibility that it will generate more than one in the same spot (might be useful if you have to add more traps).
    Last edited by D-Box; 15-03-2012 at 20:59.
  16. mister c's Avatar
    • Junior Member
    • Posts: 30
    Re: Computing pre-release material AQA A
    (Original post by D-Box)
    When the traps are generated, there's a possibility that it will generate more than one in the same spot (might be useful if you have to add more traps).
    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.
    Last edited by mister c; 09-03-2012 at 22:49.
  17. D-Box's Avatar
    • Adored and Respected Member
    • Posts: 457
    Re: Computing pre-release material AQA A
    (Original post by mister c)
    not sure that's right. this is from the python version....
    I've been using the vb.NET code, and it's something I came across earlier today. I edited the amount of traps to something in double figures to test it, then looked at the stored positions and some overlapped.

    It might be a mistake I've made though, so I'll check again tomorrow.

    EDIT: Yeah, I was wrong. Thanks for explaining the code!
    Last edited by D-Box; 15-03-2012 at 20:58.
  18. Bavsterx1495's Avatar
    • New Member
    • Posts: 9
    Re: Computing pre-release material AQA A
    Has Anyone managed to validate the file load so an incorrect file name doesnt crash the program??/
  19. Topgeeza's Avatar
    • New Member
    • Posts: 6
    Re: Computing pre-release material AQA A
    Sub LoadGame(ByRef TrapPositions() As CellReference, ByRef MonsterPosition As CellReference, ByRef PlayerPosition As CellReference, _
    ByRef FlaskPosition As CellReference, ByRef MonsterAwake As Boolean) ' If the user selects LoadGame then this subroutine will load a game from the users local area
    Dim Filename As String
    Dim LoadedGameData As GameData
    Dim Valid As Boolean
    Do
    Console.Write("Enter the name of the file to load: ")
    Try
    Filename = Console.ReadLine
    Console.WriteLine()
    FileOpen(1, Filename, OpenMode.Binary, OpenAccess.Read)
    FileGet(1, LoadedGameData)
    FileClose(1)
    Valid = True ' This section attempts to read the proposed file name
    Catch
    Console.WriteLine("Invalid file name") ' If it is an invalid file name it will loop
    Valid = False
    End Try
    Loop Until Valid = True
    TrapPositions = LoadedGameData.TrapPositions
    MonsterPosition = LoadedGameData.MonsterPosition
    PlayerPosition = LoadedGameData.PlayerPosition
    FlaskPosition = LoadedGameData.FlaskPosition
    MonsterAwake = LoadedGameData.MonsterAwake ' The parameters from the file will then be implemented into a new game
    End Sub
  20. h2shin's Avatar
    • Adored and Respected Member
    • Posts: 595
    Re: Computing pre-release material AQA A
    Does anyone have the pre-released skeleton program for vb.net? my teacher says that it hasn't come through yet but has it come for you guys?
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.