The near future: Trains are no longer controlled by humans. Instead, artificial intelligence is used to handle traffic. Program the best AI, beat challenges on various maps and watch it fight other AIs in live, online matches!
Posts | ||
---|---|---|
beginner - tutorial 3 - first real challenge stuck :) | Locked | |
Thread Options | ||
Apr 17 2013 Anchor | ||
hello, this is a beginners question: I made this code. I dont know if it works or what does it do anyway, because I get some error:
error:
did I really dont close any "if" statement..? edit:
Edited by: funnyman7 |
||
Apr 18 2013 Anchor | ||
Should be
Edited by: AHT0Hu0 |
||
Apr 21 2013 Anchor | ||
I had some problems with where to place the break and return statement I eventually settled on
Edited by: DevCroesus |
||
Apr 24 2013 Anchor | ||
I wrote it as in the tutorial, I think, but it doesnt work... where do I have mistake now?
it doesnt work, ends with an error... |
||
Apr 24 2013 Anchor | ||
a return statemant ends your function. you do not need the break.
if call this function, you can access them with array[1],array[2],etc... |
||
Apr 24 2013 Anchor | ||
thank you, I'll look on it tommorow. I have problems with challnge: smalltown3. I wrote my ai.mapEvent like this:
to send train to right town. |
||
Apr 24 2013 Anchor | ||
your train is only a local variable, that is only in functions, where the game gives it to you
luckily, the map event in this challenge gives you the train, you only need to write ai.mapEvent(train). but there will nothing happen if you return something to the map event. the map event is only a one way trigger, telling you, that you trigger if you reache a special spot, that isn't even a junction. the junction you mean, is at 8/9, the map event is triggered at 7/9.
train direction:=train.dir for the map event i can tell you: as far as i know (i never did this challenge) if your map event is triggered by train1, you need to look if the passenger he is carrying belongs to the northern or the southern park of the city. here you have to do some quite annoying comparisons. however, if the passenger wants to the southern part, you have to drop him here, if not, take him back to the northern part. if it's train to the other way round. Edited by: Sritra |
||
Apr 26 2013 Anchor | ||
it looks like the game doesnt allow this code constructions:
game reports an error: Edited by: funnyman7 |
||
Apr 26 2013 Anchor | ||
Sritra only wrote down Pseudocode, so this code won't run in any programming environment. It's not Lua code that he wrote down. He didn't want to give away all the code, so that others can still figure it out by themselves, he just wanted to help you get the idea. Tutorial 3 is one of the more advanced ones. Once you've beaten that, you're pretty close to writing a very good AI already! |
Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.