-
Notifications
You must be signed in to change notification settings - Fork 0
Visualization
Visualization is a bonus part of the Corewar project, so there are a lot of different implementations.
We will look at the original visualizer as an example. It is coded with the help of library Ncurses

Each player has it's own color. The executable code of the champion will have it's color. The cursors (processes) which store player's number in their reqistry 1, will write to the board with the champion's color using operations st and sti.
Memory sectors that are not colored by champions, have default color - grey.
To show current position of the cursor, background of cell is colored in player's color and the value is of black color.
Important that the background is of color of the cell and not of cursor. That is, a cursor created by the green player will be displayed with color blue, if it is in the blue cell.
Also newly overwritten (with operations st and sti) memory sectors will be bold for the next 50 cycles.
In addition to the newly overwritten memory, event of opertation live is highlighted.
After live is performed by a cursor, the cell containing the code of this operation will be highlighted as follows: cell background - with color of the cursor, and the code - with the white color and bold.
Highlighting operation live has higher priority than showing the carriage's position.