Coding Task - 23 April 2012 - Make a Jetpack

Sorry to clutter things up, but the other thread is a bit full. This weeks task:
Make a jetpack

That’s all - you can make of this what you will. For those that aren’t big on jetpacks (if people like that really exist =p) any kind of flying vehicle / article / etc will do the trick. Go!

PS - If a week is too short a time, no worries, we can make it a fortnight if people prefer.

Interesting puzzle. Reminds me of little nellie!

I think a new thread for each task is a very good idea.

Agreed. One new thread per week is hardly clutter.

I think the problem on this forum in general is not too many threads, but long threads with meaningless like “I just have this question…” or “can you help?”

I’ve taken a crack at this, but need a bit of guidance as to how to post my code. It’s a bit long to include as part of a normal post. I see that some other people have used playfic – could somebody explain how to go about using that?

Sorry of this is quite basic, but it’s not someting I’ve done before.

Thanks.

Robert Rothman

Hey Robert:

  1. Go to playfic.com
  2. Set up an account
  3. Start a new game
  4. Paste your code into the box
  5. Give the game a title
  6. Click ‘save and test’
  7. Click ‘publish’
    This will give a link pointing to a playable version of your game and its source, so:
  8. Copy the link and paste it in a post here on the forum.

Thanks.

My quick and dirty implementation of a JetPack is at playfic.com/games/RobRothman/jetpack-demo

Robert Rothman

@Robert: The actual jetpack seems to work fine.

A couple of points of style:

Report wearing the jetpack: Say "You slip the harness over your shoulders. It does not seem to fit quite right."; Stop the action.You probably want to use an “after” rule here.

End the game in death.
[/code]This is deprecated; use "End the story saying..." instead (yes, it is less convenient, but the old form may be withdrawn eventually)
To check for deprecated code like that, write this at the top of your program:[code]
Use no deprecated features.

At least one of the ocean rooms has a description not matching the physical layout of the rooms, leading to this:

For a large number of oceans, it might make more sense to have a single “dead end ocean” room and track where the player came from, instead of having lots of separate rooms that you have to keep identical. For a medium sized case (a typical game), you can create a kind of room and have it automagically generate its name and description:

[code]Leading-from relates a direction (called D) to a room (called R) when the room-or-door D from R is not nothing.

The verb to lead from (it leads from, they lead from, it led from, it is led from, it is leading from) implies the leading-from relation.

An ocean is a kind of room. An ocean is always wet. The printed name of an ocean is usually “Ocean”. The description of an ocean is usually “You are in the air above a large body of water. You can see land to [the list of directions which lead from the location].” [/code]Just make sure every ocean is connected to something and it will produce sensible output. If you’re going to allow the player to go up and down as well, just change the “list of directions” to “list of horizontal directions” and add this:

A direction can be horizontal or vertical.  A direction is usually horizontal.  The up and the down are vertical.

And finally, a somewhat less relevant issue:

You could not realistically use this code in a “real” game of IF, because it’s far too easy to produce unwinnable situations (by running out of fuel), unless you provide a refueling station of some kind. Ultimately, the fuel mechanic may overly complicate the gameplay.

But that’s okay, because this is just a demo. It’s not supposed to be dropped wholesale into a “real” game, and as an implementation of flight, it’s quite good.

Thanks. The code for generating a single Ocean room which appears to the player to be a myriad of rooms is a very handy thing to know. Producing the individual rooms manually was a bit of a pain in the ass, and, as you pointed out, I evidently made an error in the descriptions.

Robert Rothman

I’m a bit obsessive about the DRY principle (Don’t Repeat Yourself), so I approve of the “leading from” idea. I also itched to create this phrase:

To say on or above: if the player is airborne, say "in the air above"; otherwise say "on"

Which is exactly the reason for DRY.

