Skip to Content
Technical Articles
Author's profile photo Enno Wulff

An ABAPventure

West of House

You are standing in an open field west of a white house, with a boarded front door.

There is a small mailbox here.

>open mailbox

Opening the small mailbox reveals a leaflet.

>read leaflet

(Taken)

“WELCOME TO ZORK!

 

This is the beginning of the famous text adventure ZORK1.

ABAPventure

Due to the limited graphical possibilities of the SAPGUI and ABAP I’m always in the search of games that can be adapted in ABAP.

I thought that an ancient text adventure might fit the graphical capabilities of SAP. Luckily, Huw just made a youtube programming course of how to program a text adventure. Thanks Huw, for the inspiration! The examples are in Java and C# but Huw explains how to build the classes and functions so it was quite easy to adapt everything to ABAP.

I use the programming of games to sharpen my ABAP skills. I can define my own data model and most functions and processes are kind self-explanatory. Everyone knows what to expect; there is no need to know about special SAP-modules, fields or functions. This makes designing and understanding a lot easier.

Hopefully such projects will help others to understand programming concepts better.

If you followed some of my blog posts, you know, that all my projects need an impressive name and fancy logo. So I came up with

AXAGE – an Abap teXt Adventure Game Engine

The idea of the project is, to have a game engine with all necessary commands and functions so that you can build your own quests.

axage-logo

You might spell this like AXE AGE…

image credits to pixabay.

What is a text adventure?

The idea of a text adventure is to navigate through rooms and places and solve puzzles using the persons you meet on your journey and the things you find.

You interact with a simple command line (hello DJ Adams πŸ˜‰ ) with the game engine. You can look around and use simple commands to inspect things and interact with the environment.

You can go in different directions to move in the area and enter other rooms and places. On your journey you will find different things that will help you solving the quest. Some things can be opened. Maybe the can only be opened with a special thing that you have to find. You will have to take these things and add them to your inventory.

Current Status of AXAGE

The game engine is in work. And there is still some work to do and some problems to solve. this is the current status which is enough to build a small adventure game.

Parser

you can use two-word commands to interact with the game:

  • WEST – go through the door on the west
  • TAKE BOX – Take the box that is in the room
  • OPEN BOX – Open the box

Two-word commands limit the interaction with the interpreter very strongly. Therefore the next step should be to implement four-word sentences to have more options to interact:

Rooms

The world consists of rooms. Rooms can have exits on the north, east, south or west. You can go in a direction if the room has a door in this direction. You will reach the room next door.

You can also find things in a room which you can take (maybe). You can also drop things into the current room. So far you can take as many things you find. There is no limitation of weight or quantity. The inventory limitation will be one of the next tasks.

Things

Things are objects that you can interact with and which are standing or lying in the rooms. Things can be takeable and/ or openable. If they are openable you can define what thing will be needed to open the thing.

Thinglist

Things are organized in thinglists. An openable thing might also have a thinglist. This thinglist holds the things that are needed to open the box. Mostly you might need one thing to open a box (KNIFE) but you also might need GOLDEN KEY and PURPLE KEY to open a chest.

Actors

Actors are persons that might be in a room. So far the can give you a hint if you ASK the person. You can only ask persons that are in the same room as you are.

Actors should also have a thinglist to hold things that they can give to you or you can give to them. So far this does not work yet.

Demo Adventure – The Cursed RfC

Your task in this simple demo adventure is, to find the Request for change and deliver it to the developers.

ABAPventure

ABAPventure

The map consists of three rooms:

  • the entrance
  • the developers room
  • the consultant office

There are two actors but they still have no functionality, because you need to have four-word commands to interact with people (GIVE RFC TO MARCOΒ , TAKE PASSWORD FROM MICHAEL , ASK JELENA FOR KEYS).

Join

Feel free to join the project to add more features:

  • implement a four-word parser
  • separate game class and GUI
  • extract parser engine into a separate parser class
  • let actors help you giving and taking things
  • implement other helpful functions
  • create a UI5 GUI
  • Create funny or scary adventures with this engine

Maybe we will encounter some of Paul’s three-eyed Monsters in a dark cave to ask them for cool books like ABAP To The Future,Β  Clean ABAP or ABAP Kochbuch.

