Jump to content
IGNORED

# Help with the SCORE keyword

## Recommended Posts

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

##### Share on other sites

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.

##### Share on other sites

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?

## 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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
• ### Recently Browsing   0 members

• No registered users viewing this page.
×
×
• Create New...