I'm current attending a course where we have to write an AI to play battleships, and we managed to put out a great working one, but our teacher is a smartass and I'd like to make a cheating AI, that reads the memory and looks where the opponent AI has placed the ships.
The UI is running in a separate thread, where it runs an observer pattern on the logic in the main thread. The positions of the ships is stored in a binary two-dimensional array where true represents a point on a ship (not which, just any ship).
Now the question is: Is it possible to read the memory of the two-dimensional array of enemyBoard somehow, when it is running in the same process and in the same thread?
If it's in the same process and your classes have any kind of link to the driver (and thus indirectly to the other array), you could obtain it using only the reflection API.
One way of doing this would be to call out to a piece of native C/C++ code that uses the JNI interface to copy the array contents from the heap. JNI offers a number of methods for reading/copying and manipulating objects on the heap. The official documentation is a good place to start.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With