The Student Room Group
Reply 1
Original post by SophieMay16
Hi, I need a coursework idea for my computing project by tomorrow. I have been thinking about an adaptive mathematics quiz but I’m not sure how I would do it or if it is complex enough?! Does anybody have any ideas or help for this idea?
Thank-you :smile:

i am also doing alvel computer science and we were told not to do quizzes as the are not complex enough to get you the highest possible marks, maybe try something like a chess game? or spaceshooting game? or maze generator?
Original post by Chez 01
i am also doing alvel computer science and we were told not to do quizzes as the are not complex enough to get you the highest possible marks, maybe try something like a chess game? or spaceshooting game? or maze generator?


I have just started, my teacher said an adaptive quiz would be suitable but I’ll have to ask her next lesson, thanks for the response :smile: what are you thinking of doing?
Reply 3
Original post by SophieMay16
I have just started, my teacher said an adaptive quiz would be suitable but I’ll have to ask her next lesson, thanks for the response :smile: what are you thinking of doing?

your welcome and good luck with it!, i am actually halfway through mine, im programming a game similar to https://zty.pe/
Original post by Chez 01
your welcome and good luck with it!, i am actually halfway through mine, im programming a game similar to https://zty.pe/


Thank-you, you too. That game looks good, I can imagine it’s hard to program :smile:
Reply 5
yeh its quite challenging, my teachers gone away for a few weeks so we are kinda alone on it for a while without help >.<
Original post by SophieMay16
Thank-you, you too. That game looks good, I can imagine it’s hard to program :smile:
I made a trading card game, it's basically meant to be a Yu Gi Yo/Pokemon/Hearthstone clone type thing here have a look https://github.com/gummylongtail/Celebreity_Dog_Game/tree/master/CDG what do you think? It's pretty half-assed and tacky but I think it came alright given my criteria
Reply 7
Original post by PyroVulpese
I made a trading card game, it's basically meant to be a Yu Gi Yo/Pokeif itsmon/Hearthstone clone type thing here have a look https://github.com/gummylongtail/Celebreity_Dog_Game/tree/master/CDG what do you think? It's pretty half-assed and tacky but I think it came alright given my criteria


is it for your computer science coursework?
and it says page not found
my bad it was private here https://github.com/gummylongtail/Celebreity_Dog_Game it was meant for GCSE I know you're doing A level but I still want someone to have a look tell me what they think
Original post by Chez 01
is it for your computer science coursework?
and it says page not found
Original post by PyroVulpese
I made a trading card game, it's basically meant to be a Yu Gi Yo/Pokemon/Hearthstone clone type thing here have a look https://github.com/gummylongtail/Celebreity_Dog_Game/tree/master/CDG what do you think? It's pretty half-assed and tacky but I think it came alright given my criteria


That’s sounds like a good original idea :smile: good luck!
Original post by PyroVulpese
my bad it was private here https://github.com/gummylongtail/Celebreity_Dog_Game it was meant for GCSE I know you're doing A level but I still want someone to have a look tell me what they think


I took a bit of time to look at your code - here's a bit of feedback, in case it helps to think about ways you could do things differently, and maybe learn a bit more about python and structured programming at the same time?


It looks like the whole game is written in a single long .py file which is almost 500 lines of code(?) That's really huge for a single .py file, and there's a lot of "stuff" happening which makes it rather complex for a human reader to look at it and figure out what's going on in the code and how it all ties together, since there's no real structure or logical organisation. One thing to try to keep in mind when writing code is that making it easy for humans to read and understand what's going on is important - not even just for other people but for yourself if you ever return to the code or find a bug that needs fixing, or if you want to try to extend the program, etc.

Here's a few ways you could make the program a bit more human-friendly (readable):

1) You aren't using classes properly -- you've created a class, but then you've turned members of that class into global variables, and all your functions are global too -- I'd strongly recommend you read up on how to create objects from classes and use 'self'. The code you've got there isn't really object-oriented, and your class isn't really serving any purpose.

2) There's tonnes of code in there which looks to essentially repeat itself - looks like you've done a lot of Copy+Paste between different if statements, which are almost-identical to each other except for data. Generally speaking, when your code looks the same and only the data is different (e.g. strings, numbers, etc), then you should look at turning that code into a function or trying to generalise it somehow.

3) The code which draws on the screen is tied in really closely with your input handling logic, which is also tied in really closely with your core game logic too. One way to get some logical separation is to consider writing separate classes and functions which serve a single purpose - e.g. a class for handling user input, a class for handling game logic, a class for drawing different things on the screen.

4) If you divide your code into separate classes, then you could start putting those classes into separate files as well. Or if you have a bunch of similar/related functions, you could put those in their own file.

5) You have lot of "hard coded data" in your program which you're using for drawing on the screen - you could consider storing that data somewhere else, such as in a JSON file - then you could generalise some of your screen updates by reading everything from a JSON object rather than needing to hard-code it.

