Computer Science Canada Any tips? I'm stuck on my game |
Author: | barney [ Wed Jun 07, 2006 5:56 pm ] | ||
Post subject: | Any tips? I'm stuck on my game | ||
As you might have seen from my other post about Rand.Int, I need to make a Mastermind game with a flower theme. But I'm stuck when it comes to the hints...
Any tips on how to do my hints? ps. I know most of you will want to offer some advice on arrays, but I'm not allowed to use any. ![]() |
Author: | HellblazerX [ Wed Jun 07, 2006 8:55 pm ] | ||
Post subject: | |||
I'm still not getting why you have those subscripts, and what I mean by that is this:
Those should only be used if you're using arrays, which you're obviously not, and if you're using string manipulation, which from the looks of your program, you're not either. So why do you have them? Because all they do is make it so your program doesn't work. Btw, why aren't you allowed to use arrays? |
Author: | devilwhat [ Wed Jun 07, 2006 9:42 pm ] |
Post subject: | |
do you have your whole code...if so id like to take a look at it...i too am trying to create this game...but i used arrays... |
Author: | barney [ Wed Jun 07, 2006 9:45 pm ] |
Post subject: | |
OK, I'm using those subscripts because I'm comparing the user's answer against mine, character by character. I know that's going to take ages for me to finish, but I can't think of any other simpler way to do it! ![]() ![]() |
Author: | Anonymous [ Wed Jun 07, 2006 10:03 pm ] | ||
Post subject: | |||
HellblazerX wrote: I'm still not getting why you have those subscripts, and what I mean by that is this:
Those should only be used if you're using arrays, which you're obviously not, and if you're using string manipulation, which from the looks of your program, you're not either. So why do you have them? Because all they do is make it so your program doesn't work. Btw, why aren't you allowed to use arrays? He isn't doing half the things you are saying because he is new to Turing. I was the same way too =) |
Author: | barney [ Wed Jun 07, 2006 10:20 pm ] |
Post subject: | |
vahnx wrote: barney wrote: OK, I'm using those subscripts because I'm comparing the user's answer against mine, character by character. I know that's going to take ages for me to finish, but I can't think of any other simpler way to do it!
![]() ![]() You.... Have a female programming teacher??? I know this is off topic, but is she hot??? All us nerds know that coming across a female programming teacher is rare... Excuse me, I feel the need to use capital letters. I'M A FEMALE TOO! Barney is just a nickname, it's not my real name! And my teacher is pregnant at the moment, so that pretty much explains why she's making crazy decisions...lol. OK, back to topic please! |
Author: | Dan [ Wed Jun 07, 2006 11:31 pm ] |
Post subject: | |
Deleted a bunch of posts above this. This is NOT myspace or some lame dating site. If you have personal message about or to some one send them threw the PM system, e-mail, msn, ect. vahnx wrote: You.... Have a female programming teacher??? I know this is off topic, but is she hot??? All us nerds know that coming across a female programming teacher is rare... Please do not push unture and hurtfull sterotpyes, it just degrages us all. It may be true that the magority of peoleop in computer science are male but this dose not mean us progamers drop everything when we see a girl and yell "OMG A GIRL WTF DO I DO" and start runing around in circles. In fact most peoleop i know in computer science are noraml peoleop with nomral realtionships and even girl firends. Also out of 3 of the computer science teachers i had in high school 2 where female and in unviersity the prof that thougth about 4 of my progaming cores was also female. And futher more, with the cores i toke at collage about 1/2 of the insutrchers where female. This is hardly a rare thing epstaly in high school where computer science teachers need no offical training in computer science to teach it. |
Author: | devilwhat [ Thu Jun 08, 2006 9:10 am ] |
Post subject: | |
exactly...i know a lot of female programmers....but other than that...if anyone could help me programming this code it would be helpful |
Author: | barney [ Thu Jun 08, 2006 4:32 pm ] |
Post subject: | |
Ok, could we get back to topic please? Can I get any tips? I'm so lost! Is there an easier way to do the hint part of my game without using arrays or continuous if statements? |
Author: | barney [ Thu Jun 08, 2006 5:35 pm ] | ||
Post subject: | |||
OK, so I tried fiddling around with a new attempt at this hint stuff. But there's something wrong with it, and I can't exactly figure it out. =( Can anyone help please? Everytime i type in the right answer, it gives me one black peg, and three white pegs. It's not supposed to do that. It's supposed to give me four black pegs... ![]()
|
Author: | TheOneTrueGod [ Thu Jun 08, 2006 5:56 pm ] | ||
Post subject: | |||
Why not nested for loops?
You'd also need a loop around the "Enter your guess" and the checking for their guess part. Theres a couple problems with the method I gave you above, such as if answer(1) = "1" and they guessed "1111" then it'll tell you that you got it right, but if you use some flags, then you can probably work around it. Though, you should probably know something of the mastermind game... lets assume answer = "ABCD" lets assume guess = "DCBA" the program should tell them they have 4 correct, but they are all in the wrong place. if guess = "DCCD" then it should tell them they have 2 wrong, and 2 in the right place. Another way around it The best way that I can see would be to put this all into a function, and have it return a string (4). "2222" would indicate they got everything 100% correct "2211" would indicate they got 2 in the right place, and 2 in the wrong place "0020" would indicate they got the third one in the right place, and the rest were entirely wrong. Of course, you can use whatever characters you want to represent whatever, but the point remains, put it into a function. It'll make your life a lot easier. [Turing Walkthrough] has some info on functions. |
Author: | barney [ Thu Jun 08, 2006 7:49 pm ] |
Post subject: | |
OK....um I checked out the Turing Walkthrough about Functions, and it really did not make any sense to me whatsoever. Care to explain what you meant a bit more? ![]() |
Author: | Omnipotence [ Sun Jun 11, 2006 10:29 pm ] |
Post subject: | |
Alright barney, I'm pretty sure Ms. Cairns (Teacher in question) wouldnt be too happy with you posting stuff on this forum for others to help with. Let alone your source code. The whole point of using substring isn't for you to inefficiently manually code your way through it all over again. It is used for the exact purpose of LOOPS. Functions aren't really necessary. As for generating your hint, using loops, just start comparing position x to position x to figure stuff out. so if two things were in the same position and they were the same, you would know that its correct. P.S For anyone planning to submit to this forum, please don't give out any code to help them out. Its in the wishes of the teacher in question and itd be no good for the development of any programmer in the class. |
Author: | Martin [ Mon Jun 12, 2006 3:04 am ] | ||||
Post subject: | |||||
barney wrote: OK....um I checked out the <a href="http://www.compsci.ca/v2/viewtopic.php?t=8808">Turing Walkthrough</a> about Functions, and it really did not make any sense to me whatsoever. Care to explain what you meant a bit more?
![]() A function is like a function in math. For example, suppose that you had to add the numbers from 1 to n. Your code might look like this:
Now, let's say that you need to do this a lot. Instead of copying and pasting that code over and over, you can write a function, which would look like this:
|
Author: | devilwhat [ Mon Jun 12, 2006 12:47 pm ] |
Post subject: | |
P.S For anyone planning to submit to this forum, please don't give out any code to help them out. Its in the wishes of the teacher in question and itd be no good for the development of any programmer in the class.[/quote] Can anyone help me out. I don't have this teacher and am trying to make a similar game so that I can play it on my own time offline. |