Computer Science Canada Text-Based Adventure I was working on last year, figured I'd look over it and ask for some opinions on it |
Author: | Mattlap [ Fri Jun 01, 2012 11:44 pm ] |
Post subject: | Text-Based Adventure I was working on last year, figured I'd look over it and ask for some opinions on it |
Hey everyone, I'm Matt. I had this semi-complete text-based adventure game sitting in my Turing folder on my computer and I thought I'd take a look at it. I've went through it and I'd like some opinions on the code its self and the game. Thanks. |
Author: | Aange10 [ Sat Jun 02, 2012 1:23 pm ] | ||
Post subject: | RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it | ||
Opinions on game = You'd have to write something very enticing to make me play a text adventure. Opinions on code = Would be much smoother to put the text in a text file and read it. Bulletproofing the get commands wouldn't hurt either. The program could easily look like
|
Author: | Mattlap [ Sun Jun 03, 2012 12:25 am ] |
Post subject: | RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it |
Alright well I'm kind of a super noob when it comes to programming so would you mind explaining what all of that means? =S |
Author: | Aange10 [ Sun Jun 03, 2012 1:05 am ] |
Post subject: | RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it |
Sure, no problem. That's just psuedo code, meaning it's not actually functioning code. It's just there to give you a basic idea. But basically what I was saying is that you could get every 'passage' of text from a text file. From there you could lable the passages. After you've done that, all you'd have to do was loop through 2 lines of code to run your game 1) Display the passage with the number the user's answer gave you 2) Get a new answer |
Author: | jr5000pwp [ Sun Jun 03, 2012 11:23 am ] | ||
Post subject: | Re: Text-Based Adventure I was working on last year, figured I'd look over it and ask for some opinions on it | ||
Or you could do something like this:
You would have to populate them in reverse order, which could be done using a text file, but will probably be easiest done manually in an initializing method, which can be put into another file and pulled in using an include statement to make your main code look neat. I would have suggested classes, because those allow for custom events for different choices, but turing's class system is so bad that it's not worth it trying to figure it out. (atleast for me) |
Author: | Aange10 [ Sun Jun 03, 2012 1:20 pm ] |
Post subject: | RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it |
The only problem with that data structure, Jr5000, is 1) It's pretty complex for the problem. It's also hard to read all the data in it, given how its dynamically nested. But the biggest problem, would be that there isn't an easy way to go backwards. With a procedure to correlate a number to a message, you could skip around as you like. You'd also be able to easily tell which number goes to which message. |
Author: | Mattlap [ Sun Jun 03, 2012 4:23 pm ] |
Post subject: | RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it |
So, Aange10, what would I have to do to use that in my program. Like what is readFile and getPassage? What do they do? That kind of thing. Again exuse the ignorance |
Author: | Aange10 [ Sun Jun 03, 2012 4:54 pm ] |
Post subject: | RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it |
Do you know what procedures are? |
Author: | jr5000pwp [ Sun Jun 03, 2012 7:42 pm ] |
Post subject: | RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it |
I hadn't thought of backtracking, that would require a List of all the previous states, or recursion, which could get messy. The reading could be done, although it may end up reading in like your solution. Regardless, your solution is more practical and easy. |
Author: | Aange10 [ Sun Jun 03, 2012 8:01 pm ] |
Post subject: | RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it |
Mirhagk wrote: Just remember Occam's razor. All other things being equal, the simplest solution is best. Though I am sure there is a more elegant solution than my suggestion too. |
Author: | jr5000pwp [ Sun Jun 03, 2012 9:35 pm ] |
Post subject: | RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it |
True, I'm sure you can create a more intricate game if you choose an OOP solution, but it wouldn't be very pretty at all the way that turing implements classes. And that is not the kind of solution that Mattlap is requesting. BTW, what did you intend with "get passage # passage". Is that meant to represent retrieving the passage from an array of passages? |
Author: | Aange10 [ Sun Jun 03, 2012 9:46 pm ] |
Post subject: | RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it |
Pretty much. |
Author: | Aange10 [ Mon Jun 04, 2012 1:40 am ] |
Post subject: | Re: Text-Based Adventure I was working on last year, figured I'd look over it and ask for some opinions on it |
I made an example, try looking at this. Also, idk why, but Turing's escape keys don't seem to be working for me. Everywhere you see \t there should be a tab, and everywhere you see \n there should be a new line. |
Author: | Raknarg [ Mon Jun 04, 2012 8:11 am ] |
Post subject: | RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it |
this might be a bit late... but @jr5000pwp I think what you're looking for are linked lists, it would be basically the same thing but more organized. |
Author: | Mattlap [ Mon Jun 04, 2012 7:40 pm ] |
Post subject: | RE:Text-Based Adventure I was working on last year, figured I\'d look over it and ask for some opinions on it |
So, Raknarg, what are those rofl edit: Do you remember me? You help me on both this and another project last year My profile pic used to be a lemur sitting cross-legged with its tounge out and then a communist lemur lol |
Author: | Raknarg [ Mon Jun 04, 2012 8:01 pm ] | ||||
Post subject: | Re: Text-Based Adventure I was working on last year, figured I'd look over it and ask for some opinions on it | ||||
haha there's too many users too remember XD hello again though. So basically I like to consider them as arrays with multiple directions. They can work in different ways. For instance, you could just imagine a chain, where one link is touch the next link and the one before it, or a tree where each link is holding two links below it, and you have one original link at the top. In this case, you could do something like the tree one. I'll tell you a bit about the first one. You would start with this:
So look at what we have here. There's a collection with three things: a pointer to the next link, a pointer to the previous link and a contents variable that'll hold some info. So far there is only one link, so we say that the current and next links have nothing, i.e. nil. There are different ways to go about doing this, but this is what I do. Now lets say we wanted to move to the next link in the chain. We would do this:
This might look a bit confusing, so we'll break it down. First we initialize the pointer next so we can use it. (Idk if that's necessary, I'm just used to classes. Kindof similar in turing). Then we have this statement: current -> next -> previous := current In other words, we want what the previous of whatever next is to be whatever you're at now. If you just tried to move on to next without this statement, previous would have nothing in it, and so you would lose current. The idea of a linked list is to have everything linked, remember? current := current -> next We want current to now be on the next link. Pretty straightforward. So it might be a bit confusing, but it can come in handy sometimes. I'll show you a game I made with this idea. |