05-02-2013, 11:31 AM
(05-02-2013, 11:03 AM)Neocrypt Wrote: ai\692.as: INFORMATION : Building.<x,y> means that there is a mistake on line x, in this case 12.
ai\692.as: <12, 2>: ERROR : Unexpected token 'else'
ai\692.as: ERROR : Unable to build module
The mistake is that everything beyond "//basic move conditions:" isn't within a function, and once it encounters something that should be inside a function (such as an "else"-statement), it throws an error.
Also the "else"-statement has to follow an "if"-statement, but in this case it is following the function declaration ("int ego(){").
(05-02-2013, 11:03 AM)Neocrypt Wrote: I also don't really understand when I should use certain characters such as {. And yes, I used Clide as a base for his AI...{'s and }'s are used to indicate a block of code.
An example of this is in an "if"-statement. If you want to execute multiple lines of code you'll have to group it within the two brackets like this:
CPP-Code:
if(this_is_true){ do_one_thing(); do_another_thing(); } |
If we were to leave out the brackets like this:
CPP-Code:
if(this_is_true) do_one_thing(); do_another_thing(); |
it would only be the next statement ("do_one_thing();"), and the statements after that would be executed no matter the the result of the "if"-statement.
Also note that the indentation of the lines doesn't matter, so all the following pieces of code mean exactly the same thing
CPP-Code:
//code 1 if(this_is_true) do_one_thing(); do_another_thing(); //code 2 if(this_is_true){ do_one_thing(); } do_another_thing(); //code 3 if(this_is_true){do_one_thing();} do_another_thing(); |
Age ratings for movies and games (and similar) have never been a good idea.
One can learn a lot from reinventing wheels.
An unsound argument is not the same as an invalid one.
volatile in C++ does not mean thread-safe.
Do not make APIs unnecessarily asynchronous.
Make C++ operator > again
Trump is an idiot.
One can learn a lot from reinventing wheels.
An unsound argument is not the same as an invalid one.
volatile in C++ does not mean thread-safe.
Do not make APIs unnecessarily asynchronous.
Make C++ operator > again
Trump is an idiot.