| When | Mood | Music |
| 2012-04-15 21:23:00 | amused | Alamanana (Geert Huinink Remix) – Tastexperience |
The game is supposed to ask the luser if it wants another go. So it now does.

The luser is also left in no doubt that the game is over.

| When | Mood | Music |
| 2012-04-15 21:23:00 | amused | Alamanana (Geert Huinink Remix) – Tastexperience |
The game is supposed to ask the luser if it wants another go. So it now does.

The luser is also left in no doubt that the game is over.

| When | Mood | Music |
| 2012-04-15 19:24:00 | pleased | Agog in the Ether – Ozric Tentacles |
The basic game does what it should:
Swampy bloodbath!




until one or more enemies enter the ogre’s current location.
Then steps 2 and 3 begin to be repeated.


The remaining tasks are
I need to demonstrate my program and submit my report next Tuesday, so I better crack on.
One refinement I could make is to not use both type (‘ogre’ or ‘enemy’) and subtype of enemy (‘donkey’, ‘snake’ and ‘parrot’). I think these could be collapsed into just one type. Then I’d only need one non-abstract class of creature. But this would remove all vestiges of polymorphic programming from my code…
| When | Mood | Music |
| 2012-04-15 17:57:00 | unproductive | Again and Again – Phil Kieran |
It really doesn’t help if I leave the line in the creator code to place an ogre commented out!
| When | Mood | Music |
| 2012-04-15 17:54:00 | bitchy | Again and Again – Phil Kieran |
I think I have it: it seems I was still trying to take a step while examining the list of creatures in a different place. Back to the full game to find out.
| When | Mood | Music |
| 2012-04-15 17:30:00 | confused | Wombo Lombo – Angélique Kidjo |
I think the bug I’m currently trying to squash is in the ‘remove’ method called from battle(). I’ve traced it by putting single lines of code to display a number after each step. So far, the numbers appear in order.
The remove method works by finding the position (index) in the ArrayList of the creature to be removed, then removing the creature at that index. (You can’t do simply ‘remove this type of creature’. The remove step needs two parts so that you don’t try to remove something from a collection that’s currently being examined – that way lies crash city.)
I was puzzled because the index of the creature to be removed was constantly ‘1’, even though the first creature to be added was an ogre – and the remove code will only work if the creature to be removed is an enemy.
I’d forgotten that computing numbers start at ‘zero’. Bah!

