Giter Site home page Giter Site logo

trainsported's People

Contributors

antohu0 avatar b-studios avatar bitdeli-chef avatar bozodel avatar dapine avatar ernyldrm avatar germanunkol avatar jklmnn avatar maxxst avatar nubok avatar pena86 avatar scotty007 avatar tarmo888 avatar trcjr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

trainsported's Issues

Bug when opening Smalltown1 challenge

It crashes. Output:

[17:57:07]~/games/trAInsported> love .
Using port 5556.
No IP given. Will use fallback IP: 127.0.0.1
Found resolution:   1280    1024
OS Detected:    Linux
Will look for AIs in:   /home/cmr//.local/share//love/trAInsported/AI/
Cores detected: 8
Rendered/Loaded images in 0 seconds.
User Challenge Map found: 1. Smalltown1.lua
User Challenge Map found: 2. Smalltown2.lua
User Challenge Map found: 3. Smalltown3.lua
User Challenge Map found: 4. TheMaze.lua
Challenge Map found: 1. ExampleChallenge.lua
Searching:  /home/cmr//.local/share//love/trAInsported/AI/
Error: attempt to compare nil with string
stack traceback:
    [C]: in function 'sort'
    Scripts/ai.lua:534: in function 'findAvailableAIs'
    Scripts/menu.lua:696: in function 'event'
    Scripts/button.lua:101: in function 'handleClick'
    Scripts/input.lua:29: in function 'mousepressed'
    [string "boot.lua"]:164: in function <[string "boot.lua"]:163>
    [string "boot.lua"]:396: in function <[string "boot.lua"]:373>
    [C]: in function 'xpcall'

Added function to open AI folder: Testers needed!

Could some of you report if the new "Open Folder" Button works on your System? I can only test on Windows 7 and Ubuntu and would like to know if it works on all of your system. I'm especially interested in Mac and other Linux Distros, but also other Windows versions...

The button should display in-round and in the main menu.

Confirmed to work with:

  • Ubuntu 12.10 (with Gnome 3)
  • Windows 7

[Feature request] Fast running server mode

For comparing different AIs, single games are pretty useless (there is huge variation from game to game).

Please consider creating a server-mode that just runs matches as fast as possible and logs to a file/db. (It should be possible with the current code without too much work, I was able to hack something together for my own usage.)

Crash when reloading AI-file

happens almost every time in "theMaze"-challenge,
see screenshot.

trainsported-crash-after-reload-ai__themaze_2014-02-14

Also, that message in a logfile / crashfile would be nice...

Documentation error

In the documentation, a copy-paste of 'getMoney' to 'require' lead to a return value and example that do not match the functions.

[feature request] ai.maxTrainsReached()

is it possible to make callback for MaxTrainsReached event instead of putting the error message to console?
Or add an argument contains MAX_NUM_TRAINS to ai.init() callback.

cannot start game at Ubuntu

$ love trAInsported4.love
conf.lua:221: attempt to index field 'screen' (a nil value)
Using port 5556.
No IP given. Will use fallback IP: 127.0.0.1
Error: Scripts/menu.lua:23: attempt to call field 'getModes' (a nil value)
stack traceback:
Scripts/menu.lua:23: in main chunk
[C]: in function 'require'
main.lua:372: in main chunk
[C]: in function 'require'
[string "boot.lua"]:348: in function <[string "boot.lua"]:233>
[C]: in function 'xpcall'

Ubuntu is 12.04.4 LTS (x32), love is 0.9.0 (from PPA)

Bug on OSX: Live --> Main Server

Program crashes, when selecting
Live --> Main Server
(see screenshot)
Happened only once (first time, immediately after install). Tried another three times and was ok.

screen shot 2013-06-26 at 22 20 56

generating passengers

When I wrote SmallTown4, I notices some issues,
e.g. with passenger.new() :

  • how to make a passenger a VIP ?
  • I wanted all my passengers to go to the same destination (e.g. the store),
    but the generated passengers mostly got random destinations.

Maybe the passenger is silently re-rolled if he happens to get a spot
without a rail nearby ?
If so, how to check for "success" ?
How many passengers can be generated ?
How does it work for rush-hour ?

