Tidak Ada Deskripsi

Zoadian 30edcc3765 added icons 10 tahun lalu
media 30edcc3765 added icons 10 tahun lalu
.gitignore 1cba6fefd4 Initial commit 10 tahun lalu
LICENSE 1cba6fefd4 Initial commit 10 tahun lalu
README.md cc8448bb49 implemented cycle duration calculation and precondition checking 10 tahun lalu
ccsim.cpp 30edcc3765 added icons 10 tahun lalu
ccsim.h 30edcc3765 added icons 10 tahun lalu
ccsim.pro 30edcc3765 added icons 10 tahun lalu
ccsim.pro.user 30edcc3765 added icons 10 tahun lalu
ccsim.qrc 30edcc3765 added icons 10 tahun lalu
ccsim.ui 30edcc3765 added icons 10 tahun lalu
debugwidget.cpp d1119ad649 ui improvements 10 tahun lalu
debugwidget.h 50a3732950 more editor stuff 10 tahun lalu
debugwidget.ui d1119ad649 ui improvements 10 tahun lalu
instruction.cpp f8aeba8b6f better parsing 10 tahun lalu
instruction.h f8aeba8b6f better parsing 10 tahun lalu
main.cpp 70d6acafc7 began to implement proper ui 10 tahun lalu
mainwindow.cpp 70d6acafc7 began to implement proper ui 10 tahun lalu
mainwindow.h 1c1dd36620 loading program from file working 10 tahun lalu
mainwindow.ui 1ab2b2c534 button to load program 10 tahun lalu
parse.cpp f8aeba8b6f better parsing 10 tahun lalu
parse.h f8aeba8b6f better parsing 10 tahun lalu
playfield.cpp 83cffed98f remote access cycle cost; removed warnings 10 tahun lalu
playfield.h d1119ad649 ui improvements 10 tahun lalu
program.cpp 83cffed98f remote access cycle cost; removed warnings 10 tahun lalu
program.h 83cffed98f remote access cycle cost; removed warnings 10 tahun lalu
simulator.cpp 83cffed98f remote access cycle cost; removed warnings 10 tahun lalu
simulator.h 83cffed98f remote access cycle cost; removed warnings 10 tahun lalu
syntaxhighlighter.cpp 50a3732950 more editor stuff 10 tahun lalu
syntaxhighlighter.h 0653613748 more work on proper ui 10 tahun lalu
wgtcodeeditor.cpp 50a3732950 more editor stuff 10 tahun lalu
wgtcodeeditor.h 70d6acafc7 began to implement proper ui 10 tahun lalu
wgtlinenumberarea.cpp 70d6acafc7 began to implement proper ui 10 tahun lalu
wgtlinenumberarea.h 70d6acafc7 began to implement proper ui 10 tahun lalu

README.md

Code Contest Simulator - ccsim

A programming game based on RoboCom.

Instructions

Command Cycles InstSet Mobile Description Failures
CREATE a, b, c 100+50*a+25*b+120*c 2 0 Create a new pogram with:
instSet a; b banks; c mobile
IS, IP
MOVE 20 0 1 Move the program one field
DIE 1 0 0 Destroy the program DI
TRANS a, b 14+numOfInst 1 0 Transfers bank a to bank b in the program in front IS, IB
RTRANS a, b 14+numOfInst 1 0 Transfers bank afrom program in front to bank b IS, IB
TURN a 8 0 0 Turn by 90°;
Turn right if a >= 0 else left
JUMP a 1 0 0 Realtive jump for a instructions
AJUMP a 1 0 0 Jump to instruction a in current bank
BJUMP a, b 2 0 0 Jump to instruction b in bank a IB
SCAN #a 8 1 0 Scan 1 field in front.
Set a to:
0 if empty;
1 if enemy;
2 if friend
FARSCAN #a, #b, c 10+3*c 1 0 Scan n fields in front.
Set a to:
0 if empty;
1 if enemy;
2 if friend;
Set b to distance
IS, IP
SET #a, b 2 0 0 #a = b
ADD #a, b 2 0 0 #a = #a + b
SUB #a, b 2 0 0 #a = #a - b
MUL #a, b 2 0 0 #a = #a * b
DIV #a, b 2 0 0 #a = #a / b DZ
MOD #a, b 2 0 0 #a = #a % b DZ
MIN #a, b 2 0 0 #a = min(#a, b)
MAX #a, b 2 0 0 #a = max(#a, b)
RANDOM #a, b, c 1 0 0 #a = b + (rand() % (c - b + 1)) IP
IF a, b 2 0 0 Execute next instruction if a == b else skip it
IFN a, b 2 0 0 Execute next instruction if a != b else skip it
IFG a, b 2 0 0 Execute next instruction if a > b else skip it
IFL a, b 2 0 0 Execute next instruction if a < b else skip it
IFGE a, b 2 0 0 Execute next instruction if a >= b else skip it
IFLE a, b 2 0 0 Execute next instruction if a <= b else skip it
INIT a, b 2 0 0 Start a new task at bank a instruction b IB
BREAK 1 0 0 Stops other tasks, gives current task 100%
RESUME 1 0 0 Resume all other tasks suspended by SEIZE
SEIZE 1 0 0 Stops other tasks, gives current task 100% until RESUME
SLEEP a a 0 0 Suspend current task a cycles
QUIT 1 0 0 Stops current task UE

Failure codes

Code Description
DH Data Hunger: Bank 1 empty and executed
DZ Division by zero
IB Invalid bank number
IS Higher Instruction Set required
MO Mobility required
DI DIE executed
IP Invalid parameter
UE Unemployment: No more tasks left in a program

Variables

Local Variable mutability Description
#1 .. #20 mutable The twenty all-purpose standard integers. They cannot be accessed by remote programs
#Active mutable Determines if a current program is active (positive values) or not (zero or negative)
$Banks immutable The number of banks which the current program has
$InstrSet immutable The instruction set which the current program has
$Mobile immutable Tells if the current program is mobile
$Age immutable The current program's age in cycles
$Tasks immutable The number of tasks in the current program, incl. sleeping or seized tasks
$Generation immutable The generation of the current program
$ID immutable Identifier which is equal for each program of the same team
and initialized to random when the game is started
Remote Variable mutability Description
%Active mutable Determines if a remote program is active (positive values) or not (zero or negative)
%Banks immutable The number of banks which the remote program has
%InstrSet immutable The instruction set which the remote program has
%Mobile immutable Tells if the remote program is mobile
%Age immutable The remote program's age in cycles
%Tasks immutable The number of tasks in the remote program, incl. sleeping or seized tasks
%Generation immutable The generation of the remote program
Global Variable mutability Description
#Pub mutable Public variable which is accessible from all programs on the field
#Team mutable Public variable which is accessible from all own programs on the field
$Own immutable The number of friendly programs on the board
$Others immutable The number of enemy programs on the board
$Fields immutable The size of the board
$Time immutable The game time in cycles
$Timeout immutable The automatic simulation timeout in cycles

Execution Model

Programs are evaluated oldest to newest. Order of the first program is random. Each cycle only one task is executed per program. Tasks are organized in a ring like structure. At the beginning of each cycle the next non paused task is made the active one.