OU blog

Personal Blogs

neil

i'll never be a mathematician

Visible to anyone in the world
Edited by Neil Anderson, Sunday, 30 Sep 2012, 20:40

I'm too sloppy.

Yesterday I went to my topology tutorial, which gave me a lot of hope. Nothing was exterior to the closure of the open ball that is my understanding zone [wee topology-joke there].

Afterwards we went to the pub and chatted stuff, then, wonderfully, Ford and his M209ers arrived. I needed to head home but I imagine that much talking and drinking happened after I'd left. I certainly hope so.

Today I bracketed about five hours of revision around a couple of hours of walking to-and-from my school and putting away exam desks.

There was much mumbling about sequences in topological spaces going on during this work-walk process—I still don't get these, I suspect that I'm missing something obvious.

So sloppy?

I started some solitaire stuff the other day. What I posted isn't wrong, the topology is probably the right one, nothing I say is an outright lie. But in every other way it is wrong.

As I work my way through the books I notice the, slightly, wrong assumptions that I have made along the way. Sloppy.

As soon as I thought about how I would code it I saw where I had gone wrong. I'll leave the tripe that I wrote-up up, but I'm going to have take some time to think about this.

[For affecionados I created a topological space that wasn't Hausdorff, so it couldn't be a metric space. And yet I wanted a metric.

I think that this is the right topological space to consider, we just have to forget about a metric. A metric which is difficult anyway.]

Permalink Add your comment
Share post
neil

future, past

Visible to anyone in the world
Some thoughts about today and tomorrow and some stuff about solitaire.
Permalink Add your comment
Share post
neil

revision

Visible to anyone in the world
Edited by Neil Anderson, Tuesday, 25 Sep 2012, 21:48
Doing it my way.
Permalink Add your comment
Share post
neil

solitaire

Visible to anyone in the world

As always, but there is some other stuff.

 

Permalink Add your comment
Share post
neil

more groups and solitaire

Visible to anyone in the world
Edited by Neil Anderson, Friday, 20 Jan 2012, 18:39

Since my last post I've been thinking. Some messing around found me a pattern, a rather nice one for my purposes. Some background. 

I represent, even triangular Boards, as a HashMap of Pegs, some of these Pegs aren't valid. The hashCode() is just...

return (row * 10) + col;

Boards have rows and cols int properties, it doesn't make sense to rotate a Board if these are different. [Reflexion is another matter which I'll tackle later.]

When I started to think about rotation of a Board things got a little complicated. Take a ∏/2 anti-clockwise rotation. The Peg at 02 goes to 40, 05 goes to 10 etc.. Suddenly it hit me!

Take any row

10 11 12 13 14 15 16

Reverse it

16 15 14 13 12 11 10

Transpose the digits of the reversal

61 51 41 31 21 11 1

And map...

10 11 12 13 14 15 16

61 51 41 31 21 11 01

Which is the right answer and is pretty easy to programme. [Pseudo-code, I need to prove this one, I can't see any boundaries to test against.]

((Board.getRows() - Peg.getCol()) * (Peg.getRow() * 10)) + Peg.getRow();

So now I can programme a ∏/2 anti-clockwise rotation, which means I can compose to get the other rotations. Then I can loop through the pegMaps to see if they are equal (in the sense that they can be rotated onto one-another) and I can compare Boards up-to rotation.

I've come across something like this before; with Groups, conjugate cosets, permutations and equivelence. [I really do need to do some work on my Group Theory, because I know that I'm not describing this properly. I see the pattern, but I've forgotten what it's called, and means.]

Still I was right, there's more Groups to Solitaire than we thought.

 

Permalink Add your comment
Share post
neil

group action

Visible to anyone in the world

When I originally wrote the hashCode(), equals() and compareTo() methods for the Peg Class I didn't really think about comparing Boards.

Now that I'm there I see serious problems. I can write an algorithm, but even in pencil, on A4, it looks strained. And that's just for an English Board.

The problem is that Boards should be equal if you can rotate them onto one-another [I decided that reflection was out, which might be another mistake].

The good thing is that I can change things without a, "cascade of failure". The bad thing is that, for the moment, I can't see an easy way to do it.

I'm stuck with a hard choice: easy Peg, hard Board. Or vice-versa.

Permalink Add your comment
Share post
neil

parsing xml with java

Visible to anyone in the world

Is a sodding pain. I will be able to do it, eventually, but for now I'm going to leave it. It's just too fiddly and not much fun.

I can happily save as XML and use an XSLT to get what I need for now.

Really I should be working my way through unit 1 of the topology course, but I can't be bothered with that either.

