--Prevent standalone execution: if not TRAINSPORTED then print("To prevent players from harm, this file may only be executed by the trAInsported game.") return end --AI by LeMas: -- Tutorial 3: Sei smart! function ai.init() buyTrain(3,1) end function ai.chooseDirection(train, dirs) if train.passenger == nil then print (train.name .. " Hat keinen Passagier.") random = math.random(4) print (random) if random == 1 then return "N" end if random == 2 then return "S" end if random == 3 then return "E" end if random == 4 then return "W" end else print (train.name .. " transportiert " .. train.passenger.name) random = math.random(10) if random < 8 then if train.passenger.destX < train.x then return "W" end if train.passenger.destX > train.x then return "E" end if train.passenger.destY < train.y then return "N" end if train.passenger.destY > train.y then return "S" end end end end function ai.foundDestination(train) dropPassenger(train) end function ai.foundPassengers(train, passengers) return passengers[1] end function ai.enoughMoney() buyTrain(1, 3) end