Jump to content
IGNORED

COMBAT XB COMPETITION


Vorticon

COMBAT XB Competition  

14 members have voted

  1. 1. Would you be interested in submitting an entry for that competition? (see below for details)

    • Yes
      9
    • No
      6

  • Please sign in to vote in this poll.

Recommended Posts

Hi all.

It's time for another Extended Basic programming competition. 

Most of you are likely familiar with the venerable COMBAT game on the Atari 2600, and I am proposing using that game concept to pit user programmed autonomous tanks against each other, paired 2 at a time, with the last surviving tank being the winner with the prize being a brand new in box C64 Mini console.

Here's the game field consisting of a 32x23 board with walls represented by character #101 and empty spaces by character #96. Tanks will be represented by sprites.

103324890_Combatfield.jpg.1807094e9f08e8a1b91b1741e0120045.jpg

 

 

Each competition entry will consist of a single subroutine in the format

 

SUB X,Y,DIR,X1,Y1,DIR1,CODE
...
SUBEND

 

with the subroutine being provided your tank's X,Y coordinates and its current direction DIR (1=up, 2=right, 3=down, 4=left) and it should return a numerical value CODE between 1 and 4 where 1=FORWARD, 2=TURN RIGHT, 3=TURN LEFT and 4=FIRE. The assumption is that the tank crews are buttoned up and so each tank can only see ahead inside a 45 degree cone, and if the opposing tank happens to be in you line of sight, then its current coordinates and direction will be provided in X1,Y1 and DIR1, otherwise these variables will be zero. Firing range is 8 spaces maximum. What happens inside that subroutine is up to you the programmer with the only limitation being that the screen should not be modified in any way. Each tank will be able to perform ONE action only per turn, and initiative will be randomized between the 2 opposing tanks. In order to avoid unfair practices, the sprite representing the opposing tank will be temporarily moved off screen so that its actual coordinates will not be known unless it is in your LOS.

The host program will handle all the graphics, animation, hit checks and score maintenance.  I will be providing a listing of the host program soon so you can test your subroutine (additional use instructions to follow).

Each fight will consist of 5 rounds, with the tank that scores a hit first winning the current round. 

 

Additional clarifications:

Each tank occupies 1 square on the field.

Tank rotations are in 90 degrees increments

You cannot backup, only move forward

There is no turn pass. You have to take an action each turn

In order to hit the opposing tank, the following needs to be satisfied:

  • You have to be within 8 squares of the opposing tank
  • The target needs to be visible within the FRONTAL 45 degree cone (90 degrees field of view with 45 degrees on either side of the tank midline)
  • Your tank is lined up on either a column or row with the target because the gun turret does not rotate and only points forward.

The host program will make the LOS calculations for you. If the opposing tank is visible to you, then the X1,Y1 and DIR1 variables passed to your subroutine will be <> 0. Otherwise the opposing tank is not visible.

In order to mitigate "campers", i.e. tanks that just lie in wait and don't move, there will be a limit of 100 actions per round for each tank. If a tank exceeds that limit then it will be destroyed. Any tank that remains stationary for 4 consecutive turns will incur a 5-point hit to its action count. Remember that an action constitutes of either turning, moving forward or firing.

 

That's pretty much it :) 

Entries should be in TICodEd sxb format so they can be easily embedded within the host program. Entry deadline will be March 15,2023 at midnight GMT. Only one entry per programmer allowed.

Entries will be dichotomized randomly and each pair of tanks pitted against each other with the winner qualifying for the next competition tier. Depending on the number of entries, the overall winner should be announced in April.

 

Attached is the host program in TICodEd sxb format so you can test your subroutines. Tank 1 is computer controlled, dumb as a rock I'm afraid, but it will do for testing purposes and to get an idea of how to set up your subroutine. There is stub at the end for your routine which should be named TANK2. Just append your code in that section and build the project. Please let me know if you find any bugs.

 

Spoiler
// CCOMBAT HOST PROGRAM
// Version 02.14.23

// Initialization
CALL CLEAR
RANDOMIZE
CALL CHAR(96,"00000000000000",101,"FFFFFFFFFFFFFFFF0000001818000000FFFFC3C3C3C3FFFF")
CALL CHAR(97,"1818DBFFFFFFC3C3FCFC383F3F38FCFCC3C3FFFFFFDB18183F3F1CFCFC1C3F3F")
CALL SCREEN(14)
CALL COLOR(9,11,9)

