Recreating the Königsberg Bridge Problem in MIT app inventor

The Königsberg bridge problem was a historical puzzle in the 18th century, where one is asked to cross all seven bridges of the city of Königsberg, each and only once. (it's impossible.)
image

I am trying to recreate the problem as a game, however I ran into some problems.

  1. I don't know how to create a bridge counter work that counts the number of times everytime you pass a bridge) Also, if the number exceeds more than seven, a "game over" screen should appear.
  2. The sprites on the canvas and on the phone are in different positions, as well as the "walls" I've put to prevent the sprite from crossing the bridge (it's quite buggy)
    I've been looking for hours for a fix but to no avail. Here is my aia file
    App.aia (203.3 KB)

Thanks for your help.

2 Likes

It's going to be a while till I can get to a PC, so here's general advice.

Use proportions of canvas height and Width for bridge end animation.

Keep lists of bridge names and region names connected by those bridges.

Keep a list of bridge names already traversed.

What do you mean?

P.S. you might also need an Undo stack

I can't comment further until I can see your code.

P.S. I may not be able to reply until tomorrow since I am about to sleep.

Also I don't have experience with creating lists and whatnot; I’m just a beginner who has watched tutorials and experimented with stuff (and failed)

If you haven't already discovered these resources, they may help you learn to use the AI2 tools. A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook App Inventor 2 Book: Create Your Own Android Apps ... the links are at the bottom of the Web page. The book 'teaches' users how to program with AI2 blocks.

There is a free programming course here Course In A Box and the aia files for the projects in the book are here: App Inventor 2 Book: Create Your Own Android Apps

How to do a lot of basic things with App Inventor are described here: How do you...? .

Also look here App inventor español. Offline. Tutorial. Ejemplos. Instalación. Códigos. Juegos. Curso gratis de App inventor. and here http://www.imagnity.com/tutorial-index/ for more tutorials including Imagnity.com List Tutorial, Mirrored - @Saj

Learn about components Component Reference
and visit the Library The MIT App Inventor Library: Documentation & Support Help>Library on the MENU

That Konigsberg article was a good introduction to the ideas behind graph theory.

You should read it all the way through, and get ready to learn a little of AI2 lists and tables , then graph theory if you are going to offer this premise.

Your current approach is bringing a paint brush to a card game.

1 Like

Here is a bare bones Konigsberg traversal puzzle, without the animation but fully customizable with more maps and bridge collections.

It lacks code to announce a win or loss, though.

I have to leave some fun for you.

Sample Run



Konigsberg Bridges - Konigsberg.csv (112 Bytes)
Konigsberg.aia (103.4 KB)

The bridges csv:

Bridge,From,To
a,A,B
a,B,A
b,A,B
b,B,A
c,A,D
c,D,A
d,B,D
d,D,B
e,B,C
e,C,B
f,C,B
f,B,C
g,C,D
g,D,C
1 Like