Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
Visual Studios is saying my variable is undefined for some reason.
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="omatamix" data-source="post: 472593" data-attributes="member: 84722"><p>Hey for some reason visual studios is saying variable score is undefined but looking at the code, I can't see why it would not be set. Here is my code below.</p><p></p><p>[CODE=cpp]int reduction = 1;</p><p>if (moveCount == 0) {</p><p> Score score = -search(position.makeMove(move), -beta, -alpha, depth - reduction, ply + 1);</p><p>} else {</p><p> if (moveCount > 3 && !(move.bit & 2)) reduction = 3;</p><p> Score score = -search(position.makeMove(move), -alpha - 1, -alpha, depth - reduction, ply + 1);</p><p> if (alpha < score < beta) {</p><p> score = -search(position.makeMove(move), -beta, -score, depth - reduction, ply + 1);</p><p> }</p><p>}</p><p>if (score >= beta) { // Says score is undefined.</p><p></p><p>}[/CODE]</p><p></p><p>How is that possible because the score variable is set no matter which way the if statement goes. Is this an error on visual studios?</p><p>[automerge]1642268110[/automerge]</p><p>I solved this by defining score before the if statement, but shouldn't this work as well?</p></blockquote><p></p>
[QUOTE="omatamix, post: 472593, member: 84722"] Hey for some reason visual studios is saying variable score is undefined but looking at the code, I can't see why it would not be set. Here is my code below. [CODE=cpp]int reduction = 1; if (moveCount == 0) { Score score = -search(position.makeMove(move), -beta, -alpha, depth - reduction, ply + 1); } else { if (moveCount > 3 && !(move.bit & 2)) reduction = 3; Score score = -search(position.makeMove(move), -alpha - 1, -alpha, depth - reduction, ply + 1); if (alpha < score < beta) { score = -search(position.makeMove(move), -beta, -score, depth - reduction, ply + 1); } } if (score >= beta) { // Says score is undefined. }[/CODE] How is that possible because the score variable is set no matter which way the if statement goes. Is this an error on visual studios? [automerge]1642268110[/automerge] I solved this by defining score before the if statement, but shouldn't this work as well? [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
Visual Studios is saying my variable is undefined for some reason.
Top