FOR Y=1 TO 24::
FOR X=1 TO 32::
READ CH::
CALL HCHAR(Y,X,CH)::
NEXT X::
NEXT Y

reset:
XC=3::
CALL RNUM(2,22,YC)::
CDIR=2::
XP=30::
CALL RNUM(2,22,YP)::
PDIR=4
TFLAG=0::
PFLAG=0::
P1ACNT=0::
P2ACNT=0::
P1CCNT=0::
P2CCNT=0::
P1PCODE=0::
P2PCODE=0

CALL STDTOSP(XC,YC,XSC,YSC)
CALL SPRITE(#1,98,13,YSC,XSC)
CALL STDTOSP(XP,YP,XSP,YSP)
CALL SPRITE(#2,100,5,YSP,XSP)
CALL SPRITE(#3,102,2,193,1)
CALL SPRITE(#4,103,16,193,1)

IF RFLAG=1 THEN
   initialize

DISPLAY AT(24,4):"PRESS ANY KEY TO START"
keyloop:
CALL KEY(0,K,S)::
IF S=0 THEN
   keyloop

DISPLAY AT(24,1):" "

// Start of game

// Set initiative
initialize:
GOSUB score
CALL RNUM(1,2,TURN)

IF TURN=2 THEN
   p2turn

// Player 1 turn
p1turn:
TFLAG=1
CALL SCAN(CDIR,XC,YC,XP,YP,LOSFLAG)

IF LOSFLAG=1 THEN
   CALL TANK1(XC,YC,CDIR,XP,YP,PDIR,CODE) ..
ELSE
    CALL TANK1(XC,YC,CDIR,0,0,0,CODE)

CODE=INT(CODE)

IF CODE<1 OR CODE>4 THEN
   CALL RNUM(1,4,CODE)

IF LOSFLAG=1 THEN
   CALL STDTOSP(XP,YP,SX,SY)::
   CALL LOCATE(#4,SY,SX)::
   GOSUB radar

IF LOSFLAG=1 THEN
   IF (ABS(XC-XP)<=8 AND YC=YP) OR (ABS(YC-YP)<=8 AND XC=XP) THEN
      TARGETFLAG=1 ..
   ELSE
      TARGETFLAG=0

IF CODE>1 AND P1PCODE>1 THEN
   P1CCNT=P1CCNT+1

P1PCODE=CODE

IF P1CCNT>3 THEN
   P1ACNT=P1ACNT+5::
   P1CCNT=0 ..
ELSE
   P1ACNT=P1ACNT+1

IF P1ACNT>100 THEN
   DISPLAY AT(24,3)BEEP:"ACTION LIMIT EXCEEDED!"::
   CALL ANIMATE(1)::
   CALL DELAY(100)::
   P2SCORE=P2SCORE+1::
   GOTO nextround

CALL ACTION(1,XC,YC,CDIR,CODE,TARGETFLAG)

IF CODE=4 AND TARGETFLAG=1 THEN
   P1SCORE=P1SCORE+1::
   HITFLAG=1

IF HITFLAG=1 OR PFLAG=1 THEN
   nextround ..
ELSE
   p2turn

// Player 2 turn
p2turn:
PFLAG=1
CALL SCAN(PDIR,XP,YP,XC,YC,LOSFLAG)

IF LOSFLAG=1 THEN
   CALL TANK2(XP,YP,PDIR,XC,YC,CDIR,CODE) ..
ELSE
    CALL TANK2(XP,YP,PDIR,0,0,0,CODE)

CODE=INT(CODE)

IF CODE<1 OR CODE>4 THEN
   CALL RNUM(1,4,CODE)

IF LOSFLAG=1 THEN
   CALL STDTOSP(XC,YC,SX,SY)::
   CALL LOCATE(#4,SY,SX)::
   GOSUB radar

IF LOSFLAG=1 THEN
   IF (ABS(XC-XP)<=8 AND YC-YP=0) OR (ABS(YC-YP)<=8 AND XC-XP=0) THEN
      TARGETFLAG=1 ..
   ELSE
      TARGETFLAG=0

IF CODE>1 AND P2PCODE>1 THEN
   P2CCNT=P2CCNT+1

P2PCODE=CODE

IF P2CCNT>3 THEN
   P2ACNT=P2ACNT+5::
   P2CCNT=0 ..
ELSE
   P2ACNT=P2ACNT+1

IF P2ACNT>100 THEN
   DISPLAY AT(24,3)BEEP:"ACTION LIMIT EXCEEDED!"::
   CALL ANIMATE(2)::
   CALL DELAY(100)::
   P1SCORE=P1SCORE+1::
   GOTO nextround

CALL ACTION(2,XP,YP,PDIR,CODE,TARGETFLAG)

IF CODE=4 AND TARGETFLAG=1 THEN
   P2SCORE=P2SCORE+1::
   HITFLAG=1

IF HITFLAG=1 OR TFLAG=1 THEN
   nextround ..
ELSE
   p1turn

// Next round
nextround:
CALL LOCATE(#4,193,1)::
GOSUB score

IF P1SCORE=5 OR P2SCORE=5 THEN
   GOTO endgame

IF HITFLAG=1 THEN
   HITFLAG=0::
   GOTO endround

IF P1ACNT>100 OR P2ACNT>100 THEN
   endround

TFLAG=0::
PFLAG=0::
GOTO initialize

// Reset game
endround:
CALL LOCATE(#4,193,1)::
RFLAG=1::
CALL DELAY(500)::
GOTO reset

// End of game
endgame:
CALL LOCATE(#4,193,1)::
CALL DELAY(200)

IF P1SCORE=5 THEN
   W$="TANK 1" ..
ELSE
   W$="TANK 2"

DISPLAY AT(24,3):W$;" IS THE WINNER!!!"
loop:
CALL KEY(0,K,S)

IF S=0 THEN
   loop

STOP

// Screen data
DATA 101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101
DATA 101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101
DATA 101,96,96,96,96,96,96,96,96,96,96,96,96,96,96,101
DATA 101,96,96,96,96,96,96,96,96,96,96,96,96,96,96,101
DATA 101,96,96,96,96,96,96,96,96,96,96,96,96,96,96,101
DATA 101,96,96,96,96,96,96,96,96,96,96,96,96,96,96,101
DATA 101,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96
DATA 96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,101
DATA 101,96,96,96,101,101,101,96,96,96,96,96,96,96,96,96
DATA 96,96,96,96,96,96,96,96,96,101,101,101,96,96,96,101
DATA 101,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96
DATA 96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,101
DATA 101,96,96,96,96,96,96,96,96,96,101,101,101,96,96,96
DATA 96,96,96,101,101,101,96,96,96,96,96,96,96,96,96,101
DATA 101,96,96,96,96,96,96,96,96,96,101,96,96,96,96,96
DATA 96,96,96,96,96,101,96,96,96,96,96,96,96,96,96,101
DATA 101,96,96,101,101,96,96,96,96,96,96,96,96,96,96,96
DATA 96,96,96,96,96,96,96,96,96,96,96,101,101,96,96,101
DATA 101,96,96,96,101,96,96,96,96,96,96,96,96,96,96,96
DATA 96,96,96,96,96,96,96,96,96,96,96,101,96,96,96,101
DATA 101,96,96,96,101,96,96,101,101,96,96,96,96,96,96,96
DATA 96,96,96,96,96,96,96,101,101,96,96,101,96,96,96,101
DATA 101,96,96,96,101,96,96,101,101,96,96,96,96,96,96,96
DATA 96,96,96,96,96,96,96,101,101,96,96,101,96,96,96,101
DATA 101,96,96,96,101,96,96,101,101,96,96,96,96,96,96,96
DATA 96,96,96,96,96,96,96,101,101,96,96,101,96,96,96,101
DATA 101,96,96,96,101,96,96,96,96,96,96,96,96,96,96,96
DATA 96,96,96,96,96,96,96,96,96,96,96,101,96,96,96,101
DATA 101,96,96,101,101,96,96,96,96,96,96,96,96,96,96,96
DATA 96,96,96,96,96,96,96,96,96,96,96,101,101,96,96,101
DATA 101,96,96,96,96,96,96,96,96,96,101,96,96,96,96,96
DATA 96,96,96,96,96,101,96,96,96,96,96,96,96,96,96,101
DATA 101,96,96,96,96,96,96,96,96,96,101,101,101,96,96,96
DATA 96,96,96,101,101,101,96,96,96,96,96,96,96,96,96,101
DATA 101,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96
DATA 96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,101
DATA 101,96,96,96,101,101,101,96,96,96,96,96,96,96,96,96
DATA 96,96,96,96,96,96,96,96,96,101,101,101,96,96,96,101
DATA 101,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96
DATA 96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,101
DATA 101,96,96,96,96,96,96,96,96,96,96,96,96,96,96,101
DATA 101,96,96,96,96,96,96,96,96,96,96,96,96,96,96,101
DATA 101,96,96,96,96,96,96,96,96,96,96,96,96,96,96,101
DATA 101,96,96,96,96,96,96,96,96,96,96,96,96,96,96,101
DATA 101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101
DATA 101,101,101,101,101,101,101,101,101,101,101,101,101,101,101,101
DATA 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32
DATA 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32

// Subroutines section

// Score display
score:
DISPLAY AT(24,3):"TANK 1: ";P1SCORE;"    TANK 2: ";P2SCORE
RETURN

// Radar sound routine
radar:
CALL SOUND(165,1165,0)::
CALL SOUND(165,1165,8)::
CALL SOUND(165,1165,16)::
CALL SOUND(165,1165,24)
RETURN

// Generate random number
SUB RNUM(A,B,R)
R=INT(RND*(B-A+1))+A
SUBEND

// Standard to sprite coordinate conversion routine
SUB STDTOSP(X,Y,SX,SY)
SX=(X-1)*8+1
SY=(Y-1)*8+1
SUBEND

// Delay routine
SUB DELAY(D)

FOR I=1 TO D::
NEXT I

SUBEND

// Scan for enemy tank and determine LOS
SUB SCAN(DIR,XC,YC,XP,YP,LFLAG)
DX=ABS(XC-XP)::
DY=ABS(YC-YP)::
LFLAG=0

IF DIR<>1 THEN
   sright

IF YP>=YC OR DX>DY+1 THEN
   SUBEXIT

setflag:
CALL LOS(XC,YC,XP,YP,LFLAG)::
SUBEXIT

sright:
IF DIR<>2 THEN
   sdown

IF XP<=XC OR DY>DX+1 THEN
   SUBEXIT ..
ELSE
   setflag

sdown:
IF DIR<>3 THEN
   sleft

IF YP<=YC OR DX>DY+1 THEN
   SUBEXIT ..
ELSE
   setflag

sleft:
IF XP>=XC OR DY>DX+1 THEN
   SUBEXIT ..
ELSE
   setflag

SUBEND

// Line of sight routine
SUB LOS(OX1,OY1,X2,Y2,FLAG)
X1=OX1::
Y1=OY1
DX=ABS(X2-X1)::
SX=-1

IF X1<X2 THEN
   SX=1

DY=ABS(Y2-Y1)::
SY=-1

IF Y1<Y2 THEN
   SY=1

ER=-DY

IF DX>DY THEN
   ER=DX

ER=INT(ER/2)
checkobs:
CALL GCHAR(Y1,X1,C)

IF C=101 THEN
   SUBEXIT

IF X1=X2 AND Y1=Y2 THEN
   FLAG=1::
   SUBEXIT

E2=ER

IF E2>-DX THEN
   ER=ER-DY::
   X1=X1+SX

IF E2<DY THEN
   ER=ER+DX::
   Y1=Y1+SY

GOTO checkobs

SUBEND

// Gun fire subroutine
SUB FIRE(S,X,Y,DIR,FLAG)
CALL SOUND(250,-6,0)

IF FLAG=0 THEN
   DISPLAY AT(24,3)BEEP:" TARGET OUT OF RANGE!"::
   CALL DELAY(100)::
   SUBEXIT

IF S=1 THEN
   ST=2 ..
ELSE
   ST=1

CALL STDTOSP(X,Y,SX,SY)

IF DIR=1 THEN
   SY=SY-4::
   CALL LOCATE(#3,SY,SX)::
   CALL MOTION(#3,-30,0)::
   GOTO checkhit

IF DIR=2 THEN
   SX=SX+4::
   CALL LOCATE(#3,SY,SX)::
   CALL MOTION(#3,0,30)::
   GOTO checkhit

IF DIR=3 THEN
   SY=SY+4::
   CALL LOCATE(#3,SY,SX)::
   CALL MOTION(#3,30,0)::
   GOTO checkhit

SX=SX-4::
CALL LOCATE(#3,SY,SX)::
CALL MOTION(#3,0,-30)

checkhit:
CALL COINC(#3,#ST,4,H)
IF H=0 THEN
   checkhit

CALL MOTION(#3,0,0)
CALL LOCATE(#3,193,1)
CALL ANIMATE(ST)
CALL SOUND(500,-7,0)::
CALL SOUND(200,-7,0)::
CALL SOUND(100,-7,0)

SUBEND

// Tank displacement routine
SUB DELTA(DIR,DX,DY)

IF DIR=1 THEN
   DX=0::
   DY=-1::
   SUBEXIT

IF DIR=2 THEN
   DX=1::
   DY=0::
   SUBEXIT

IF DIR=3 THEN
   DX=0::
   DY=1::
   SUBEXIT

DX=-1::
DY=0

SUBEND

// Apply tank action routine
SUB ACTION(S,X,Y,DIR,CODE,FLAG)

IF CODE=1 THEN
   CALL DELTA(DIR,DX,DY)::
   GOTO movetank

IF CODE=2 THEN
   DIR=DIR+1::
   IF DIR>4 THEN
      DIR=1

IF CODE=3 THEN
   DIR=DIR-1::
   IF DIR<1 THEN
     DIR=4

IF CODE=4 THEN
   CALL FIRE(S,X,Y,DIR,FLAG)::
   SUBEXIT

IF DIR=1 THEN
   CH=97

IF DIR=2 THEN
   CH=98

IF DIR=3 THEN
   CH=99

IF DIR=4 THEN
   CH=100

CALL PATTERN(#S,CH)
SUBEXIT

movetank:
CALL GCHAR(Y+DY,X+DX,C)

IF C=101 THEN
   SUBEXIT

X=X+DX::
Y=Y+DY
CALL STDTOSP(X,Y,SX,SY)

IF DIR<>1 THEN
   right

CALL MOTION(#S,-5,0)
GOTO checkpos

right:
IF DIR<>2 THEN
   down

CALL MOTION(#S,0,5)
GOTO checkpos

down:
IF DIR<>3 THEN
   left

CALL MOTION(#S,5,0)
GOTO checkpos

left:
CALL MOTION(#S,0,-5)

checkpos:
CALL POSITION(#S,TY,TX)

IF (ABS(TY-SY)<=1) AND (ABS(TX-SX)<=1) THEN
   CALL MOTION(#S,0,0)::
   CALL POSITION(#S,SY,SX)::
   SUBEXIT ..
ELSE
   checkpos

SUBEND

// Tank hit animation routine
SUB ANIMATE(S)
FOR I=1 TO 10
   FOR P=97 TO 100
      CALL PATTERN(#S,P)
   NEXT P
NEXT I

SUBEND

// Tank 1 routine
SUB TANK1(X,Y,DIR,X1,Y1,DIR1,CODE)

IF X1=0 THEN
   nolos

IF (ABS(X-X1)<=8 AND Y=Y1) OR (ABS(Y-Y1)<=8 AND X=X1) THEN
   CODE=4::
   SUBEXIT

nolos:
N=INT(RND*10)+1

IF N>3 OR X1<>0 THEN
   straight

turn:
N=INT(RND*2)+1

IF N=1 THEN
   CODE=2 ..
ELSE
   CODE=1

SUBEXIT

straight:
IF DIR=1 THEN
   DX=0::
   DY=-1

IF DIR=2 THEN
   DX=1::
   DY=0

IF DIR=3 THEN
   DX=0::
   DY=1

IF DIR=4 THEN
   DX=-1::
   DY=0

CALL GCHAR(Y+DY,X+DX,C)

IF C=101 THEN
   turn

CODE=1

SUBEND

// Tank 2 subroutine
SUB TANK2(X,Y,DIR,X1,Y1,DIR1,CODE)


SUBEND

 

 

 

 

 

 

CCombat.sxb

  • Like 6
Link to comment
Share on other sites

I would be interested.

However, I have never used TICoded sxb.

 

Maybe this is the time to learn about it and add some tools to the box.

 

It is a month away...  I have a major project at work that has me doing 10-12 hours days that is supposed to launch 3/1 

I am also deep into 2 TI projects already. 

 

I will see what I can do. 

 

Question.  The view of 45 degrees...  Can you always see 10 spaces?  Or less, if a wall is in the way?

 

I guess I have lots of ideas, but I think they are all cheating.  All's fair in love and war?

 

Edited by 1980gamer
Link to comment
Share on other sites

48 minutes ago, 1980gamer said:

I would be interested.

However, I have never used TICoded sxb.

 

Maybe this is the time to learn about it and add some tools to the box.

 

It is a month away...  I have a major project at work that has me doing 10-12 hours days that is supposed to launch 3/1 

I am also deep into 2 TI projects already. 

 

I will see what I can do. 

 

Question.  The view of 45 degrees...  Can you always see 10 spaces?  Or less, if a wall is in the way?

 

I guess I have lots of ideas, but I think they are all cheating.  All's fair in love and war?

 

You can see as far as line of sight allows. Obviously if there is an obstruction then that limits things. The 10 space limit is for the gun range only, in other words while you could have eyes on the opposing tank at the other end of the field, you'll need to get closer in order to fire. 

TICodEd is primarily an editor with some additional programming structures like CASE and WHILE, but you don't have to use these and you can type in straight XB code. The main advantage is no line numbers, indentations and named labels for GOTO's and such instead of line numbers. Since we are dealing with subprograms and not complete programs, being able to drop the code into the host program instead of trying to rearrange line numbers will be a huge time saver.

I'd like to see at least 6-8 entries to the contest in order to make it competitive and interesting and you may want to wait until we reach that level of interest before moving forward (no pun intended :) )

  • Like 2
Link to comment
Share on other sites

Now that RXB 2023 is out there, and it has been pretty much proven by Retrospect that you can crank out games that are better than normal XB

due to some special built in commands like CALL JOYMOTION that is a single command that does

CALL JOYST+CALL MOTION+CALL KEY+IF fire button THEN GOTO line number

 

Thus CALL JOYMOTION is many times faster then CALL JOYST :: CALL MOTION :: CALL JOYSTICK :: IF K=18 then line number in normal XB

 

So I guess a RXB version of this type of contest should be suggested.

 

 

Link to comment
Share on other sites

Rich, RXB is truly awesome. That said, the entries for this contest will not have any input from the user nor will they handle any graphics or animations (these are handled by the host program) and as such will be strictly computational and you are free to use any flavor of XB you want. It's essentially the pitting of 2 AI's against one another. Incidentally, TICodEd understands RXB as well. Care to give it a shot? 😁

  • Like 4
Link to comment
Share on other sites

I have multiple questions ...

  1. How do I initiate a move? With "CODE"? What are the options to turn, move forward (backward?) and fire?
  2. Do you supply a test-program, i.e. where you manually play one player to test your AI/NPC player?
  3. I can GCHAR the screen as a map? But not query the enemy?

 

Link to comment
Share on other sites

1 hour ago, Vorticon said:

Rich, RXB is truly awesome. That said, the entries for this contest will not have any input from the user nor will they handle any graphics or animations (these are handled by the host program) and as such will be strictly computational and you are free to use any flavor of XB you want. It's essentially the pitting of 2 AI's against one another. Incidentally, TICodEd understands RXB as well. Care to give it a shot? 😁

Hmm RXB has built in assembly so even normal XB code using things like CALL HCHAR or CALL VCHAR are way faster.

Added to that is the RND function in RXB is insanely faster than XB RND.

 

So you still have to use the original module to get the result using TICodEd?

Link to comment
Share on other sites

56 minutes ago, SteveB said:

I have multiple questions ...

  1. How do I initiate a move? With "CODE"? What are the options to turn, move forward (backward?) and fire?
  2. Do you supply a test-program, i.e. where you manually play one player to test your AI/NPC player?
  3. I can GCHAR the screen as a map? But not query the enemy?

 

Excellent questions. The host program will randomly assign initiative between the opposing tanks and will call the respective subroutine in turn. That subroutine, given the data passed on to it as detailed above, will return the variable CODE by assigning a numeric value to it from 1-4 based on its computations. 

CODE values:

  • 1: move forward 1 square
  • 2: turn right 90 degrees
  • 3: turn left 90 degrees
  • 4: fire. To score a hit, the target
    • has to be within the line of sight of the 45 degrees cone in front of the tank (essentially a field of view of 90 degrees with 45 degrees on each side of the tank midline)
    • there are no intervening walls between the firing tank and the target
    • the target is <= 10 squares away

The host program will be supplied by me and I will post a complete listing once I finish it assuming we have enough entries to initiate the contest. It will have a simple computer-controlled opponent which will allow participants to test their subroutine logic. That NPC will be replaced by another player's tank during the competition judging.

You can GCHAR to your heart's content. As mentioned previously, the tanks will be represented by sprites on the field, so GCHAR will not help here, nor will you be able to LOCATE or COINC the sprites because the opposing sprite will be temporarily moved off-screen during one's turn so that it's real location will not be known to the subroutine, UNLESS that tank is within the cone of visibility in which case its coordinates and direction will also be passed to the subroutine. The host program does the heavy lifting of figuring out LOS, so the contestants only need to concentrate on the subroutine logic.

 

Hope that clarifies things a bit.

While the rules are pretty simple, I suspect the task of tracking down the enemy tank and killing it will not be trivial given the limited amount of information on hand each turn.

 

Link to comment
Share on other sites

4 minutes ago, RXB said:

Hmm RXB has built in assembly so even normal XB code using things like CALL HCHAR or CALL VCHAR are way faster.

Added to that is the RND function in RXB is insanely faster than XB RND.

 

So you still have to use the original module to get the result using TICodEd?

Again, the contestant subroutines will have no need for HCHAR or VCHAR, but will likely use GCHAR to scout out the field. As for the RND function, this is not an arcade game and the speed gain is irrelevant.

And yes, the original RXB module will be required if using RXB syntax with TICodEd, something I can do if a specific entry requires it.

  • Like 1
Link to comment
Share on other sites

So basically, writing code to randomly guess the location? 

I fail to see any difference is going to make any difference at all no matter if XB or RXB or LOGO or PILOT or Assembly.

1. Turn based so speed does not matter.

2. Guessing a Sprite location that has been removed off screen using GCHAR that is the same speed in any XB made.

(I know this as I wrote many versions of Assembly GCHAR for RXB and none ever showed more than a half a second improvement over normal XB doing GCHAR of 10,000 times.)

3. Even TI Basic is pretty much the same speed as XB for CALL GCHAR unless you do 10,000 times loop to find the difference of 1 second overall.

 

Is the idea to find the best search algorithm as I can see no other purpose for this?

In that case any language would do this and can be recoded into other languages.

Link to comment
Share on other sites

5 minutes ago, RXB said:

So basically, writing code to randomly guess the location? 

I fail to see any difference is going to make any difference at all no matter if XB or RXB or LOGO or PILOT or Assembly.

1. Turn based so speed does not matter.

2. Guessing a Sprite location that has been removed off screen using GCHAR that is the same speed in any XB made.

(I know this as I wrote many versions of Assembly GCHAR for RXB and none ever showed more than a half a second improvement over normal XB doing GCHAR of 10,000 times.)

3. Even TI Basic is pretty much the same speed as XB for CALL GCHAR unless you do 10,000 times loop to find the difference of 1 second overall.

 

Is the idea to find the best search algorithm as I can see no other purpose for this?

In that case any language would do this and can be recoded into other languages.

The idea is to have fun. If you don't think it would be fun, then you shouldn't do it.

  • Like 4
Link to comment
Share on other sites

15 minutes ago, Asmusr said:

Is the subroutine responsible for calculating whether the other tank is within range? Will the other tank be destroyed immediately if fired upon within range?

No. The hosting program will assess the range and if it is a hit then the opposing tank will be destroyed.

  • Like 2
Link to comment
Share on other sites

57 minutes ago, RXB said:

Hmm RXB has built in assembly so even normal XB code using things like CALL HCHAR or CALL VCHAR are way faster.

Added to that is the RND function in RXB is insanely faster than XB RND.

 

So you still have to use the original module to get the result using TICodEd?

It looks like I know RXB way better than you know TiCodEd with SXB ... TiCodEd is an Editor with a pre-processor, which extends the BASIC language with constructs it then translates to standard TI (Extended) BASIC with line-numbers. With the RXB-Package included, it even knows all your RXB extensions, both for code-completion and for checking of valid subroutines. The advantage in this context is that it delivers fully relocatable code when you use labels and REPEAT-UNTIL / WHILE-WEND for loops. As a design limit you currently can't use BEGIN/END in SUB-Routines. But you also have your local variable scope in SUB, so you don't interfere with your competitor or the host.

 

So yes, TiCodEd will output a tokenized XB or RXB program in your FIAD directory and then Classic99 with XB resp. RXB will take over, requiring the module. 

 

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

9 minutes ago, Vorticon said:

No. The hosting program will assess the range and if it is a hit then the opposing tank will be destroyed.

Will a tank within a 10 square distance in any direction be destroyed, or do you have to face the tank and line up with it either vertically or horizontally?

Edited by Asmusr
Link to comment
Share on other sites

23 minutes ago, RXB said:

So basically, writing code to randomly guess the location? 

I fail to see any difference is going to make any difference at all no matter if XB or RXB or LOGO or PILOT or Assembly.

1. Turn based so speed does not matter.

2. Guessing a Sprite location that has been removed off screen using GCHAR that is the same speed in any XB made.

(I know this as I wrote many versions of Assembly GCHAR for RXB and none ever showed more than a half a second improvement over normal XB doing GCHAR of 10,000 times.)

3. Even TI Basic is pretty much the same speed as XB for CALL GCHAR unless you do 10,000 times loop to find the difference of 1 second overall.

 

Is the idea to find the best search algorithm as I can see no other purpose for this?

In that case any language would do this and can be recoded into other languages.

I think it's a little more involved than just trying to randomly guess the location of the opposing tank. This is particularly true once the opposing tank has been spotted but is not yet in range because now you have more specific location information. What you do with that information based on the coordinates and direction of the target is where your algorithm will be truly tested.

As I already stated, you can use any flavor of XB for this since it's purely computational. 

  • Like 2
Link to comment
Share on other sites

6 minutes ago, Asmusr said:

Will a tank within a 10 square distance in any direction will be destroyed, or do you have to face the tank and line up with it either vertically or horizontally?

If you see the tank within the frontal 45 degree LOS cone, then firing at it will destroy it as long as it is within 10 squares. You will know when you have LOS when X1, Y1 and DIR1 are <> 0.

  • Like 1
Link to comment
Share on other sites

1 minute ago, Asmusr said:

Will a tank within a 10 square distance in any direction will be destroyed, or do you have to face the tank and line up with it either vertically or horizontally?

So your cannon also has a +/- 45 degree turning angle ... you can shoot what you can see if it within 10 squares reach?

Link to comment
Share on other sites

1 hour ago, Vorticon said:

I am wondering however if 10 squares for firing range is too generous given the size of the field and the firing cone. Any thoughts on that?

I also wonder if this is too much of a gamble. As soon as you see him, you calculate the distance and shoot ... not much of a strategy. If you need to align yourself without getting shot, this becomes tricky and more challanging, doesn't it?

Edited by SteveB
Link to comment
Share on other sites

55 minutes ago, Vorticon said:

I think it's a little more involved than just trying to randomly guess the location of the opposing tank. This is particularly true once the opposing tank has been spotted but is not yet in range because now you have more specific location information. What you do with that information based on the coordinates and direction of the target is where your algorithm will be truly tested.

As I already stated, you can use any flavor of XB for this since it's purely computational. 

RXB has

CALL HGET(row,column,length,string-variable) 

or

CALL VGET(row,column,length,string-variable)

Thus a simple look in any direction would be...

CALL HGET(1,1,224,A$) ! would get all 32 characters in 7 rows top row 1 to 7 and this RXB line would get entire screen:

CALL HGET(1,1,224,X$(0),8,1,224,X$(1),15,1,224,22,96,X$(3))

FOR X=0 to 3 :: L=POS(X$(X),"HIT",1) :: IF L  THEN PRINT "WE HAVE A HIT" :: NEXT X

 

I can put this in a single RXB line to find it in one pass. ("HIT" would be the single character you would look for in GCHAR)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...