Log In  

Cart [#50833#] | Copy | Code | 2018-03-26 | Link

Updated with some interface improvements suggested by aaaidan:

  • When hovering with the selection cursor over a city, the two other cities with which it is paired (those with which it "exchanges" traffic) are "highlighted", i.e. they are drawn with a white number on a black background (negative image). This function is disabled while holding "z" down (e.g. when planning a new line).

  • When the cost of a planned line exceeds the current budget, the additional (unaffordable) segments are drawn as a dashed (not continuous) line.

For the previous update (V1.2), see: https://www.lexaloffle.com/bbs/?tid=30979

For the "complete" manual, please refer to the original post: https://www.lexaloffle.com/bbs/?tid=30916

P#50834 2018-03-26 04:47 ( Edited 2018-03-26 04:48)


Cart [#50646#] | Copy | Code | 2018-03-20 | Link

Version 1.2

  • All known bugs have been fixed.
  • The pricing scheme has been overhauled to make it simpler and more useful. The ticket price is now charged when leaving the point of origin and the value is linearly proportional to the distance to the destination, independently of the route taken (multiplied by the "class of travel" factor, whether the whole journey is by Shinkansen or not). For instance, if the distance is 6 "blocks", 4 of which are on fast trains and 2 on slow trains, the total fare is still 30,000 (if the price is left to the default 5,000). If using only slow trains, it would have been 6,000 in total.
  • The decision function to take the Shinkansen (or not) is now nonlinear. Travelers will choose the fast train option if the increase in price is lower than or equal to the square of the reduction in journey duration. For instance, if the duration is reduced by a factor 3 and the price is increased by a factor 5 (default), the traveler will still choose the fast option (5 < 3^2 = 9). This makes the price adjustment function more usable (i.e. it is easier to "convince" travelers to use the Shinkansen for only part of their journey through a small fare reduction).

For the "complete" manual, please refer to the original post: https://www.lexaloffle.com/bbs/?tid=30916


Debugging "Shinkansen" in the Shinkansen ;-)

P#50648 2018-03-20 21:20


Cart [#50224#] | Copy | Code | 2018-03-11 | Link

Deleted original thread by mistake...
A little Particle Swarm Optimisation (PSO) demo. Move the crosshairs using directional keys. Keep "X" down and press up/down to change the number of particles (16 to 128). Move the target to a new location by hitting the "Z" key.

P#50225 2018-03-11 03:14


Cart [#50132#] | Copy | Code | 2018-03-09 | Link

“Shinkansen” is more of a “love letter” to the people (and railways!) of Japan than an actual game, but hopefully it is still at least mildly challenging and entertaining to play…

You are in charge of orchestrating the progressive replacement of the “conventional” railway of a “Fantasy Japan” (each game takes place on a procedurally generated island that bears little topographical resemblance to the real Land of the Rising Sun) with high-speed “bullet train” lines. Your career spans what could be considered Japan’s “golden era”, the 25 years from 1964 (historical introduction of the first Shinkansen) to 1989.

Each map features 16 cities and the inhabitants’ travel pattern is peculiar: in essence, there are commuters between any two cities identified by adjacent numbers, e.g. between “1” and “2”, between “2” and “3” etc. (“16” and “1” are considered adjacent for that purpose). At the beginning of the game, travelers follow the shortest route using the existing (conventional) rail network (grey lines).

By holding the “Z” key while moving the cursor (rounded coloured rectangle) you can connect two cities with a high-speed train line, following any available route between them (you will not be allowed to move the cursor over “forbidden” terrain). It will not replace the existing conventional railway, only run parallel to it. NB: until “Z” is released, the new route is only “in planning”.

The colour of the cursor is specific to the line, of which there can be up to five: red, green, blue, orange and purple. Once the first section of a line has been opened, it can only be “extended” (i.e. any new section must start at a terminus for that line). You can switch between lines by keeping the “X” key down when pressing the left or right arrow key.

Travelers are rational agents (some would call them AI and they’re almost certainly smarter than Sophia ;-) At the beginning of each journey, they compute the cost/benefit ratio of taking the Shinkansen: in the game, the bullet train is 5 times faster than conventional railway. By default, the cost of the ticket is JPY 5,000 per section, which is 5 times more expensive than a normal ticket. Travelers will opt to take the Shinkansen if and only if the travel time to their destination is divided by at least as much as the fare is multiplied. In other words: for the default factor of 5, only travelers whose cities of origin and destination are both serviced by the bullet train will take it.

For every section traveled by one passenger on the Shinkansen, you earn the equivalent of the fare (JPY 5,000 by default). For every section traveled by one passenger on either railway (i.e. including conventional), you must pay JPY 1,000 maintenance and operations fee. In short: if 100% travelers use the bullet train and the ticket price is JPY 5,000, you earn JPY 4,000 per passenger and per section. If fewer passengers choose the Shinkansen, your margin will shrink accordingly.

Opening one new section costs JPY 1,000,000 and you start the game with a JPY 5,000,000 budget. A new line/section can only be opened if you have enough funds available.

The yellow “post-it” note contains all the relevant information needed to play the game and plan your strategy. On the top left is the year (circled, in red). On the top right is the percentage of all ongoing journeys that use the Shinkansen. The other two numbers below are respectively the annual profit/loss (reset at the beginning of each year) and the current treasury, both in thousands of JPY.

The last section at the bottom of the “post-it” note is the current Shinkansen fare (displayed on a white/green background, my best yet pitiful attempt at reproducing an authentic JR ticket!). You change the fare (by JPY 100 increments/decrements) by holding the “X” key down while pressing the up or down arrow key. By making the necessary calculations, you can adjust it down to attract more passengers, but it will of course reduce your margin. The limits are JPY 1,000 (below which you cannot possibly break even) and JPY 5,000 (above which every traveler will choose the conventional railway over the bullet train).

This is a "sandbox" game, so you set your own objective: get 100% travelers on the Shinkansen, reach the 31,999,000 treasury limit as early as possible, use the fewest possible lines to service the whole country…

The number of travelers increases over time (by one unit every year) to reflect Japan’s booming economy. In Jan 1965, one traveler is added to the population commuting between cities “1” and “2”, in Jan 1966, it’s between “2” and “3” and so forth.

P.S. This project took longer to complete than expected and as a result, the code is rather messy... Sincere apologies to my fellow programmers with higher standards!

P#50133 2018-03-09 08:21 ( Edited 2018-03-12 00:59)


Cart [#45376#] | Copy | Code | 2017-10-21 | Link

“Picroisières” is a procedural sailing simulator. Every time you play the game, a new unique archipelago and new weather conditions (wind direction and speed) will be created. Although the map will always look roughly similar, the shape and location of islands should be sufficiently different to keep route planning interesting.

There are two screens: Map and Compass. Toggle between the two by hitting the “Z” key (FR: “W”, DE: “Y”).

Controls are very simple: you only control steering and “power”. Think of the latter as an abstraction for all the trimming, sail changes etc.

Steering is done using the left (port) and right (starboard) arrow keys. “Power” is increased or decreased (by 5% increments) by pressing the up and down arrow keys respectively.

Your boat is a racer: it can easily reach over 15 knots in strong wind! However, sailing at higher speed risks damaging your ship. At 20 knots, a critical failure will statistically occur after approximately 4 hours (game time). At 25 knots (hard to reach but not impossible), after only 45 minutes. Note that this is a probabilistic event, so if you’re unlucky, you could suffer a breakdown much quicker (and vice versa). To be safe, reduce “power” to stay well under 20 knots, where the chance of damage is very low…

The game consists in completing a course through 4 waypoints or gates, in the prescribed order, then coming back to your starting point. Each gate (NW, NE, SE, SW) is marked by a red “+” sign on the map. The next waypoint you must reach emits a “pulsating” signal. The gates are not buoys: you don’t go around them, you must sail “through” them. When you clear a gate, the symbol turns green and the next waypoint is automatically selected. After you clear the last (SW) waypoint, you must return to the starting box.

In “Picroisières”, you race against the clock. The timer starts when you exit the starting box and stops when you re-enter it (after completing the course). Leaving the starting box again restarts the clock, so you can compete against yourself (try to improve your time) or challenge a friend (hot seat).

As in real life, weather (windspeed and direction) changes continuously (and randomly) over time. Before you first exit the starting box, you can randomise the weather as many times as you want by hitting the “X” key (as if choosing the day on which to go sailing). Once the “race” has started, this option becomes unavailable.

White and light blue indicate a safe depth, if you ever enter dark blue or yellow, you will beach your boat (this effectively ends the game as you can no longer manoeuvre in any way). A black symbol at the centre of the screen marks your current position. A black vector (to the edge of the screen) plots your course following the current heading.

If you suffer a breakdown (as a result of sailing at excessive speed), your “power” drops to a maximum of 20% (jury rig) and the drag coefficient of your boat is multiplied by two. Needless to say this makes you rather slow! You must limp back to the starting box (automatically selected in case of damage). When you leave the starting box again, you boat will be repaired.

The map has periodic boundary conditions, which means you can pretty much sail indefinitely in any direction (the archipelago just “repeats” itself). Of course, the gates remain where they are, i.e. you cannot reach the SW gate by sailing NE!

The Compass also shows your heading (CRS), speed (SPD) and the apparent windspeed (WND), as well as the current “power” level. The light blue arrow is the apparent wind direction (taking into account boat speed), the dark blue one is the true wind direction (both obviously overlap when motionless).


P#45377 2017-10-21 02:47 ( Edited 2017-10-21 22:46)


Cart [#43379#] | Copy | Code | 2017-08-18 | Link

In “Jodorowsky’s Sandmaster”, you play the role of a titular “Sandmaster” on Arrakis, the desert planet in Frank Herbert’s “Dune” universe. I imagined this game many years ago. I first implemented it in TurboPascal in the 1990’s, and have since then created a Java version. The obvious next step was to do it in Pico-8.

I called it “Jodorowsky’s Sandmaster” in tribute to this visionary director’s failed attempt at making a motion picture out of Herbert’s landmark Sci-Fi novel in the 1970’s (an epic story recounted in Frank Pavich’s 2014 documentary “Jodorowsky’s Dune”, which I all-heartedly recommend). I drew inspiration from Jodorowsky’s work in redesigning my game, for instance by making the spice a pulsating, organic, psychedelic blue instead of the more conventional cinnamon brown. The patterns in the sand are also meant to be reminiscent of Chris Foss’s “fishskin” spaceship designs. Of course, none of the great artists who were involved in this ill-fated movie project were involved in my modest game. Should Mr Jodorowsky become aware of it and not wish to be associated with it, I will of course remove his name…

In Frank Herbert’s universe, the Sandmaster is the person in charge of supervising spice mining operations. In the game, you pilot a “carryall”, an airborne vehicle tasked with transporting the spice-mining harvesters to extraction sites. The controls are very simple: the arrow keys set the direction of movement. Hitting the key pointing opposite to the current heading brings the carryall to a halt (hovering). Hitting the “Z” key will do one of 3 things: if above a spice-blow, it will lower a harvester (which immediately start collecting the precious substance), if above an already deployed harvester, it will lift it from the ground. Finally, if above open desert, it will drop a “thumper”.

The difficulty (as everyone familiar with the book will know) is that giant worms roam the desert of Arrakis and search and destroy any object producing a rhythmic noise, such as a thumper or a harvester. In the game, worms perceive vibration up to a distance of 16 sprites and will home into the nearest source. The game consists in finding spice (there’s quite a big patch of desert to explore!), then extracting it while luring worms away with thumpers so as to allow harvesters to complete mining operations. In the game, “wormsign” takes the form of a shifting disruption in the sand pattern. Worms cannot cross rocky areas and have to go around them. If a worm comes within 8 sprites of a harvester, the whole screen starts vibrating as a warning of imminent disaster.

You can deploy as many harvesters and thumpers as you like. Deploying a harvester costs 10 points, a thumper 1 point. Losing a harvester to a worm costs 100 points (this includes financial compensation to the workers’ bereaved families ;-), so look after them! Each spice-blow is worth 100 points if fully harvested, which takes some time: you will know that mining is complete when the harvester icon’s animation stops (it will still attract a worm though!) The load is only secure once safely inside the carryall, but you can lift a harvester out of harm’s way at any time (you only need to be right over it and press the “Z” key) and bank a partial load.

The game lasts for a 12 hours shift (countdown in the bottom left corner), after which the score (spice cargo minus costs) is computed. The game should keep track of high scores (enter your 4 letter/number identifier using the arrow keys). If there are harvesters still deployed at the end of the shift, the game will continue until you pick them up (or they are destroyed by a worm), but you cannot deploy new ones (you can still deploy thumpers though).

Enjoy, comment and report bugs please!

P#43380 2017-08-18 05:26 ( Edited 2017-08-23 02:29)


Cart [#32075#] | Copy | Code | 2016-10-30 | Link

My first completed (or thereabout) pico-8 cartridge. As you might guess, I have a soft spot for "2001, A Space Odyssey", and this work is my tribute to it (and other "optimistic" Hard Sci-Fi, a sadly endangered genre).

The gameplay is admittedly a bit basic: you simply shuttle between two space stations (one in low, the other in high orbit), using as little fuel and time/oxygen as possible. The final score is 1000 points for each successful docking, minus 10 points for each fuel and oxygen unit consumed (both replenished after each docking).

Orbital dynamics are accurate, apart from the timescale obviously. Directional arrows control the thrusters of the Orion shuttle, "Z" is for docking when close to the hub of your destination station (the "selection" box will flash when this is the case). Delta-V is deliberately ignored (too hard to manage, particularly at this breakneck simulation speed! ;-)

Everything else is pretty much self-explanatory. Press "X" when docked to exit the game and see your score. The orange curve is of course your craft's projected trajectory. Labels on the edge of the screen indicate the direction of each space station (useful when out of sight). The "F" and "O" values near the centre of the screen are your current "Fuel" and "Oxygen" reserves (I kid you not!) Running out of either will end the game, as will entering the atmosphere (zero score!)

I hope you enjoy practicing your orbital flight skills!

P#32076 2016-10-30 07:02 ( Edited 2016-11-01 01:40)

:: More
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2018-06-25 00:31 | 0.376s | 1835k | Q:77