6) You're using several "global variables" which are created at the top of the program (i.e. variables which are visible and modifyable from anywhere in the program) -- these are generally things to be avoided because it means there's no real structure or logical separation to your program; again it goes back to everything feeling like it's all one big chunk of code which is harder for a human to understand, instead of being separated out into small, self-contained pieces which are each responsible for different things.

7) No comments anywhere in the code which explain your thought processes or intent -- comments are really important when writing code because it allows you to communicate with other humans (or yourself in future) all the things you were thinknig when you wrote the code. Any programmer can read code to figure out what that code is actually doing, but trying to understand the intent or reasoning/rationale behind the code is something that you can often only get from having comments; so it's a really good idea to put a reasonable number of comments in your code to help someone follow it (don't go overboard though, and don't state the bleatingly obvious -- commenting is about having necessary and sufficient wording)

8) Try to use verbs when naming functions. Functions "do things", so if you're writing a function, then ask yourself "what does it do?" then use that as the name. for example, your shuffler function might make more sense to a human if you called it shuffle_cards() instead. (Don't be afraid to use multi-word function names either)


Obviously there's loads of stuff you could change, it'd probably take quite a while, but might be a good learning exercise. But realistically anyone who ever writes code always has things that they could improve after they've written it. Writing structured code is a real skill in itself and definitely isn't easy (especially not when you're learning programming in school/college/uni), but it's something worth practicing - especially if you think you might ever like to have a job writing code some day in the future; employers love to see code which is neatly separated into different logical pieces/modules/classes/etc, and where the intent and purpose of the code is clear and easy to understand. .
(edited 5 years ago)
Original post by PyroVulpese
my bad it was private here https://github.com/gummylongtail/Celebreity_Dog_Game it was meant for GCSE I know you're doing A level but I still want someone to have a look tell me what they think


im not familiar with python, sorry!
Original post by winterscoming
I took a bit of time to look at your code - here's a bit of feedback, in case it helps to think about ways you could do things differently, and maybe learn a bit more about python and structured programming at the same time?


It looks like the whole game is written in a single long .py file which is almost 500 lines of code(?) That's really huge for a single .py file, and there's a lot of "stuff" happening which makes it rather complex for a human reader to look at it and figure out what's going on in the code and how it all ties together, since there's no real structure or logical organisation. One thing to try to keep in mind when writing code is that making it easy for humans to read and understand what's going on is important - not even just for other people but for yourself if you ever return to the code or find a bug that needs fixing, or if you want to try to extend the program, etc.

Here's a few ways you could make the program a bit more human-friendly (readable):

1) You aren't using classes properly -- you've created a class, but then you've turned members of that class into global variables, and all your functions are global too -- I'd strongly recommend you read up on how to create objects from classes and use 'self'. The code you've got there isn't really object-oriented, and your class isn't really serving any purpose.

2) There's tonnes of code in there which looks to essentially repeat itself - looks like you've done a lot of Copy+Paste between different if statements, which are almost-identical to each other except for data. Generally speaking, when your code looks the same and only the data is different (e.g. strings, numbers, etc), then you should look at turning that code into a function or trying to generalise it somehow.

3) The code which draws on the screen is tied in really closely with your input handling logic, which is also tied in really closely with your core game logic too. One way to get some logical separation is to consider writing separate classes and functions which serve a single purpose - e.g. a class for handling user input, a class for handling game logic, a class for drawing different things on the screen.

4) If you divide your code into separate classes, then you could start putting those classes into separate files as well. Or if you have a bunch of similar/related functions, you could put those in their own file.

5) You have lot of "hard coded data" in your program which you're using for drawing on the screen - you could consider storing that data somewhere else, such as in a JSON file - then you could generalise some of your screen updates by reading everything from a JSON object rather than needing to hard-code it.

6) You're using several "global variables" which are created at the top of the program (i.e. variables which are visible and modifyable from anywhere in the program) -- these are generally things to be avoided because it means there's no real structure or logical separation to your program; again it goes back to everything feeling like it's all one big chunk of code which is harder for a human to understand, instead of being separated out into small, self-contained pieces which are each responsible for different things.

7) No comments anywhere in the code which explain your thought processes or intent -- comments are really important when writing code because it allows you to communicate with other humans (or yourself in future) all the things you were thinknig when you wrote the code. Any programmer can read code to figure out what that code is actually doing, but trying to understand the intent or reasoning/rationale behind the code is something that you can often only get from having comments; so it's a really good idea to put a reasonable number of comments in your code to help someone follow it (don't go overboard though, and don't state the bleatingly obvious -- commenting is about having necessary and sufficient wording)

8) Try to use verbs when naming functions. Functions "do things", so if you're writing a function, then ask yourself "what does it do?" then use that as the name. for example, your shuffler function might make more sense to a human if you called it shuffle_cards() instead. (Don't be afraid to use multi-word function names either)


