{"id":15751416,"url":"https://github.com/remram44/corewar2","last_synced_at":"2026-05-16T00:37:29.057Z","repository":{"id":66117761,"uuid":"2128599","full_name":"remram44/corewar2","owner":"remram44","description":"A simple Corewar game written in C++ with Qt.","archived":false,"fork":false,"pushed_at":"2021-01-20T03:22:52.000Z","size":25,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-30T23:24:22.273Z","etag":null,"topics":["assembly","corewar","qt-gui"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/remram44.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-07-30T12:35:39.000Z","updated_at":"2021-10-30T01:55:38.000Z","dependencies_parsed_at":"2023-02-20T17:31:01.589Z","dependency_job_id":null,"html_url":"https://github.com/remram44/corewar2","commit_stats":{"total_commits":11,"total_committers":2,"mean_commits":5.5,"dds":0.2727272727272727,"last_synced_commit":"9448c18901909c49d05ce7fdb56ef9dd58122709"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/remram44/corewar2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remram44%2Fcorewar2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remram44%2Fcorewar2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remram44%2Fcorewar2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remram44%2Fcorewar2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remram44","download_url":"https://codeload.github.com/remram44/corewar2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remram44%2Fcorewar2/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269373109,"owners_count":24406321,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assembly","corewar","qt-gui"],"created_at":"2024-10-04T07:01:40.786Z","updated_at":"2026-05-16T00:37:28.999Z","avatar_url":"https://github.com/remram44.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"Corewar2\n========\n\nContents\n--------\n\n* [Introduction](#introduction)\n* [Corewar](#corewar)\n* [Language](#language)\n* [Rules](#rules)\n* [Examples](#examples)\n\nIntroduction\n------------\n\nCorewar2 is a very simple Corewar clone, written in C++ with [Qt](http://qt.nokia.com/). The language used was created by myself for this purpose and named CWA (for CoreWar Assembly). It's a simple assembly language, with 7 instructions.\n\nCorewar\n-------\n\nThe idea of Corewar is simple: programs fight in a virtual memory arena, the last program running wins. You can make other programs crash by making it execute an invalid instruction (by overwriting its code).\n\nLanguage\n--------\n\nThe programs are CWA files, which are compiled and placed in memory at the beginning of the round. To keep things simple, the memory is a list of \"cells\", any of which capable of storing **data** (a number) or **an instruction**. Instructions execute one at a time, one per program per turn. Memory is cyclic, going over one end transparently comes out the other.\n\nCWA files contain one instruction per line, with comments after a semicolon ';'. Each instruction is either like `DAT \u003cval1\u003e`, or `\u003cINSTR\u003e \u0026\u003cval1\u003e \u0026\u003cval2\u003e` where `val1` and `val2` are numbers and `\u0026` is one of the characters `#` (hash sign), `$` (dollar sign) ou `@` (at sign) which correspond to the different addressing modes. There are no registers, all data is in memory.\n\nArguments can be of three sorts. They are written with a prefix character then a number (positive or negative). The prefixes mean:\n\n* `$`: immediate value. The value to use is the number written. Example: `$-12`\n* `#`: address. The value to use is the one found at the address given, relative to the current instruction's position. So `#0` means the current instruction, `#-1` means the previous one, etc.\n* `@`: indirect address. The value to use is at the (indirect) address found at the given address. Note that the indirect address is also relative to the current instruction, not its own location. For example, `@1 ; DAT 3 ; DAT -3 ; DAT 4` references the last cell which contains `DAT 4`.\n\nInstructions can take one of two arguments. Not all types are necessarily accepted, for example, `JMP` needs an address (no immediate value), same thing with `MOV`, `ADD`, and `SUB`. The instructions are:\n\n* `DAT \u003cnumber\u003e`: A numeric value. If a program reaches a cell containing a `DAT`, it gets terminated. Note that the `number` cannot have a prefix.\n* `ADD \u003csrc\u003e \u003cdst\u003e`: Add `src` to `dst`. `dst` cannot be an immediate value..\n* `SUB \u003csrc\u003e \u003cdst\u003e`: Subtract `src` from `dst`. `dst` cannot be an immediate value.\n* `MOV \u003csrc\u003e \u003cdst\u003e`: Copy from `src` to `dst`. This instruction can copy both data and instructions. `dst` cannot be an immediate value.\n* `IFE \u003ca\u003e \u003cb\u003e`: Compare `a` with `b`. If `a` is equal to `b`, the next instruction is executed, else it is skipped.\n* `IFL \u003csrc\u003e \u003cdst\u003e`: Compare `a` with `b`. If `a \u003c b`, the next instruction is executed, else it is skipped.\n* `JMP \u003cdst\u003e`: Jump to the address `dst`. `dst` cannot be an immediate value.\n* `FORK \u003cdst\u003e`: Start a thread, which executes at the address `dst`, while we continue with the next instruction.\n\nRules\n-----\n\nA program is terminated if it executes an invalid instruction (for example a `DAT`, or an instruction with an invalid argument type). Furthermore, a memory cell is considered to belong to the last program which wrote to it. If a program executes a memory cell that doesn't belong to it, it is *considered to be* the program that wrote it. This means if all remaining programs are executing code from your program, you win.\n\nIf the `FORK` instruction is enabled, it allows a program to create multiple threads. However beware that threads are sharing execution time. This means that a program with 3 threads will see each of its thread execute at one third of the speed a of program which never uses the `FORK` instruction.\n\nExamples\n--------\n\n### Steamroller\n\nThe steamroller is the simplest possible program. It only contains one instruction, which copies itself at the next memory cell. It doesn't crash other programs, once overwritten by the steamroller, they simply start executing the single instruction themselves (which does not cause the steamroller to move faster). Written in CWD, this instruction reads:\n\n```\nmov #0 #1 ; steamroller\n```\n\n### Bomber\n\nThis example, a little more complex, loops to write `DAT 0` over the whole memory following it.\n\n```\nadd $1 #3 ; increase the counter\nmov $0 @2 ; write a DAT 0 to the pointed address\njmp #-2   ; back to start\ndat 2     ; counter\n```\n\n### Anti-steamroller\n\nThis program only counters steamrollers, it doesn't attack. It places a `DAT 1` a little way back and checks for it regularly. Once it is overwritten, it kills the steamroller that we assume overwrote it, by writing a `DAT 0`:\n\n```\nmov $1 #-4 ; place the DAT 1\nife $1 #-5 ; checks that it's there\njmp #-1    ; it's still there, loop\nmov $0 #-5 ; it was overwritten, write two DAT 0 to kill a steamroller\nmov $0 #-6\njmp #-5    ; then loop\n```\n\n### Spammer\n\nFor this example, the `FORK` instruction needs to be enabled. This program sends steamrollers to many memory locations. It may overwrite itself with a steamroller.\n\n```\nadd $128 #5 ; increase counters\nadd $128 #5\nmov #5 @3   ; copy the steamroller\nfork @3     ; start the steamroller\njmp #-4     ; loop\ndat 4\ndat 3\nmov #0 #1   ; instruction for the steamroller\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremram44%2Fcorewar2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremram44%2Fcorewar2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremram44%2Fcorewar2/lists"}