Giter VIP home page Giter VIP logo

jiricodes / corewar Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 17.76 MB

This project involves creating a virtual arena, and having simplistic-language programs fight each other. It involves getting familiar with VM concept (with the instructions it recognises, the registers, etc.) and compilation problems of an assembly language in bytecode.

C 38.80% Assembly 58.99% Shell 0.50% Makefile 1.08% C++ 0.43% Python 0.19%

corewar's Introduction

About

Aspiring software engineer with a robust soft skills base gained in almost decade as customer service professional and with former education within international business and logistics field.

Currently I’m working full-time as Security Researcher at Ericsson.

Also I'm practicing and developing my skills at Hive Helsinki through coding various projects and algorithms, subsequently it also positively affects my rigour, problem solving and time management.

Hive Helsinki

Hive Helsinki is a coding school following 42 educational model.

Contact

Visit jiricodes.com

corewar's People

Contributors

artemso avatar jiricodes avatar jmakela42 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

corewar's Issues

ASM not compiling with flags

ASM doesn't compile with required flags

sources/asm/encoding.c:92:31: error: unused parameter 'target' [-Werror,-Wunused-parameter]
char    *save_name_comment(char *target, int source_fd, char *line)
                                 ^
sources/asm/encoding.c:116:11: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
        else if (line[cnt] == '\"')
                 ^~~~~~~~~~~~~~~~~
sources/asm/encoding.c:118:33: note: uninitialized use occurs here
        return (remove_trailing_spaces(ret));
                                       ^~~
sources/asm/encoding.c:116:7: note: remove the 'if' if its condition is always true
        else if (line[cnt] == '\"')
             ^~~~~~~~~~~~~~~~~~~~~~
sources/asm/encoding.c:94:11: note: initialize the variable 'ret' to silence this warning
        char    *ret;
                    ^
                     = NULL
2 errors generated.
make: *** [objects/asm/encoding.o] Error 1

Dump

-dump nbr_cycles

at the end of nbr_cycles of executions, dump the memory on the standard output
and quit the game. The memory must be dumped in the hexadecimal format with
32 octets per line.

asm labels should ONLY consist of LABEL_CHARS

allowed characters are defined in op.h as: LABEL_CHARS

issue example:

.comment "b"
.name "a"
# paskuda tvar
jopa&:
live %1

should spit an error.

original behavior example:
Lexical error at [4:5]

Assembler creates .cor file upon Error

If Assembler exits with error it still creates an empty .cor file.

Suggest to move relevant creation lines of target file from init.c initialize_asm function to to_bytecode.c write_champion function.

ft_error_exit

Needs to be replaced with a function that writes the error to stderr fd

Norminette (vfx_utils)

Norme: ./sources/vm/vfx_utils.c Warning: /Users/jnovotny/Hive/corewar/sources/vm/vfx_utils.c may not compile or is invalid for some reasons.

Needs to be tested on schools mac.

Operation "live"

if live argument is a valid player, it needs to save it to core->last_player

op "fork"

After cloning a carriage, it should be prepend to the car_list as subject mentions:

The instructions ending at the same cycle will execute themselves in in decreasing order of the processes’ number.

Therefore newest carriage should be always at the beginning of the list

Winner announcement and exit

  • when reporting "live" the vm needs to check if given argument is a valid player, if yes saves his index in core->last_live
  • when game ends the winner is announced and program exits cleanly
  • what if none reports live?
“Player X (champion_name) won”

Global variable oplist

According to norminette any used global variable has to be prefixed with g_. So the global variable

static const	t_oplist	oplist[16];

in oplist.h needs to be changed to:

static const	t_oplist	g_oplist[16];

"live" announcement

For each valid execution of the live instruction, the machine must display:

“A process shows that player X (champion_name) is alive”.

op "lfork"

After cloning a carriage, it should be prepend to the car_list as subject mentions:

The instructions ending at the same cycle will execute themselves in in decreasing order of the processes’ number.

Therefore newest carriage should be always at the beginning of the list

asm segmentation fault

asm segfaults if either .name or .comment is missing completely.

example:

.comment "comment"

# paskuda tvar
live %1

Carry Flag

Needs investigation whether works properly

jani's slack msg:

I think there might be an issue with the carry flag as well. I'm running championship 2014 champs to learn stuff and many of them just skip zjmp instructions in their code and end up doing nothing. I don't know if the rules and carry flag changed over the years but for example 2014/gleger/Machine_gun.s has multiple obvious zjmp loops but the carriage just gets away during the game.

asm .name and .comment MAX LENGTH

In asm, the .name string and .comment string should be limited by PROG_NAME_LENGTH and COMMENT_LENGTH respectively.

original asm response example:
Champion name too long (Max length 128)

Error Management

In case of an error, you must display a relevant error message on the standard error
output.

.s ending with \n

Ensure that the (every and last) operation in .s must always end with a newline for a correct translation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.