Back to bug-squashing…
| When | Mood | Music |
| 2012-04-15 14:51:00 | disappointed | Will The Circle Be Unbroken – Hayseed Dixie |
I’ve started assembling the actual game – a separate program which calls methods from the Swamp class as needed. It doesn’t quite work yet – the battle section crashes. One reason for this was that I wasn’t checking the current enemy’s type – so the ogre was killing itself!
Having cured this – suicidal ogres are not allowed – and temporarily removed the ‘battle’ section from the game code, the following occurred.:
A swamp is created and an ogre is added.![]() |
||
|
Turn 1. No enemy has been added.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 2. No enemy has been added.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 3. No enemy has been added.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 4. No enemy has been added.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 5. No enemy has been added.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 6. No enemy has been added.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 7. No enemy has been added.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 8. No enemy has been added.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 9.No enemy has been added.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 10. No enemy has been added.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 11. No enemy has been added.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 12. An enemy parrot arrives.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 13. No enemy has been added.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 14. An enemy donkey arrives.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 15. Another enemy parrot arrives.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 16. No enemy has been added.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 17. No enemy has been added.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 18. No enemy has been added.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 19. Another enemy donkey arrives.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 20. No enemy has been added.
![]() |
All creatures move.
![]() |
A battle should occur here, resulting in the parrot at (1,1) being removed to leave just the ogre at those coordinates.
![]() |
|
Turn 21. No enemy has been added.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are.
![]() |
|
Turn 22. Yet another enemy parrot arrives.
![]() |
All creatures move.
![]() |
At this point, a battle should occur at (1,1), resulting in the ogre being killed by 2 parrots. But this code isn’t yet called, so the ogre lives on.
![]() |
|
Turn 23. No enemy has been added.
![]() |
All creatures move.
![]() |
No battle occurs so everyone stays where they are……….
|
This is where the extra methods will be useful. I can create a swamp with creatures where I choose and see whether the battle proceeds as it should.
| When | Mood | Music |
| 2012-04-15 12:32:00 | contemplative | William’s Last Words – Manic Street Preachers |
Original status
Returning to the programming project after a day of cycling and finishing some written coursework for another module, I was faced with a blur of methods (subroutines) written in the order I realised I needed them. These included some methods which were only there to test whether I could create, move and list my creatures.
The chronology followed the basic need to
In short, my code was an inaccessible mess. It didn’t help that the code for the Swamp called code for ogres and enemies which are in separate files. Given that my code has to be read and understood, I needed to tidy it. (Currently, only my lecturer and I need to read my code. However, if I end up writing code for anyone else, they – and maybe later workers – will need to be able to read and modify it easily.)
Problem statement
Given that my code is an inaccessible blur, how can it be tidied?
Solution methodology
It is surely sensible to break any long piece of writing into chunks, i.e. chapters, headings and subheadings etc. So why not do the same to my code?
As far as I know, Java doesn’t allow headings and subheadings. I’m pretty sure there’s no such feature in the IDE I use. However, there are two comment styles:
//comment
and
/** *******************
* comment *
********************* */
The green style is used throughout to say what individual methods, bits of method and individual lines do. I believe the blue style is now used to feed the JavaDoc system and I’ve seen it used for header blocks (name of program, author(s), copyright status, etc). However, I’ve not yet got into JavaDoc.
Solution
So ‘chapters’ in my code are headed
/** *******************
* ALL CAPS *
********************* */
and ‘sections’ are headed
/** *******************
* lower case *
********************* */
Recommendations of how this should really be done are very welcome!
Corollary
Chunking my code and moving the methods so they fit the chunks has also been helpful in that I’ve isolated methods no longer used into a METHODS USED ONLY DURING DEVELOPMENT/TESTING. I feel I should get rid of them but I’m not sure. Recommendations are again very welcome.
I need to write a piece on how my code works, including some comment on development – so in this instance it might be better to keep them. Also, this code won’t be transmitted (unlike JavaScript doing stuff in your browser or naughty things to your computer) so it doesn’t **need** to be concise.
Current status
In my Swamp class, I now have chapters for
My Creature class has
My Ogre and Enemy classes just have creator methods, so don’t need chunking.
| When | Mood | Music |
| 2012-04-13 22:17:00 | relieved | William’s Last Words – Manic Street Preachers |
Much experimentation on a simpler version of my swamp later, it turns out I can remove creatures from the swamp’s creature collection after all. The trick is to FINISH finding the position (technically, the ‘index’) of the relevant creature first (i.e. finish the for-each loop), THEN remove the creature with that index. Now to try it on the full version of the swamp!
| When | Mood | Music |
| 2012-04-13 18:57:00 | dorky | The whole of the moon – The Waterboys |
Oops – I forgot to call the code that invokes a battle. So no matter how many enemies are in his current grid-square, the ogre is immortal!

The following should NOT be the case:

| When | Mood | Music |
| 2012-04-13 18:44:00 | amused | Who Needs Information – Roger Waters |
The music was unintentional but is amusingly appropriate.
I can add a lot of creatures, move them all around and draw a textual ‘map’ of where they all are. Even better, it agrees with where the creatures themselves say they are!




The code to draw the map is horribly inefficient: for each grid-square in each row, each creature is asked ‘should you be added to the list of creatures for this grid-square?’. For a 4 by 4 swamp, each creature is interrogated mercilessly 16 times! I hope I can find a better way – maybe each creature could have a record of whether it’s been added to the map. But then it would need to be interrogated about this too!
If I was still working with grid-square objects, the code would have been ‘for each grid-square in each row, ‘give me a list of your contents’. But that approach didn’t work because of the difficulty of moving creatures.
a back-up of https://friends-ssct.org
wibbelwobble
Good governance and leadership
Participatory Budgeting for the Leith Neighbourhood Network
Maximising the impact and value of library and information science research
Leith Harbour and Newhaven Community Council
News, funding opportunities, and support from Research, Innovation & Enterprise