Obviously there's loads of stuff you could change, it'd probably take quite a while, but might be a good learning exercise. But realistically anyone who ever writes code always has things that they could improve after they've written it. Writing structured code is a real skill in itself and definitely isn't easy (especially not when you're learning programming in school/college/uni), but it's something worth practicing - especially if you think you might ever like to have a job writing code some day in the future; employers love to see code which is neatly separated into different logical pieces/modules/classes/etc, and where the intent and purpose of the code is clear and easy to understand. .


Thank you I really appreciate you taking time off your day to go through my mess, I'll make sure my code is more legible starting with the one that you just went through, also correct me if I'm wrong but aren't JSON files like javascript and isn't javascript like a language of its own...think I understand what you mean though as in using a JSON file as a sort of style sheet(CSS) like when using HTML is that right or am I still missing the point? also, object-oriented programming hadn't fully grasped that until now thanks. Neatness is something I struggle with in my work and irl, I'm probably the most unorganised person I know but I'll try and like decompose everything into chunks that are legible after all if the examiners can't read it I'm pretty screwed XD. Again thanks mate you're the best!
Original post by PyroVulpese
Thank you I really appreciate you taking time off your day to go through my mess, I'll make sure my code is more legible starting with the one that you just went through, also correct me if I'm wrong but aren't JSON files like javascript and isn't javascript like a language of its own...think I understand what you mean though as in using a JSON file as a sort of style sheet(CSS) like when using HTML is that right or am I still missing the point? also, object-oriented programming hadn't fully grasped that until now thanks. Neatness is something I struggle with in my work and irl, I'm probably the most unorganised person I know but I'll try and like decompose everything into chunks that are legible after all if the examiners can't read it I'm pretty screwed XD. Again thanks mate you're the best!

Don't worry about it! organising code isn't something that comes naturally to anyone at first, it takes practice, and the first attempt at writing a program is always going to be a lot more messy than that same program after spending hours trying to tidy it up and re-factor -- sometimes it can be a good thing to start out with something which is really simple just to get it working, then when you can see the patterns, you can tidy it up later. Obviously the downside is the amount of time it takes to tidy things up.


Maybe I didn't explain the JSON idea very well, but it's just a plain-text structure for data (there are others too, including XML and CSV). It's not a language per-se because it doesn't do anything except provide a structure for holding data in plain text that's easily readable in Python (and in a lot of other languages too, including Python as well as JavaScript and C#/VB, etc).

The difference with that and HTML and CSS is that those both also have their own pre-defined grammar (set of keywords and reserved words) for example, HTML has elements like table, div, img, etc. Also CSS has its own grammar with things like font, text-align, color, etc. JSON is only a structure without keywords so it's not really classified as a language. XML and CSV also both fall into the same category.


In any case, I wouldn't worry too much about JSON specifically - the main thing is to try to think of your program both in terms of data as well as algorithms Even if all you end up doing is just putting data into a dictionary in the program somewhere (Python Dictionaries deliberately look the same as JSON), then you've achieved the same thing in your code/logic.

For example, you have a lot of functions which display messages on the screen and look copy-paste-ish, but you could generalise those functions by putting the data in a dictionary like this, and using it like a data-lookup table: https://repl.it/repls/DutifulImpracticalBetatest

text_boxes = {
"TEXT_BOX_EXERCISE": {
"button_colour_rgb": 0x00FF00,
"text": "EXERCISE",
"height": 100,
"width": 150
},
"TEXT_BOX_INTELLIGENCE": {
"button_colour_rgb": 0x0000FF,
"text": "INTELLIGENCE",
"height": 100,
"width": 50
},
}

Of course, the consequence of that is two-fold:
1) One single, short, generalised function which replaces a whole bunch of almost-identical copy&paste functions (a good thing) -- repetition of code isn't so good really!
2) Slightly more complex code because the data is now separate from the code, and there's an extra dictionary step involved too. (extra complexity can sometimes be a bad thing for human-readability, but not when the reason for that complexity is to remove duplicated/repeated logic)

So really a trade-off of simplicity-versus-flexibility, but the extra complexity is really minimal so doesn't matter here. Also, writing more generalised code is usually a bit more difficult to get it 'right' first time and takes more time and effort.


JSON did originate from JavaScript and means 'JavaScript Object Notation', but it goes way beyond JavaScript these days - it's pretty easy to use in most programming languages because they all have libraries for it which make it really easy to use:
https://stackoverflow.com/questions/12309269/how-do-i-write-json-data-to-a-file
https://stackabuse.com/reading-and-writing-json-to-a-file-in-python/
(edited 5 years ago)
Is checkers a valid game to code for A level OCR and what grade would I roughly receive for it?
Sounds kinda based, but probably get you an A* nonetheless.

Latest

Trending

Trending