Also, what exactly are the differences between versions 2, 3 and 4
regarding map-generation ?
What features need to be avoided to make maps compatible with v.2 or v3 ?

What map-sizes are recommanded, or what sizes should be avoided
(the buttons for "Compete" only offer even sizes) ?

AI - variants / personalities

For "compete", it would be nice to be able to
run several copies of the same AI, with different settings,
e.g. for pathfinding or passenger-evaluation.
(To avoid making a lot of copies with minor changes,
which is hard to track)

This could be done with an extra parameter "variant-number"
provided by ai.init(), e.g. like ai.mapEvent(aiID, ... ),
so the AI could choose one of its built-in settings.

For AIs used for wargames, this is commonly used to give the same AI
more than one "personality", e.g. with peaceful or aggressive settings.

To see who runs with what settings, it would be nice if the
AI could then append some string to its name.

AI choosing in live match

I found this bug accidentally. if any AI already chosen for the next match and author deleting it before match starts then only 3 AI participates. It should be to check existing of AI-script before round starts and if its missed then choose another one.

Windows version not updated?

As of now, the latest version I could find for windows was "trAInsportedWin2.1.zip" from indiedb.com. The .exe contained was from 03/22/2013.

Its ai.init function is constricted to 5,000 (five thousand) lines, not 50,000 (fifty thousand) lines as indicated in #10.

This version obviously also does not support the maximumTrains parameter introduced recently for ai.init according to https://github.com/Germanunkol/trAInsported/blob/master/Documentation.md. As the web documentation is the only documentation available for windows users, this is an unfortunate situation for any newcomers for the windows version, they have no idea why that parameter does not work in their version.

The AI with the lowest ID has an advantage

The AI with the lowest ID in a match has a slight advantage over every other AI, probably because its methods are called first whenever more than one AI experiences an event in a timestep.

fh:close() is missing in ai.lua

At least when running in Windows XP, the tutorial isn't working due to the fact, that the created AI lua script is locked by the operating system and cannot be modified as long as trAInsported is running.
Reason is that in ai.lua, function ai.new(), the script file is opened and read, but never closed. Adding fh:close() immediately after reading the file solved the issue.
Best regards,
malzahn.

Several tutorial mistakes

Hello!
I just discovered trAInsported and played the first three tutorials. I’m an experienced programmer, Lua was new for me so I started slowly. I’m not quite sure but I think there are some mistakes in the tuts:

  • In tutorial 2 and 3 you refer to a while loop using while i < #variable, but since the indices are one-based (what the hell? this is after Pascal the first language I see using this …), you’d have to check while i <= #variable, am I right?
  • In the last mission of tutorial 3 (the More Ideas) you suggest for checking that a passenger wants to travel east, compare if passengers[1].destX < train.x, but smaller values are west to the current position, so it’s the other way round.

But these are just small mistakes in the otherwise fantastic and friendly tutorials, even for non-programmers. :)

AI's get assigned to non existing player

Currently there are three new uploads (YUNOBringMeHome, mops and agentOrange) which get assigned to a non existing player (ai) instead of the player who uploaded these.

