Cloud computing is a concept that is in use since late 2000s related to consumption of distributed computer resources, namely servers and networks for data storage and access. In the paper we examine knowledge-based algorithms for agents that have access to a resource center to use some of available discrete resources. We assume that resource items are passive, they form a cloud, any item can be lend on demand to any agent if and only if there is no races for this item with other agents. All agents are rational and can communicate with each other in P2P-manner, negotiate, flip and swap (change intentions) so that all flips/swaps always must be rational for participating agents. The problem is to design a multiagent algorithm, which allows each agent sooner or later to access some resource item. We present a uniform algorithm scheme and then specialize for the following particular problems: Robots in Space and Rational Agents at the Marketplace.