+cvga Posted December 11, 2008 Share Posted December 11, 2008 I've been working on a project and can't get the score to update the way I want it to. Suppose I have two variables (x and y) that I'm using as bit operators to determine if an objective has been met or not. Accomplishing each objective should add to my score at the end of a round. I have a subroutine that looks like this... updatescore roundscore = 0 if x{0} then roundscore = roundscore + 1 if x{1} then roundscore = roundscore + 1 if x{2} then roundscore = roundscore + 1 if x{3} then roundscore = roundscore + 1 if x{4} then roundscore = roundscore + 1 if x{5} then roundscore = roundscore + 1 if x{6} then roundscore = roundscore + 1 if x{7} then roundscore = roundscore + 1 if y{0} then roundscore = roundscore + 1 if y{1} then roundscore = roundscore + 1 if y{2} then roundscore = roundscore + 1 if y{3} then roundscore = roundscore + 1 if y{4} then roundscore = roundscore + 1 if y{5} then roundscore = roundscore + 1 if y{6} then roundscore = roundscore + 1 if y{7} then roundscore = roundscore + 1 score = score + roundscore return Ideally, each objective (bit) could be assigned a different value but for now they're each assigned one point. My program compiles without errors but sometimes the score appears correct and other times I get a different answer than I expected. I changed the score = score + roundscore at the end to score = roundscore while I was debugging to see what I'm getting per round but now my answer is always 54 no matter if I accomplish zero objectives or all of the objectives. Any ideas as to what is going on? I'd like to resolve this before moving on Quote Link to comment Share on other sites More sharing options...
+batari Posted December 11, 2008 Share Posted December 11, 2008 I've been working on a project and can't get the score to update the way I want it to. Suppose I have two variables (x and y) that I'm using as bit operators to determine if an objective has been met or not. Accomplishing each objective should add to my score at the end of a round. I have a subroutine that looks like this... updatescore roundscore = 0 if x{0} then roundscore = roundscore + 1 if x{1} then roundscore = roundscore + 1 if x{2} then roundscore = roundscore + 1 if x{3} then roundscore = roundscore + 1 if x{4} then roundscore = roundscore + 1 if x{5} then roundscore = roundscore + 1 if x{6} then roundscore = roundscore + 1 if x{7} then roundscore = roundscore + 1 if y{0} then roundscore = roundscore + 1 if y{1} then roundscore = roundscore + 1 if y{2} then roundscore = roundscore + 1 if y{3} then roundscore = roundscore + 1 if y{4} then roundscore = roundscore + 1 if y{5} then roundscore = roundscore + 1 if y{6} then roundscore = roundscore + 1 if y{7} then roundscore = roundscore + 1 score = score + roundscore return Ideally, each objective (bit) could be assigned a different value but for now they're each assigned one point. My program compiles without errors but sometimes the score appears correct and other times I get a different answer than I expected. I changed the score = score + roundscore at the end to score = roundscore while I was debugging to see what I'm getting per round but now my answer is always 54 no matter if I accomplish zero objectives or all of the objectives. Any ideas as to what is going on? I'd like to resolve this before moving on Assigning the score to a variable isn't supported. Adding a variable to the score is, but the variable is expected to be in BCD form. Since roundscore can only be 0-16, you can fix your code by adding "if roundscore>9 then roundscore=roundscore+6" before you add it to the score. This will make roundscore into a BCD compliant number. Quote Link to comment Share on other sites More sharing options...
+cvga Posted December 12, 2008 Author Share Posted December 12, 2008 Thanks! Thanks for the explanation. Adding 6 to make a number BCD compliant makes sense. When you say "assigning a score to a variable isn't supported" you mean I can say something like... score = roundscore but I could say score = o score = score + roundscore right? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.