Before and during the match startup (on the mainpage - http://trainsportedgame.no-ip.org/index.php) the 'player' is displayed correctly. After the match has finished, the player has changed to ai. No scores can be stored for this palyer so the uploads remaing with zero matches.

Bug in linecounting

The pcall function also catches the 'taking too long' error, leaving it up to the user to handle it. Refusing to do so effectively removes the line limit. Code snippet that proves this:

function usefullStuff()
    while true do
        print("A")
    end
end

function ai.init()
    print("lines:", getNumberOfLines())
    pcall(usefullStuff)
    for i = 1, 1000 do
        print(i)
    end
    print("lines:", getNumberOfLines())
end

Prints:

[superAI] lines: 87575 5000

AnToHu0: simple additions to Russian.lua?

I just added a button that will open the AI folder.
AnToHu0, could you translate it for me?
Shouldn't take more than 5 minutes.

See lines 91 and 92 in Languages/English.lua

Also, the text in Tutorial 1 which explaines how to open the folder should be modified, search Tutorials/Tutorial1.lua for "AI_DIRECTORY" to find the text and see an example.

Thanks a lot!

randomizing

When reloading the AI after a challenge-map,
it looks like the passengers are placed at the same spots as before,
so I think the same random seed is used.

While this is useful for debugging,
a button/checkbox "fresh random seed" would be nice.

More lines in ai.init()

The function ai.init(map) gets the same amount of lines (5000) as any other function. When loading the script, 50000 lines are available, but rather useless (because the map is not known yet - no path finding can be done yet).

This is not the behaviour described in the documentation:
"Also, ai.init gets to use a lot more lines than the other functions. Try to do heavy calculations in ai.init()!"

buyTrain() on x,y of newPassenger() will not pick him/her up

I delay calling buyTrain() until ai.newPassenger() is called. I buy the train on the x,y, but train passes passenger. I must deliberately place the train one tile away heading towards passenger if I want that train to stop and pick them up.

Is this intended? Or is this a bug?

counting of lines

If someone were to remove all the linebreaks from his code the AI would certainly benefit from it.
I wonder whether this behaviour is intended and just something one has to figure out by himself ;)

for example:
having the init function with a simple while loop,
in case 1 without linebreaks, in case 2 with linebreaks

case 1 consumes around 5000 Lines,
while case 2 consumes more than 10000 Lines

function ai.init(map, money, maxTrains)
    used1, available = getNumberOfLines()
    w = 0 while w <= 5000 do w = w + 1 end
    used2, available = getNumberOfLines()
    print (used1 .. " " .. used2 .. " == " .. used2-used1)
end
function ai.init(map, money, maxTrains)
    used1, available = getNumberOfLines()
    w = 0
    while w <= 5000 do 
        w = w + 1 
    end
    used2, available = getNumberOfLines()
    print (used1 .. " " .. used2 .. " == " .. used2-used1)
end

Crash in Tutorial 4

when loading the following script in tutorial 4, the program crashs:

print("highlight")

function ai.init( map,money )
    buyTrain(1,3,'E')
    counter=0
    s=""
end

function ai.chooseDirection( train,possibleDirections )
    if train.passenger == nil then 
        return "N"
    elseif train.passenger.destX < train.x 
        then return "W"
    elseif train.passenger.destY > train.y 
        then return "S"
    else 
        return "E"
    end

    counter=counter+1
end

function ai.foundPassengers(train, passengers)
    if #passengers == 1 then
        return passengers[1]
    end

    mindist=100
    bestPass=0

    for i=1,#passengers do
        dist = math.abs (train.x-passengers[i].destX) + math.abs (train.y-passengers[i].destY)
        if  dist < mindist then
            mindist=dist
            bestPass=i
        end
    end
    return bestPass
end 

function ai.foundDestination(train)
    dropPassenger(train)
end

function ai.enoughMoney(  )
    buyTrain(2,2)
end

it's incorrect to return bestPass instead of passengers[bestPass], but it should not crash trAInsported.

enhancement of gui

Hey,
first of all I think you did a pretty program there.

Maybe you can show a grid of the coordinates on the map. that would be a great help to understand some actions of your trains, at least sometimes :).
in the tuturial you can click thruogh the overlays. I stopped the time sometimes to see a different spot and wondered why it doesn't do anything anymore. that's maybe ok, because you can't resize an other issue I like to adress. Why isn't the gaming window resizable. looks very funny on a 24" monitor to just use a quarter of the space ^^
and maybe it would be a nice change to have the trains move in the same direction by default

