Earlier this year, I had a severe epileptic seizure. When I finally came round, it was a week later. I was in the intensive treatment unit of my local hospital. The medics, I learned, were concerned that I might have suffered some brain damage. There was a possibility that I wouldn't even know who I was.

Luckily, I have always had a strong - some would say overdeveloped - sense of who I am. So when I drifted back to full consciousness I instantly recognised my old self. But I soon realised that I had no memory of anything that had happened during February and March, the months leading up to the seizure.

When I returned home, it took a while to work out which key fitted which lock on the front door. Once inside, there was some new furniture that I didn't recognise and some flat-packed goods still in boxes. When had I bought this stuff? Truly, this was a strange new world. Disorientating - but in its own way rather exciting.

Then I got a phone call. "Mark, are you still up for writing a new play for every day of the Edinburgh festival?" "Er, yeah, sure," I said, and carried on identifying what the mysterious flat-packed goods were. What was that phone call all about? Who was this crazy person who had agreed to write 17 new plays? I started to quiz friends. Did anyone know what was going on? Finally, someone explained: "You came up with the idea of writing a premiere for every day of the festival. The Traverse theatre is going to present them as staged readings at breakfast time every morning. The hordes of fabulous directors and actors working in Edinburgh during August will be invited to take part."

I weighed up the situation. I'd just had a major medical incident. Surely I should be pulling out of this insane undertaking? But then my doctor advised me it would take me several months before I could expect to be fully physically active. What was I going to do with my time? Watch Richard and Judy and eat lots of cakes? Or be a prolific dramatist? A hasty calculation told me that the latter would be better for my health.

I think - I'm guessing, since I have no recall - my original intention might have been to write all the plays actually in Edinburgh during the festival. I've always been fascinated by the idea that the dramatist might have a relationship with his or her audience that mirrors the one a novelist such as Dickens must have had with his readers. Publishing in serial form, keeping just one step ahead of his audience, spinning a constant stream of new material out of thin air, feeding on the audience's hunger - some of them hoping Little Nell would live, some wishing the little bore would die.

But, working out the practicalities of producing a play a day, I realised that this would result in plays that were either very short or very bad - and possibly both. And so I decided not to inflict this on Edinburgh Fringe-goers. Instead, I've been spending the past three months writing a series of 20-minute plays, with just the final three in the cycle to be written during the festival. But with each play written this summer and the breakfast reading being the premiere outing of each piece, there's bound to be a sense of immediacy to the event.

In total, I'm producing five and a half hours' worth of theatre. Having to write so much, so quickly has been a fascinating experience. As a playwright, you get used to looking for a new subject every year or so. But for this project, I've had to find something new to write about every few days. It's made me very receptive. I feel as if a few layers of protective skin have been peeled away. My own experiences, those of friends and neighbours, events in the news, the stuff of my dreams: all of it has been soaked up to feed the great beast that every day is demanding more material.

What is emerging is a cycle of plays that I'm calling Shoot, Get Treasure, Repeat. Each 20-minute play is a stand-alone piece, but they are all in some way about the war on terror. Key images and phrases are repeated throughout the cycle. My aim was to create an epic out of a series of small encounters. It feels as if I'm getting there. The next few weeks in Edinburgh will be the test.

Today I rehearse the first of the plays. Tomorrow is our first performance. Maybe you'll be there, but if not you can read short extracts from some of the plays in the Guardian and longer extracts on the Guardian website every day. There's still a huge amount of writing to do. But I'm enjoying it enormously. I'll never get the memory of last February and March back. But this summer I've created an epic. Who needs memory when the imagination can work so hard?