-2

Consider 2 roads merging into one(This map is supposed to remain fixed). The program will not generate this map. The program will read this map and plot positions on it on its own.

Path

The python program will control the position of the object. The program is supposed to "highlight" or "fill" a box when the object is at that position, and then empty it as the object changes the position. For example, if the object goes from c10 to c1, and then from b10 to b1, the boxes should be filled and vacated as the position changes.

I don't need the code and stuff. I just need something to graphically represent these "boxes" on, that can be controlled by the program. It's not "text" so I can't just print it on a cmd window. I need something that is a little interactive.

I tried looking for python controlled electric circuit simulators, so that I can represent the positions using light bulbs as "boxes" to switch on and off. Couldn't find what I'm looking for. And I came across some game engines to represent it on, but I don't know if they are the right choice. I'm also not looking for good graphics, the representation needs to be as minimal as possible with some solid colors.

(I Prefer Python, it's better for me if I can make it work with Python, but I can work with Java and C too)

Edit: About the "map": I used the word map to refer to paths, I should've use a better phrase than "read this map". What I mean is, lets say I take an electrical circuit with 30 bulbs, and arrange them in the same pattern given in the image above(That pattern basically makes a "map"). Now, knowing that there are 30 bulbs with all their unique switches, I'll write a program to trigger those switches whenever I want (**it's my job to understand how I designed the pattern and it's positions. I'll be the one to write into the program that there are 30 bulbs with a1, a2, a3...... positions and these are the ones the program has to trigger) **. So if I want the object's position to be c10, I will trigger the bulb at c10.

That's what i wanted to refer with "maps". The "map" is not an image or a document. It's just a pattern of components that I can control. Like if I find an application that lets me control light bulbs, I'll use light bulbs as indicators and positions. If I find some other application that lets me fill circles with colors, I will make the same pattern with 30 circles, and feed my program it's positions.

Also, this map cannot change forms. The Program I'll write will be made for one map only. The user, while running this program, can't change anything about this map. If I, as a developer, want to change the pattern of the map to add more lines or whatever, I'll also have to change the program I wrote for it. So yeah, every map will have it's own program. But once fixed I have no intention to change the map.

  • Exactly what do you mean by “read this map”? Is the map fixed in place or could it move? Can it change form? Is it just a single image or is it streaming video? – candied_orange Dec 8 '20 at 20:05
  • @candied_orange I've edited the question and explained it better. – Jayant Dec 8 '20 at 20:46
0

There are a few python libraries that may be worth looking into but graphics.py is probably a good one to cut your teeth on. I’m not so much recommending as saying this is the kind of beast you need.

The capabilities you need are:

  • Draw an image (the map)
  • Draw a shape on image (the fill)
  • Clear shape from image

graphics.py can do all that but so can others. Clearing the shape can be as crude as redrawing the image. There are more elegant techniques that only repaint a limited area. How much that matters depends on the frame rate you need and the hardware you’re using.

With those capabilities you just need to sort out your business logic of what coordinates to light up and when.

Start with small tests and prove out your capabilities. Learn what problems you have.

You may end up wanting to switch libraries so keep the code that knows how to talk to the library at a distance. The business rules should have no idea what you’re using to draw.

Do all this and things should go smoothly no mater what graphics library you start with.

If you want to work from examples look for open source board games like chess. They have to solve this exact problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.