BTW.: I use a Macbook retina (13") with external monitor

broken server matches

While I was watching some of the live matches I noticed that some of them seem to be broken.

The train's are not moved properly (they seem to be teleporting) and at the end the time limit runs out but the round does not end. Instead the countdown switches to 24 hours. At some point of time these matches seem to be killed by the server.

Those matches are normally won by the AI that managed to drop around 3 passengers.
(while a "normal running" match requires at least a two digit number of passengers to win)

Position of Win/Lost-message

(at 1024x768) overlaps the status-message
with the number of remaining passengers.

So it would look better if it was moved a bit.

Missing information on part 4 of tutorial for Windows users

The tutorial (end of part 4) says:

"There is also a full documentation of all the AI functions available in the .love file. Simply use a zip-program to extract it."

I couldn't find the .love file in the Windows version: neither in the game folder nor in C:\Users[Username]\AppData\Roaming\LOVE\trAInsported

It should be told that for this you have to download the source code of the game.

Randomizing IDs of loaded AIs not working

The method randomizeTable cannot be used on the table files in function ai.findAvailableAIs, because it may be sparsely populated, i.e.
{1=ai1, 3=ai2, 4=ai3, 5=ai4}

In game time not accessible

There seems to be no way to get the elapsed game time. os.time is not sufficient, because the in-game time can be paused and sped up/slowed down.

Suggestions:

  • Rewrite os.time to return the in-game time instead of returning the system time.
  • Create a separate method to get the system time.

German translation

Hi, I started to translate the tutorial files into german.
Tutorial 2 is almost finished and will be proof-read from my fellow students.

My questions is: can you provide an email address on your profile? I couldnt find it.
I know I just can create a pull request, but in wanted to ask some questions before e.g:
Would it be helpful for you when i extract the strings out of the Tutorial files so there would be less redundancy?

Cheers,
Flo

Multi-threading

just wondering, is multi-threading allowed by design, or is this an oversight? It kind of bypasses the line/time-limit for functions:

function longFunction()
    for i = 1, 30000000, 1 do
        local x = 5 * 5
    end
    print("long function done")
    print(getNumberOfLines())
end

function ai.init()
    startTime = os.clock()
    coroutine.resume(coroutine.create(longFunction))
    endTime = os.clock()
    print("elapsed: "..(endTime-startTime))
end

This will output:

[thread] long function done
[thread] 5 50000
[thread] elapsed: 4.86

If allowed it would be great for background-calculations (and is already used in some AIs I've seen), but it kind of feels like cheating...

Slow rendering

Starting with SmallTown3 and TheMaze, the time to render maps get really long -
several minutes, on a Pentium-PC 2.8 GHz, 2GB RAM.

I want to suggest an option for reduced details, e.g. no or simpler trees,
just like "no clouds".

Also, selecting the ai-file is done in the menu before rendering,
so a file-selector next to "reload" would be nice.

Licence missing

Under which licence conditions is this source released? Adding copyright and licence information will allow others to contribute and/or fork. :)

Status in Smalltown1 challenge incorrect

When you run the Smalltown 1 challenge the status field in the upper right corner does not update the "passengers remaining" data correctly. That's because it is hardcoded in the Smalltown1.lua file, line 80:

challenges.setStatus("Map by Germanunkol\n" .. math.floor(maxTime-time) .. " seconds remaining.\n4 passengers remaining.")

It should be replace by the corresponding line in Smalltown2.lua, line 95:

challenges.setStatus("Map by Germanunkol\n" .. math.floor(maxTime-time) .. " seconds remaining.\n" .. passengersRemaining .." passengers remaining.")

Create link on website to AIs

Please add a link on the website where you can download other people's AIs.
It is already mentioned that they are available for download, but finding the URL is nearly impossible without reading through several forums.

Error while creating a challenge-map

The script is a straight copy of SmallTown4, just with new mapdata,
so no obvious reasons for an error.

A vage errormessage is displayed at the bottom of the progress-screen,
(as in "something went wrong during rendering ... please restart")
but only very briefly, hardly long enough to read.

If someone is not watching the screen the whole time
during rendering, he wouldn't know that something happened...

Does that mean map-generation was ok ?

Also, sometimes it refuses to select any of the available AIs,
but no message shows up.

How to debug this ?

Edit: I found my bug. But the error-message / debugging-issue is still valid...

Toggle between pause and unpause does not work correctly

In the UI where you can decrease the speed (button labeled "--", left), increase the speed (button labeled "++", right) and pause the game (button labeled "x1", middle) I thought it would be a good idea if you can after pressing the middle button to pause the game ( button goes to "x0") press the middle button again to go back to the previous speed (otherwise you have to press "++" several times). When I looked at the source it seems that you already prepared for that, but in the function pauseGame() in input.lua you forgot a line:

function pauseGame()
    if timeFactorIndex == 1 then    -- unpause
        if timeFactorIndexRemember then
            timeFactorIndex = timeFactorIndexRemember
        end
        timeFactorIndexRemember = false
    else
        if not simulation.isRunning() then
            timeFactorIndexRemember = timeFactorIndex  -- this line is missung
            timeFactorIndex = 1
        end
    end
    timeFactor = timeFactorList[timeFactorIndex]
    if menuButtons.pause then
        menuButtons.pause.l = "x " .. timeFactor
    end
end

Gaming the score table

It's exceedingly easy to get good results on the server by simply uploading one decent and 3 really bad (or broken) AIs at once.

Suggestions:

  • only pick one AI with a low match count and the other three randomly
  • or make the awarded points based on the opponents' score

Common utility functions for AIs / drivingPath(), drivingDistance()

Every serious AIs needs helper-functions such as distance, pathfinding etc.
How about providing some of that as part of the API ?
That would also save some processing time, because analysing the map
only needs to be done once in the "core", instead of once by every AI.

A good start might be "drivingPath(x1,y1,dir, y1,y2, blocked)" and
"drivingDistance(x1,y1,dir, y1,y2)" that gets the path and its length
to get from one point to another, when facing in some direction dir
at the start (i.e. including steps needed to turn around).
Optionally with a list of blocked tiles...

If successful, drivingPath() would return a list of coordinates and directions
to be used with ai.chooseDirection(), or an error-indicator (no-rails,
path-blocked, etc.)

Are ever any Non-VIPs created?

From the documentation I was under the impression that the game would create VIP and non-VIP passengers, with the ratio not directly specified but for example influenced by the Day/Rushhour selection on the setup screen for test competitions ("Compete" on main menu).

But after watching some recent server matches I never saw any non-VIPs created, and after trying many different options under "Compete" on my local PC, there was never any non-VIP passenger created.

I added the follwing at the start of my ai.newPassenger function:

if not (vipTime) then
  print ("Non-VIP erzeugt: ",name)
  vipTime = -1
  end

but the print was never executed. Is this by design or an error?

ai.newPassenger called before ai.init

In the Challange map "The maze" I get a call to ai.newPassenger before a call to ai.init. I don't think I've ever seen this in another place.

Should the AIs expect that kind of thing or is this an error? In other words, can I assume that ai.init will always be called first.

[Sugg] Separate text and code to make translation easier

Hi,

I believe this game has a high educative value. That's why I would like it to be tested by people who, unfortunately, don't all speak English.
The translation itself is not a problem but actually it's not really easy to do as the text is hardcoded into the game. I could recompile the game with translated files but that's a bit too much time-consuming...

The easiest solution would be a folder with files containing the text that could just be replaced with translated ones.

I hope you will consider this suggestion.

-Yho

trAInsported2 funktionert nicht mehr

On Windows 7 32 bit I downloaded the Zip file. Extracted it to harddisk and strated the Exe.
The Program opens 1-2 Windows an crashes after 10 seconds.
Any ideas ?

in-game console can't handle diacritics

I recently started a Brazilian Portuguese translation of this game. While I was testing Tutorial 1, I came across a bug. I tell the player to add the command "print("Olá, trAIns")", and instead of printing it, I get the following error message:

Could not execute script: (TutorialAI1.lua): Scripts/console.lua:54: Not enough space
5: [/home/bozodel//.local/share//love/trAInsported/AI/TutorialAI1.lua]: line 11
6: [=[C]]: line -1
7: [@Scripts/ai.lua]: line 98

I read somewhere that this might be an issue with the engine? Could it have been fixed in 0.9.0?

I can get around that for the tutorial, replacing "Olá" with "Oi", but the player will eventually use diacritics and won't know what to do. If it's impossible to fix the issue, then maybe we can give people an error message telling them to remove diacritics?

P.S.: Is that why the tutorial translations haven't actually been implemented?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.