InputStream in...;
OutputStream out...;
Buffer buffer...;
public void run() {
while (true) {
try {
// sleep for X ms
} catch (InterruptedException e) {
}
if (in.available() > 0) {
// read operations
}
synchronized (this) {
out.write(buffer.toArray());
buffer.clear();
}
}
}
You read/write on same thread, but instead of writing directly to the outputstream each time, you write to a buffer, which is in turn written to an outputstream, and the only blocking you get is synchronizing with the player to access the buffer.
I think a neat solution to the problem of others taking advantage of the road you constructed, (which isn’t really an issue IRL due to the roads not being built by the bus-company) would be this:
Make distance a significant factor:
To build a road, you need equipment, like trucks (and materials?)
This equipment needs to be moved (potentially using the very roads they construct)
The same equipment is required to build structures (bus stations)
Once you bring these systems in place, the game suddenly gained a lot of realism and solved the balance at the same time.
I didn’t know of the available method, that makes sense indeed and would halve the number of threads available… sounds like a nice addition after I’m done with Riven’s
Sounds realistic but wouldn’t that slow down the building of things? If I need to move the trucks/materials around every time I want to build something I’ll need to wait for them to arrive, which in turn will prohibit me from quickly throwing up a couple of stations and building a road. I’ll indeed need to fix the “tactic” of reusing roads, but I think that’ll be easier solved by reputation based upon city loyalty to the first company that invest in them.
Well I can confirm there is a bug in purchasing buses.
I bought 1 for my first station, and I got the bus.
The second bus, for my second station, just disappeared. The money is gone, the bus is gone >:O
And thanks for at least acknowledging my suggestion. :’(
EDIT: Also it appears my bus doesn’t want to leave the station “Currently cannot find a path”. I rotated the entrance to be facing the road, but it still can’t find a path.
Give road a owner and then add some small payment for using it. That payment would come from citizens, other players or both.
That would add more variation and economics. Combine this with Riven ideas and there is two different game play strategy. Transporters and builders.
Seems my eclipse debug mode caused some issues instead of helping me solve them… They do leave for me and I can buy new ones… annoying that it isn’t consistent
Seeing as it’s supposed to be a game that works for kids as well (my 6 year old is play testing it a lot ;)) I’m not sure blowing things up is very fitting. Adding some competition like bribing his employees to stop all busses leaving from a station for a couple of hours sounds like a sound tactic though
Roads are owned and I was considering the small payment for using roads someone else built, but won’t that cause everyone to build their own roads in-between the cities? That might make the map very messy (as busses always take the shortest road).
I do really like the idea of different game play strategies though. From the beginning I wanted people to be able to focus on different tasks (building vehicles, building infrastructure or transporting things but as I didn’t come up with the way to make it fun to only build roads (you drag a road and it’s done) I moved away from that idea. If anyone can come up with a nice way to make it fun (without making it very slow and tedious) I’m all ears.
EDIT: I/O is now split up from logic and all logic happens in one thread, let’s see if that helps a bit with narrowing things down
EDIT 2: Tested it by scrolling around a lot, built 3 stations and 10 vehicles. no disappearing or stuck vehicles, no errors on the client or server,. Let’s hope it made it more stable
EDIT 3: Thanks to debug mode I found the dead lock that sometimes caused people not to get past the downloading packages screen
You can balance road building and use cost so it’s not good strategy just build own road every time. Example: Not every airline company build their own airport to every country even if they have to pay costs of using other companies airports.
If it’s no good strategy to build your own roads, why would someone else specialize in only building roads? Because several people use the road and pay toll for it? Or thanks to research invested in specializing in road maintenance and building costs?
The only technical thing I have against it is that my path finding would be messed up as they always take the closest route (there is no distinguish between own roads (free) and using someone elses roads (paid), and having different weights for different people will be… messy.
I think sorting the bus/building list after the town name isn’t good. I think the build order would be great and the last one would stand on the top. And I miss something to drag the list because I have more than 260 buses … That means 250 clicks to reach the end.
And I repeat my wish: minimap and a big map (or really zoom out) because at the moment I don’t know how much stations I have. =)
Wow, so you’re the one pushing the server to it’s limits constantly? Nice job, money must be coming in at crazy speeds
Adding so you can scroll in the lists and a window with all cities including number of inhabitants. Seems like you start needing a map though with all cities and your own stations, hopefully (knock on wood) most of the critical bugs are gone so I can go on with adding it.
I think that’d look bad on the map, but maybe in your list with stations?
Added a list with all cities in the game (with inhabitants). It’s sortable by name asc, name desc, inhab asc and inhab desc. Clicking on a city brings you to it.
You can now scroll in lists (hold down page up/page down to scroll really quick).
Grats to Apo and Riven for being number #1 and #2 in the rankings You may need to refresh the browser to see the rankings once you selected a server (caching). The button is temporary, as I’m on vacation I don’t have access to my home computer where I made the buttons.
EDIT: Your busses are now red while the busses of the other companies are grey/white. This will help in locating your busses.
EDIT 2:
In the station list it now says number of passengers waiting and number of buses using the station Nice suggestion!
I’m trying to keep it simple enough for my 6 year old to play, but some things are indeed a bit too tricky (more graphics in the UI would help but alas I am not the best artist…)
Zooming out to come to a map is on the top of my todo list. I was actually planning to have done it already but requests from some guys here put other things higher on my list
The clouds are normal (it’s actually the water but without land on the bottom). The reason for it is that the server keeps track of everything, and the clients only stream in/out the land close to the viewport (so it’s the server that’s limiting to the world size and never the applet), and the streaming and build up of the VBO’s takes a couple of seconds.
There is no way to beat Apo. For two very distinct reasons:
that cute little bastard takes advantage of your roads
once you are big, there is nothing stopping you: the growth is exponential so there is no way to catch up.
One of the problems is that everything keeps working. You can build two stations and one bus, and it will bring in money forever. If you’d add buses that break down or roads requiring maintenance, that would further balance the game.