Main Assembly

Main Assembly

评价数不足
Some Programming Tips
由 Ownedpilot 制作
This is a simple short guide of what should go into your brain when you program. Some principles may also apply to other languages, games and programming interface.
   
奖励
收藏
已收藏
取消收藏
Disclaimer
This guide do not contain any specific algorithms of how to do certain things. This guide is more focused on tips that helps programming in Main Assembly and the thinking process a player should have when doing programming. I am not the best programmer in this game but I do wish to share my experience on programming in Main Assembly.
Part 1: Simple things
Pressing P button on any bot would give access to the programming page. However, the default programming page is limited. In addition, the default connection line style is subway style which will overlay on top of each other when the programming gets complicated. Therefore, I always turn the advanced mode on and subway style off. These two switches are located at the lower left corner of the programming page. With advanced mode on, more useful functions would be revealed which can lead to simpler programming and more powerful logics. Not using the subway style allows easier code reading which can help tracking the logic of your own build or learning the coding of others. In addition, such format can help with packing the code which can reduce the number of CPU required.
Part 2: What to think when programming.
Start Programming
When most people start programming in Main Assembly, things can get very intimidating as most people would have no idea how to even start. The simplest and easiest thing to do in this situation is to simply hook the input directly to the parts that needs to be controlled. For some builds, that is all that need to be done to get them working. However, if the build is unstable, or have some functionalities that need to be accomplished or some performance improvement is desired. We might need to add additional blocks. This brings us to the second point.

Keep Track of Values
The purpose of any computer program is to manipulate values. This fact also applies for the controllers in both Main Assembly and real life controllers. Therefore, keeping track of values that is being sent between nodes is the key to develop a good algorithm. A good programmer may be capable of tracking values in his/her head. But it never hurts to use the debug node to visualize the values that are being sent out of a node. Debug node is also crucial for making a functional UI. If tracking the node within the game is too difficult, it is always beneficial to write out the formulas of the control algorithm before implementing in the game. This is a common practice for top programmers such as Azotic who is famous for implementing super sophisticated programs.

Read Descriptions and Test the Nodes
Understanding the tools available is another key to great programs in Main Assembly. To achieve this goal, reading the node description carefully is a requirement. If the node description is either unclear or hard to understand, it is always good to test what that specific node do before implementing. And if that still does not help, asking questions on the Discord server would always help.
https://discord.com/channels/596686647345676288/718374504103149678

Minimize the Number of Nodes
Solving a problem may be easy but solving a problem with the most optimized solution may be difficult. Minimizing the number of nodes is important because each node takes up valuable computational resources which can impact the performance of the simulation. Therefore, if it takes a complex algorithm to do a simple thing, consider checking the nodes that are available to see if any node can replace a chuck of nodes. For example, if an input is being multiplied to a constant and added to another constant to scale the input properly, consider using the scaling block which performs all the functions that is being described here.
Conclusion
In all, each people programs differently but the mentality is the same. A programmer would never be a good programmer unless he practices the art of programming. Therefore, I suggest that you all try some new algorithms from time to time. Perhaps you will find that you are a better programmer than you think.