Have fun coding and a happy weekend

Enno

/2022-05-14: added unit tests

Assigned Tags

      13 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Paul Hardy
      Paul Hardy

      When I started programming (whilst still at school aged about 14) text adventure games were pretty much all I did. I did do a few "normal" games. I recall "Hovis Invaders" where instead of alien spaceships loaves of bread were descending on the Earth.

      Back then I would read the magazine "Computer and Video Games" and see if I could not incorporate the new features I read about into my games. A fine example was "The Hobbit" for the Sinclair Spectrum whereby the NPCs could move and do things whilst you were thinking about what to do next. I got that feature working.

      Also, as alluded to above, I was able to parse commands like "GO WEST AND THEN STAB THE MONSTER WITH THE KNIFE AND THEN JUMP UP AND DOWN".

      Back then text compression was the main barrier. We had so little memory to work with. I designed something in machine code and my mate actually wrote this (remember we were still at school) and it ran on the BBC Micro, and we got an adventure gate working with thousands of locations like the adventure game "Return to Eden".

      When I was releasing the last version of my book I found an open source text adventure game making thing. I ran out of time but I was going to use it to create a game where you ran about Heidelberg being chased my monsters, drinking in all the ten thousand bars in the high street till you found the bar with "ABAP to The Future" in the glass case next to a load of American Football stuff (there is such a bar in the main street of the old town).

      Cheersy Cheers

      Paul

       

       

      Author's profile photo Enno Wulff
      Enno Wulff
      Blog Post Author

      How comes, that I am not surprised by your career, Paul’sΒ ...? πŸ™‚

      Thanks for these insights.

       

      Author's profile photo Michael Keller
      Michael Keller

      A wonderful example of what else you can do with ABAP and a lot of creativity. In addition, you learn a lot about design, tokenizers, parsers and a lot more in general when you deal with text adventures. That's why it's worth it. Entertaining and educational.

      Great work Enno Wulff . As always, you enriches our ABAP world with a colorful facet! πŸ™‚

      Author's profile photo Enno Wulff
      Enno Wulff
      Blog Post Author

      Thanks for your kind words MICHAELΒ !

      Author's profile photo DJ Adams
      DJ Adams

      Thanks for thinking of me πŸ™‚

      Author's profile photo Enno Wulff
      Enno Wulff
      Blog Post Author

      just to generate traffic... πŸ˜‰

      Author's profile photo Matthew Billingham
      Matthew Billingham
      IF input->first_word( ) EQ get_word('ATTACK')
          AND input->third_word( ) EQ get_word('WITH')
          AND input->fourth_word( ) EQ get_word('SWORD').
        reply( replace( val = 'With one well aimed blow you cleave the &1's skull in two"
                        sub = '&1'
                        with = |input->second_word| ).
      ENDIF.

      That should do it.

      But I played and loved many adventure games with just two word parsing. Including one when I was a student in 1989 on my summer job - written by MVS systems programmers.

      Β 

      Author's profile photo Enno Wulff
      Enno Wulff
      Blog Post Author

      😎

      what will get_word( ... ) do?

      The challenge is to provide a parser that validates the input to a given "story". Otherwise you will have an unmanageable mass of IF THEN ELSE CASE statements.

      Author's profile photo Matthew Billingham
      Matthew Billingham

      I think you may have missed the reference to the old Hobbit adventure game for the Spectrum (maybe you're too young πŸ˜€). There's a cool video here: https://www.youtube.com/watch?v=2nYthbboVIs

      If you attacked the chest in the first scene, it responded "with one well-aimed blow, you cleave the chest's skull".

      Author's profile photo Enno Wulff
      Enno Wulff
      Blog Post Author

      πŸ˜† yeah,missed that. My friend owned a ZX81...

      Author's profile photo Matthew Billingham
      Matthew Billingham

      That's where I learn Z80A.

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Thanks for sharing your fun and innovative ideas, Enno!

      I imagine in an SAP-themed game there could be a room where we'd find an SAP Press booth a la "Khajit has wares if you have coin". πŸ™‚

      Author's profile photo Enno Wulff
      Enno Wulff
      Blog Post Author

      In fact Β I had the idea to gamify business processes... πŸ˜†

      Β