Three months off have left me unable to motivate myself to do the uncongenial.

Permalink Add your comment
Share post
neil

as i thought

Visible to anyone in the world

[See my previous post]

Creating the XML wasn't difficult, I knew that it wouldn't be. Parsing the thing back will be a bugger.

There's a big bit of me asking why this is should be so. It's not as if XML isn't a standard. Someone should have made this easy. But..

If I bump into a bod on the street and start talking Topology [not there yet, but will be sometime soon wink], I'm seen as a benign idiot; I start talking XML and I'm a signed-up-member-of [insert your favourite hate group here].

True, the thing was, and is, used wrongly, but we can say this about any data format, can't we? Morons used it when they shouldn't, it's still better than anything else we have. Or do you fancy openDoc?

Who knows. But it is, funny? One of the major techs that drives the web is named after XML, which it doesn't use. AJAX [Asynchronous Javascipt and XML].

Only a moron loads XML, because you have to fork IE and normal browsers' javascript... [I've tried, if you want the almost working code drop me an email.]

Jings! I've just realized that I need to care not one iota about how others are going to use my stuff. I'm off the leash for once.

So it's going to be XML. Plus.

 

Permalink 2 comments (latest comment by Neil Anderson, Thursday, 12 Jan 2012, 21:17)
Share post
neil

i could use XML...

Visible to anyone in the world
Edited by Neil Anderson, Thursday, 12 Jan 2012, 17:33

You have these thoughts.

