I have books on the subject also. The Dey was not unaware of the situation, he had the option at any time of agreeing to the Anglo-Dutch demands. He could have sent out a boat under a flag of truce at any time up to the opening shot, there was little wind and the Anglo-Dutch fleet was moving into position quite slowly. His fleet, consisting of an number of frigates and corvettes, was anchored in a defensive formation in the harbour and was manned. Again, his batteries, extensive as they were, were manned and so were ~90 small vessels which were to be used for boarding the enemy ships. The Dey was fully aware of the great likelihood of combat and thought that he could beat the fleet off. This is obvious from the fact that he ended up with his city partly demolished and burnt, his fleet destroyed and still had to meet the initial demands for freeing slaves and paying compensation. If he did not have confidence in his defences he would have just agreed to the demands from the first and consequently would have retained his other assets intact. The Dey was not caught napping by the Anglo-Dutch fleet, he just gambled on the conflict going his way and lost. He was anything but an unsuspecting and innocent 'sheep in the fold'.