Skip to content

Visualization

gmolin edited this page Apr 17, 2020 · 2 revisions

Visualization is a bonus part of the Corewar project, so there are a lot of options for its implementation.

In this section, we will look at the visualization approach that was provided to us as an example.

! Visualizer

Each of the players who participate in the battle should have its own color.

The champion’s executable code will be painted over with this color during the initialization of the arena, as well as those sections of memory that will be recorded by the carriages belonging to it using the statements st and sti.

The player’s list includes a carriage, which is placed at the beginning of his source code before the battle, as well as all carriages that it spawns with the use of the fork and lfork statements.

Pieces of memory that are not painted in the colors of one of the players will have a default color of gray.

#Carriage

Carriages stand out in a special way on the arena. The cell on which the carriage is currently located is highlighted as follows: background - the color in which the code in the cell is painted; contents are black.

It is important that the background displays the color code of the cell itself, not the carry. That is, the carriage generated by the "green" player, once on the blue field, will glow blue.

Updated sites

Also, the memory that was modified by the st and sti statements is specifically color-coded. The contents of these cells will be bold for the next 50 cycles.

statement live

In addition to updated sections of memory, the live statement is also highlighted.

The next 50 cycles, the cell that contains the code for this statement will be highlighted in the following way: background - color from the carriage that performed this statement; the contents of the cell will be white and bold.

By the way, the display of the performed live statement has a higher priority than the carriage display. Therefore, when superimposing these two entities, the carriage will not be visible.