Last night I started to write the, proper, specification for version 1.0 of the solitaire thingee [codename: suzdal (not after the town! wink]. I got as far as the input/output before hitting a problem.

I knew what I wanted to do, and describing this it wasn't too hard. But when I started thinking about the how, I began to doubt—I seemed to be designing a proprietary file format. Not good, brittle. That's when I started to think XML.

Java has plenty of libraries for writing and parsing XML, I'm comfortable with XML and XSL [the sitemap for my nonsense is an PHP generated XML file]. It would seem to make sense, would it not?

The problem is that it would be quicker to build my own format and move onto the stuff that I want to do. That's the temptation—should I spend the extra time [a quick guess-timate is about five-or-six times the time] to do things properly? Whether to build something that will last, rather than just work?

If you think that's this is a no-brainer then you don't understand the problem. To do this properly will involve me being mired in online documentation and tutorials, making hundreds of adjustments to lots of classes [because I've rather built-in my current format] and writing out sequence diagrams, and such, by the score. In short it won't be much fun.

Damn it! All this OU stuff has had its effect, I have to do it right. Time to crack-open the

DocumentBuilderFactory

Docs. and get planning...well, actually not yet. Because I have the spec. to finish first don't I?

Permalink Add your comment
Share post
neil

All my holidays are over

Visible to anyone in the world
Edited by Neil Anderson, Wednesday, 11 Jan 2012, 20:43

Today I downloaded the first TMA for the Topology course; the books haven't even been posted yet. Still, come late[-ish] February the thing [the TMA] and its associated PT3 will have to be with my tutor. It's getting serious again.

So, fin de siècle, I've been playing around with my solitaire thingee. I fear that in the near future the poor beast will become neglected. No...that's not right...what's the word that I want? Oh yes, broken, utterly broken.

I've built many a poor beast over the years, all have proved flaky, shoddy, ill-considered and, in-the-end, worthless. For once, this time, I've built something that has some legs [if only in my head]. I know this because I'm having to go out of my way to break the thing; usually this happens by default. On a simple opening.

[It also does some of the things that I meant it to do.]

I don't want to destroy it. But destroy it I shall if I hopelessly-hack-at-it during the few idle moments that I'll have between now and October. Version control is all very well—you can rewind the code. What you can never do is put yourself back into, "knowing what you [meant yourself to be] do[ing]". If you have no documentation, that is.

So I've made a decision: this weekend I'll collate all the pages (bits of paper), that I can scavenge from the scattering of the floors, into a specification, I'll re-do my to-do list, I'll write down my feature requests, I'll make a plan, I'll finish the tests, I'll make sure that the Javadoc makes sense. I'll do what I should have done.

So that, at moments of stress, when maths hurts and I seek the balm of code, I might, do something useful.

Won't, won't and won't.

Permalink 2 comments (latest comment by Neil Anderson, Wednesday, 11 Jan 2012, 21:56)
Share post
neil

fork

Visible to anyone in the world
Edited by Neil Anderson, Friday, 6 Jan 2012, 22:01

When I, once-or-twice, attended my brick-university, there was this place called the grease-pit; where you could eat anything fried.

All I really remember about it is that they made the best ever easy-over eggs and a quote on the wall from the Naked Lunch. It was on-canvas, in oils, created by a proper art student and covered in a thin film of fat.

It was the, clarity on the end a the fork, quote [for, despite what everyone pretends, nobody has ever read that book]. Tonight that art-work/quote came flashing back to me.

I decided to add a wee-bit-more functionality to the solitaire thingee. My additions had caused a rippling-through-chaos-effect. The thing thralled.

But the additions worked, in their own way, during the process, I don't want to lose them. Perhaps a fork? This is a job for: version control; I hadn't committed.

The Hg documenation seems a bit vague...oh, branch, or clone?, still...? I can't use the it! Can I? When will I ever learn!?

I can't see what's at the end of my fork clearly.

Permalink 7 comments (latest comment by Neil Anderson, Wednesday, 11 Jan 2012, 16:44)
Share post
neil

been offline...

Visible to anyone in the world
Edited by Neil Anderson, Wednesday, 4 Jan 2012, 21:52

For the last couple of days I've been working on my solitaire thing, lying in bed and trying not to think about going back to work.

The solitaire thing: looks awful, the code is gnarly in too many places, there isn't much (any) error handling, the test-harness is patchy, the documentation is scant and the TODO list is huge. But the major components [bar one] are all now in place.

There are issues, but these are issues that shouldn't cascade—I can work on them without worrying that I will break-the-build. The main plumbing has been done, all I need to think about now is what the sinks, taps, bidets etc. will look like/do.

Well not quite.

The main reason that I started building the thing in the first place was that I was interested in the game itself. In studying it mathematically and studying AI. I'm still a while off doing that yet.

That's the big [bar one] that I don't have in place—the analysis module. [Although I'm not sure that it is going to be a module!] It's all very well being to open/save games, write the code for a new board/move/player and just have this happen, what I really need to do is...

There's a wee bit of me that just wants to forge ahead. I've built-in a few things into the model to help, and the model is set up so that it should be easy to build-in many more of such things. This would be a wrong thing to do.

So what I'm going to do is to fix the things that are flaky, every day when I'm tired of doing that I'll get out a pencil and paper and see if me not thinking about the main problems has been a help.

What's been done so far isn't too bad, but then after studying computing for three years now, it shouldn't be.

I'm in new territory [computer-wise], time to make ensure that I've built the foundations right, even if I'm thinking about the roof while I doing that.

 

Permalink 1 comment (latest comment by ROSIE Rushton-Stone, Thursday, 5 Jan 2012, 07:59)
Share post
neil

today

Visible to anyone in the world
Edited by Neil Anderson, Monday, 26 Dec 2011, 21:11

I've spent today lying around in my new P-Jays, listening to the wind's incessant howl and trying to hack Java.

I knew that I'd get here, to this point. to the place where I would have to start the thing all-over-again. Yes, the bloody solitaire thingee is f***ed.

That's what you get when, despite almost three years of work on, virtually, the same beast, you repeat the same mistakes. Mistakes that you knew were mistakes when you first made them.

Although I do have CASE tools I hate the damn things and won't open them up unless you are hoverring over me with an axe. I did sketch a few sequence diagrams.

But I think that I have a new in; do the plumbing first. So, for once, I'll upload a screenshoot.

Tomorrow is going to be another P-jay/Java day.

71a6133bbc9abf735b57f587e89608ab.png

Permalink Add your comment
Share post
neil

fags

Visible to anyone in the world
Edited by Neil Anderson, Wednesday, 21 Dec 2011, 19:24

I hacked away for a couple of hours today until it became obvious that I was flailing hopelessly. So I closed NetBeans and got out a notebook and pencil.

As soon as I did this it all began to come together. This often happens when you're coding—it isn't until you stop that you get an idea of the what it is that you should be doing. Of course, I know this, but I rarely use any of my knowledge.

Since my good idea [see my last post] I've been changing the architecture of the solitaire thingee. Somewhat of a silly thing to do without an entire new spec. When I started the thingee I did have a plan; but when you change said plan? Possibly a good idea to firm-up your concept of the new one? Not something that I did.

My trouble is that I play games [online Go at the present], you're not allowed to try things out, except inside of your own head; what I forget is that I spend rather a lot of my time being physical so that I can do the mental when it comes to games. Still I like to plan in the falible software of my head, despite knowing that this is an idiot thing to do.

That's why fags are important: you have to go outside; where you have to stop doing, and you have to think.

Permalink 2 comments (latest comment by ROSIE Rushton-Stone, Thursday, 22 Dec 2011, 08:10)
Share post
neil

jings

Visible to anyone in the world

What a mess. I was having trouble with loading a new game from file; it was reading all right, it just wasn't displaying. A realization dawned that I hadn't thought this through properly. Which lead me into having an idea.

Ideas are an anathema when you're actually coding—by all means have them when you are absent from the click-face, don't entertain them when you can actually try them out for real. Especially when you're struggling with some other broken thing.

Utter mess.

What's worse is that I don't have the thing under version control—crinimal negligence for a coder, I might have branched if I had been, at least I would have had a chance to go back.

I know all this stuff, and yet again, and again, I get caught in the web of my own stupidity.

It is fixable, and the idea wasn't a bad one. But I'm cracking out Hg and doing some pencil and paper work before I get stuck in again.

 

Permalink 4 comments (latest comment by Chris FInlay, Friday, 23 Dec 2011, 21:30)
Share post
neil

nearly

Visible to anyone in the world

I spent a few hours today hacking the Java solitaire thingee, I'm close to a landmark. Which would be a human playable GUI the can store my games to disk.

Some of its internals are a wee bit iffy, the look/GUI is awful and I really do need to revisit the unit tests. Still I'm pleased on the whole.

Mostly what I'm pleased about, is that, for once, I did something well—I'd planned an Observer pattern, but plans and fulfillment are often strangers to one another. But when I plumbed the thing together today it worked [almost] seamlessly. What was particularly pleasing was that I could insert Objects [almost everywhere] and it still, just, worked. I'd meant this to happen, but such outcomes do not always occur in my experience.

I'm tempted to crash-on. That would be a wrong thing. In a couple of places my Objects didn't perform in the way that I'd expected them to, despite the tests that I'd written. As Phil W says, the first step is to, "write a failing test". I don't have much trouble writing failing tests, but I know what he really means—if you can write the test you can write the code; and you should write  the test before you write the code.

Anyway tomorrow I write the I/O. I think that I'm going to go for string [UTF-8] and XML. And possibly HTML. I won't be serializing any Objects any-time soon methinks.

 

Permalink 2 comments (latest comment by Neil Anderson, Sunday, 11 Dec 2011, 21:32)
Share post
neil

solitaire

Visible to anyone in the world
Edited by Neil Anderson, Wednesday, 7 Dec 2011, 21:32

We get into groups.

Well, I do.

Permalink 1 comment (latest comment by Roo N, Wednesday, 7 Dec 2011, 22:23)
Share post
neil

solitaire

Visible to anyone in the world
In my madness I've decided to air my thoughts about solitaire. This may prove to be a trial to both me and you, my gentle reader. Still done now.
Permalink Add your comment
Share post
neil

seperation of concerns

Visible to anyone in the world
Edited by Neil Anderson, Sunday, 4 Dec 2011, 19:15

Today I wanted to stay in, but my wife dragged me out to exercise, "her human right to make-up". We came home cold and penniless. So I did a bit of coding.

I had a problem, which I will explain thus: we have an implementation of a board [which is part of the Model] that we wish to have the View to advertise, and the Controller to know about. Not too difficult you'd think, we use an enum to tell the view what options are available. But then the Controller has to keep up with the changes...

Or does it? And even if it does do we want to hard-code the Controller?

[Board is an Abstract Class, neither the controller nor the Vew should care about what the thing actually is; but as a board maker how do I tell the others that there's a new one? And do they have to alter their code?]

My first-thought was that I could add some methods to an enum, didn't work. But you can wrap a Class around said enum thingees. Throw in some methods and we might be on the right track. 

What I came up with is a class that exposes an enum of what's available and copes with, the inevitable, switch. You send me a switch, I'll send you an instance of what you want if you send me a String.  

public class Boards {
    private enum AvailableBoards {
        ENGLISH,
        FRENCH
    }
    public static Board getBoard(String board) {
        AvailableBoards available = AvailableBoards.valueOf(board);
        Board brd = null;
        switch (available) {
            case ENGLISH:
                brd = new English();
                break;
            case FRENCH:
                brd = new French();
                break;
        }
        return brd;
    }
}

Not finished, indeed I have a burning tree and there are several returns that need to be crafted better.

Still I think that a Class like this [at the top of a package] is a self-documenting boundary for the package. It reminds me of the [rarely-seen] javascript .config.

Permalink 5 comments (latest comment by Neil Anderson, Tuesday, 6 Dec 2011, 19:59)
Share post
neil

dependency

Visible to anyone in the world
Edited by Neil Anderson, Friday, 2 Dec 2011, 19:10

At some point in any project you are going to begin hacking; Objects are beginning to know a wee bit too much about each other, we are playing pass-the-parcel with said-same and we keep having to re-visit them to add, "positively the last method".

In short you are starting to create an Italian staple: spaghetti. And you are probably adding a piquant sauce to your error.

It doesn't matter how carefully you planned, it doesn't matter how well it looked when you drew the diagrams, it doesn't matter about your elegant proficiency with the CASE tools. You will stuff up—you'll start balling string [lower-case] into a weevil's-nest of knots. 

At this point you need to step back and plan again.

The problem is that the we think that 'our thing' is working. This is a snare, a deceit and a trap of our arrogance. Working in what sense? That it's passing the unit tests? Or that your end-users can use it [when did we care about them?], or, worse, that you can use it. Bad code is bad code. Accept that you are going to write wrong; learn to feel when you're doing that.

We don't start out to write crappy code, but write it we shall and will, and if we don't grok the moment[s] when we start to do it we will always do so. Coders need a reset: we should know when we when need a re-think of our initial mal-assumption. For such moments will come. In their droves.

My personal test is that if I change a Class and it burns the tree in a place I didn't expect it's time for serious thought.

Actually that's not my only test, there are many [if I'm starting to chain too much I get worried; my reason for disliking JQuery , but there are loads if you look] You have to develop your your own Zen in this matter.

Yup, I'm there with my Solitaire thingee.

 

Permalink 4 comments (latest comment by Neil Anderson, Sunday, 4 Dec 2011, 20:57)
Share post
neil

i have to be a good boy

Visible to anyone in the world

So I'm trying to be a good boy...

Due to extreme penuary I'm going to have to give up on the drinking and excess for the next couple of weeks. Horrid, but has to be done alas.

So I might as well make the best of a bad job and try to be good in some other areas of life. That other area would be Java.

So tonight I created a load of empty method bodies and rather too many failing tests for my liking. [I think that I have all the classes that I need—we'll see.]

I've also done some reading about MVC and I'm attempting an attempt at it.

This is probably all going to go badly wrong. That's OK, because it doesn't really matter. As long as I have some fun.

[Anyone who has ever coded knows that fun isn't something that you have—you do get something out of it, but it isn't fun.]

Permalink 4 comments (latest comment by Neil Anderson, Friday, 18 Nov 2011, 18:33)
Share post
neil

coding again

Visible to anyone in the world
Edited by Neil Anderson, Saturday, 12 Nov 2011, 21:32

Today I've spent around six hours hacking Java: good. I'm recreating my solitaire programme...not so good [I can hear some people screaming at this point.]

I don't intend to delve into history here, those of you who have been reading this blog for some time will know of this thing of old. [And Phil & Robb, who actually managed to get a working app. together last year, must be screaming the loudest.] Still.

I had a thought; what about 3-D solitaire? It was the book on partial differentiation that gave me the idea. Indirectly.

I went to bed very early last night, much drink had been taken. Thus I awoke early. I was lying in bed trying not to think about going to work, so I tried to visualize what was going on with partial differentiation. I won't bore you with my suppositions, they will be wrong, but it did get me thinking about how two 2-D solitaire boards might interact. Hence 3-D solitaire.

When I got to work [work] I started thinking about how this could be studied [some form of lego will build the board]. Which lead me to open up one of my many solitaire programmes. I thought that I could see a way to do it better...

I'm probably wrong, but if the only thing that I manage to achieve is to get me programming again then this is still gain territory. As long as I'm coding something I'm at least alive, to a certain extent.

 

Permalink Add your comment
Share post
neil

Colouring

Visible to anyone in the world
Edited by Neil Anderson, Saturday, 30 Jul 2011, 12:38

I should be doing analysis if I'm doing maths, but I've become obsessed by colouring problems. I'm determined to find a general algorithm.

The problem involves a lot of subtleties; take, for example a hexagon, how many ways are there to divide it into 2, 3, 4, 6, equal areas, can we divide into 5? Are primes involved here?

For the first time in ages I'm working at something for myself, and working at maths with a view to writing a programme. This is good.

I won't manage this, but sometimes the exercise is more important than the result. And in the back of my head I'm thinking solitaire.

Permalink 2 comments (latest comment by Neil Anderson, Sunday, 31 Jul 2011, 05:52)
Share post

This blog might contain posts that are only visible to logged-in users, or where only logged-in users can comment. If you have an account on the system, please log in for full access.

Total visits to this blog: 252654