Right, I had a fair bit of trouble trying to use bitmap.setPixel(x, y, zeroAlpha) yesterday, and I think it’s because the bitmap was immutable.
I’ve found some nice code from Sudar Nimalan, whose blog is at http://sudarnimalan.blogspot.co.uk/, which converts to a mutable bitmap in a very memory efficient way, and it goes a little something like this (verbatim, actually):
//this is the file going to use temporally to save the bytes.
File file = new File(“/mnt/sdcard/sample/temp.txt”);
//Open an RandomAccessFile
/*Make sure you have added uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE”
into AndroidManifest.xml file*/
RandomAccessFile randomAccessFile = new RandomAccessFile(file, “rw”);
// get the width and height of the source bitmap.
int width = bitmap.getWidth();
int height = bitmap.getHeight();
//Copy the byte to the file
//Assume source bitmap loaded using options.inPreferredConfig = Config.ARGB_8888;
FileChannel channel = randomAccessFile.getChannel();
MappedByteBuffer map = channel.map(MapMode.READ_WRITE, 0, width*height*4);
//recycle the source bitmap, this will be no longer used.
//Create a new bitmap to load the bitmap again.
bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
//load it back from temporary
//close the temporary file and channel , then delete that also
So, on Wednesday, I can immediately try to convert to mutable bitmap and see if that error disappears. Probably won’t, it’ll probably end up being something else, something tiny but takes me all fucking day to find it, etc. etc.
I improved the initial selection of targetMove last night, but there are still a few problems:
- Certain specific targetMoves cause a crash (stack overflow)
- Kimura Sweep
- Arm Triangle Sweep
- Arm Triangle
- Escape Out The Back
- Moves which are impossible to get to – without P2 actually putting you there – should be disallowed as targetMove
- Pop Elbow Off and Escape
- Push Head, Trap Elbow and Roll
- Isolate One Hook and Push Knee
Need to fix both of these issues, and need to actually diagnose the stack overflow error in the first place. Then I need to start actually implementing the AI choosing logic. On paper, that shouldn’t take too long. There, I just said it, kiss of death.
So yeah, Wednesday it is. Hopefully I can get a good chunk of this sorted.