I'm trying to automate the typing process in a video game. Players are given an on-screen QWERTY keyboard layout that they can navigate with the control stick (up, down, left, right) in order to select a letter to type. I was wondering if there was a module for Python (or some other resource I could explore) that would help my program find a path across the keyboard as it types each letter in a given message. In other words, if the first letter typed was "A" and the next letter was "B", the module would know that the program should move 1 space down on the keyboard and 4 spaces to the right.
Currently, I have the program resetting to the "G" key after each letter is typed (allowing me to use fixed-directions as the program parses each character in the desired message). As you can imagine, this is quite inefficient and defeats the purpose of automating the typing in the first place.
Associate to each letter a position.
For example, Q would be (0,0), W (0,1), Z is (0,2), ... A (1,0) ...
This way it is very simple to find the shortest path (simple vectors substraction)
To compute the path Q -> S :
(0,0) - (1,1) = (-1,-1) so you need to do 1 down then 1 right.