Here’s my version of the jet pack puzzle. It’s quite complex and probably isn’t the most efficient way of doing it, but it works well. It might also be a little tough, but then again so is navigating through a zero gravity and frictionless environment! Enjoy!
Jet Pack.zip (174 KB)

Thanks to climbingstar’s and Felix’s help my game is ready for release. Unfortunately playfic doesn’t like the extensions I used (it doesn’t seem to like plurality, which is included in rideable vehicles). So here is the game:
docs.google.com/open?id=0BxxqVX … 1NLSGpsWXM
And the code:
docs.google.com/open?id=0BxxqVX … 0JpTkxIeWM

I decided to have a broom rather than a jet pack. If you knew me you’d realise it was more appropriate. :slight_smile:

Just about to give your game a test run now climbingstars. I’ll let you know how it goes.

Robert, I loved the way you handled the task. This time I decided that, rather than code flying (which you did so elegantly) I would just fake it instead. :slight_smile:

'twas a fun task. Do we have any more entrants for this ‘week’?

PS - Just played your game CS. Wow!

I love how you managed to work action and reaction into a puzzle. Truly awesome!

Climbingstars, I haven’t managed to land safely yet, but your piece is definitiely not easy. I’m curious – does it in fact follow the “real world” laws of physics? That Newton guy has definitely made the world more complicated (although I do like the fig cookies he invented).

Robert Rothman

It does to some extent, but it’s probably not completely perfect. The main concept I use here is for the jet pack to accelerate in a given direction and then continue in that direction when it is put in idle as is the case with travelling in such environments. Also, firing the jet in the opposite direction of motion will slow the jet down and then reverse its direction. One important similarity with real life is that if you keep the jet firing it will continue to accelerate and can make it very difficult to control, that’s why those flying in space shuttles and similar crafts tend to use short bursts of propulsion for aligning up for docking to docking stations.

Well given the Newton Leibniz Calculus Controversy, I’d go with the cookies! :slight_smile:

Yeah, Choco Leibniz are better anyway.

The discussion of physicists and baked goods calls to mind an egregious act of plagiarism of which I was the victim some years ago.

Back when I was but a lad, I once visited Austria for purely scientific purposes, to wit: I wanted to test the hypothesis that “there is pastry in Vienna.” I designed an appropriate experiment and, having arrived in the subject city, proceeded to conduct said experiment and replicate it a sufficient number of times to obtain an adequate sample of data. Eventually, I reached the conclusion that the hypothesis was confirmed.

However, as I was preparing to leave town, it occurred to me that, if a hypothetical second experimenter were to attempt to replicate my experiment shortly thereafter, he would reach a contrary conclusion. This flows from the axiom that one cannot have one’s cake and eat it too; hence, after I consumed all of the pastry in Vienna, there would be none left for the second experimenter to enjoy (at least until the bakers were able to replenish the supply). More generally, this leads to the principle that, under certain circumstances, the mere fact of conducting the experiment – in this case, eating the pastry – can affect the result. I designated this principle the Rothman Strudel Theorem.

I have since learned that physics students are taught this very same principle, without giving me proper credit. Instead, the principle is attributed to some German guy who evidently didn’t like cats.

I have considered bringing legal action against those who have misappropriated my intellectual property. Were I to do so, the theory of the case would undoubtedly become known as the Sacher Tort.

Robert Rothman

Excellent stuff. Reminded me a lot of the old asteroids arcade game, and I really liked the visual display of the thrusters on the status bar. The display of the velocity and acceleration was really flash as well. I’ve got to ask: did you write out all those rooms yourself, or did you make a program to do it?

Also, would there be a way of creating infinite identical rooms with just one room? It could be all directions from itself, and you could track your co-ordinates with two number variables, such that when you arrive at the right co-ordinate, you find yourself at the docking bay. The benefit of this method would be that you could have infinite* space without having to describe so many rooms.

The next logical step would be to extend it in three dimensions, and have the parser understand up-southeast or down-north as USE or DN and so on.

*well, pretty big if you use glulx.