Energy consumption management and optimal use of node resources are key elements in the Internet of Things. In this study, a framework based on cognitive topology control that acts based on the LR−I learning automata and game on it, has been used to control power, channel and contention windows and to create preventive behavior in the network. Due to the limitations of nodes in the Internet of Things, the transfer of learning automata processing to the cloud, fog and edge has been investigated to increase lifespan, reduce memory consumption and increase processing power. The communication was done based on IPv6 protocol and IEEE 802.15.4 standard. The nodes also used the uIP lightweight protocol stack and the RPL lightweight routing protocol. In order to use the sixth version of the Internet Protocol in the IEEE 802.15.4 standard platform, the 6LoWPAN protocol has been used to compress and convert headers. Computing on fog nodes has also been used to perform game calculations on automata. Finally, the Cooja simulator was used in the Contiki operating system to evaluate the efficiency of the proposed method, which showed the superiority of the proposed method in energy consumption, memory usage and processing power compared to other methods that control power and channel.