Strategy

Conquer the island
Post Reply
MelGrubb
Posts: 2
Joined: Thu Jan 06, 2005 2:47 am

Strategy

Post by MelGrubb » Thu Jan 06, 2005 2:55 am

I code for a living myself, and have tried to program the occasional game in my spare time. I've had to limit myself to solitaire or time-limit style games because I just can't wrap my head around AI opponents.

I've looked up your site because I've played the demo of Slay, and seen the full version before. Since you write the kinds of games I would try myself, I throught I'd ask how you begin to construct the AI logic for somehting like Slay.

I wouldn't want you to give away your secrets (Actually, I would, but I may as well ask for source code, right?), but could you give a rough outline of how the computer opponents "think" in Slay? By rough outline, I mean that I'm not asking for exact calculations, but broad concepts.

What makes the higher levels harder? Is it a change to the weighting values for different types of decisions? Does a dumb player value more land over more defense, and a higher level player tilt the scales the opposite direction? At what intelligence level does the AI "realize" that connecting two disjointed kingdoms is a strategic advantage?

If you could recommend any good sources of information, I'd like to read more about it.

Thanks

User avatar
BoxZone_Author
Posts: 331
Joined: Thu Sep 16, 2004 7:46 pm
Location: UK (back from USA)
Contact:

Post by BoxZone_Author » Sun Jan 09, 2005 10:53 pm

I'd also be interested to hear this.
The AI's I code are all shades of dumb.
I have to make the difficult levels difficult by making it easier for the AI's (the equivalent of less money to purchase or feed a unit, Sean doesn't need to do this to make his AIs good).

User avatar
sharon
Posts: 43
Joined: Wed Dec 22, 2004 9:48 pm
Location: leicester, uk
Contact:

Post by sharon » Mon Jan 10, 2005 12:27 am

(sharons other 1/2 here)

As your talking about programming you might be able to help me.

A long long time ago i used to be able to write good programs in basic (not machine code) on the amstrad 64 and a few others like comodore 64 ect.

my graphics was nothing great but i could write games real well that contained alot of mathmatics like monopoly ect.

Is there a programing language like this for windows ? oh and i dont meen microsoft basic that came with windows 3.01 lol

I would love to get back into programing again but things dont sink in so quick now so it would have to be a laungage sim to what i know already...

btw i used to have AI problems when i worte my little games on the amstrad, I remember if the computer was loosing i used to give it a slight advantage on its dice roll



5 dice = int(rnd*7):if dice=0 then goto 5
10 for x=1 to 30
30 y=int(ran*30):if y=10 then goto 100:rem ***goto cheat line***
40 next x
50 rem *** move piece ***
60
70
80
90 return
100 rem ***how many does the pice need to get the property it needs ?***

I wonder how many of you realy remember basic from back then, i think i may be rusty now lol
will my pc ever be fast enough?

User avatar
Leon
Posts: 47
Joined: Fri Sep 03, 2004 3:28 pm
Location: Switzerland

Post by Leon » Mon Jan 10, 2005 1:52 am

All the AI differences (at the various levels) are clearly explained in the "instructions" which you find in the help file.

Be careful .. this game is addictive.
Intelligence is a tool to fight the forces of evil.

User avatar
Fusion_power
Posts: 323
Joined: Fri Sep 03, 2004 2:34 pm
Contact:

Post by Fusion_power » Mon Jan 10, 2005 3:03 am

Sharon's other half:

You have an error on line 5.

Goes to show you didn't know basic quite as well as you thought you did.

*S*

As for a programming language on a windows machine, I prefer one of the C variants such as C++. However, there is excellent reason to code in Java in order to have high level portability to other platforms.

The question is "Do you know what the error on line 5 is?"

One more thing - to make an AI functional at different levels, you code for example to test two possible AI responses. To add another level, you code more tests and execute the first test followed by the second. To add another level of sophistication, add another sequence of tests.

I have to say that Slay's AI is relatively unsophisticated. This is NOT a complaint, if it was much better, most people could not possibly win. Here are some examples of the AI's weakness:

1. The AI will kill the capitol sitting next to a castle with a knight even when the castle could be destroyed then the capitol destroyed with a spearman.

2. The AI does not evaluate for threats that are one hexagon removed from their territory.

3. The AI places men first, then decides whether to build castles. This often results in poor position of the man and a weakly positioned castle.

4. On the opening move, the AI does not know how to strategically block opponents.

5. The AI is set to attack under specific conditions even when such an attack inevitably results in destruction. Place a peon next to territory held by a landlocked spearman and the spearman will kill the peon every time. Your men then destroy the spearman's capitol and he starves.

There are a ton of others

Fusion

User avatar
sharon
Posts: 43
Joined: Wed Dec 22, 2004 9:48 pm
Location: leicester, uk
Contact:

Post by sharon » Mon Jan 10, 2005 6:29 am

(sharons other 1/2 here)
should get my own id :lol:

5 dice = int(rnd*7).........makes it pick a random no between 0 and 6
if dice=0 then goto 5.......tells the computer, if it picks 0 then go (back to the same line) and pick another number (will keep going until it hasn't picked 0)

(rnd*7) in the amstrads basic would make it pick either 0,1,2,3,4,5 or 6, i dont see any error there.

if you are on about there is spaces either side of the "=" at 1 point but not the other on that line then if you read up on amstrad basic, unlike the comodore it didnt matter at at that point if there there or not and i used to always use the spaces when setting the variable but not when checking (i found it quicker for debugging)

now in line 30 there is an error

30 y=int(ran*30):if y=10 then goto 100:rem ***goto cheat line***


its been a long long time since i used this basic as i stated so the odd mestake is bound to happen, but as far as knowing basic, i did know it and very very well.....15 years ago!
will my pc ever be fast enough?

User avatar
Fusion_power
Posts: 323
Joined: Fri Sep 03, 2004 2:34 pm
Contact:

Post by Fusion_power » Mon Jan 10, 2005 2:42 pm

Sharon's other 1/2,

Technically your coding does work. There just happens to be a much faster way to achieve the same thing.

Study how this works instead.

5 dice = int(rnd*6)+1

This automatically picks a number between 0 and 5 inclusive then adds 1 to it. The result is a number between 1 and 6 which fits for the toss of the dice. But this has a problem. The odds of getting a 1 or a 6 is very slightly less than the probability of getting 2, 3, 4, or 5. There is a similar probability issue with your coding. It does of course depend on the version of basic.

Strictly on a sidenote, I learned to program in basic completely without the goto statement (except for the dedicated error trapping routine which must use goto). This was a result of an article I read in a magazine years ago about the misuse of goto to execute code. It makes most basic programmers pull their hair out to read code written without goto but when it runs, its typically many times faster than comparable code written with goto. I use gosub to execute subroutines but the subroutine has only one entry point and one exit point. It may be called from different locations in the main program but it will always start and end at the same points. Depending on your browser, the below code will substitute smilies for the number 8 and may substitute smilies for :p as well

Fusion


100 REM **** PREPARATIONS AND DEFINITIONS ****
102 ON ERROR GOTO 700
104 WIDTH 80
106 DEF SEG
108 KEY OFF
110 SCREEN 0,1
112 DEFDBL P
114 DIM DAT$(12,12)
116 FOR XA=1 TO 7
118 FOR XB=1 TO 12
120 READ DAT$(XA,XB)
122 NEXT XB
124 NEXT XA
126 :
128 REM **** MAIN ROUTINE ****
130 FOR XD=1 TO 2
132 CLS
134 COLOR 10,0
136 PRINT CHR$(213)+STRING$(72, 205)+CHR$(184)
138 PRINT CHR$(179)+" MORTAMOR 9.00, , , , "+CHR$(179)
140 PRINT CHR$(212)+STRING$(72, 205)+CHR$(190)
142 PRINT " THIS PROGRAM WILL CALCULATE MORTGAGE AMORTIZATION SCHEDULES":PRINT
144 PRINT " AND REGULAR MORTGAGE PAYMENTS. NO REPRESENTATION IS MADE":PRINT
146 PRINT " REGARDING FITNESS OR SUITABILITY FOR A PARTICULAR PURPOSE.":PRINT
148 PRINT " YOU MAY REGISTER BY SENDING $10.00 TO THE ADDRESS ABOVE.":PRINT
150 PRINT " IF FIXES OR IMPROVEMENTS HAVE BEEN MADE, AN UPDATE DISK":PRINT
152 PRINT " WILL BE SENT TO YOU. I HAVE SPENT 2 YEARS AND OVER 1000":PRINT
154 PRINT " HOURS DEVELOPING, DEBUGGING, AND FINE TUNING THIS PROGRAM":PRINT
156 PRINT " YOUR HONESTY IN PAYING FOR ITS USE WOULD BE APPRECIATED.":PRINT
158 COLOR 15, 0
160 PRINT " 0 = RESERVED FUTURE 2 = STANDARD MORTGAGE AMORTIZATION"
162 PRINT " 1 = PAYMENT ANALYSIS 3 = AMORTIZATION W/FIXED OR BALLOON PAYMENTS"
164 PRINT "SELECTION (0, 1, 2, 3) OR ESC ===>";
166 LOCATE 22,36,1
168 FOR XA=1 TO 2
170 A$=INKEY$
172 IF (A$<"0" OR A$>"3") AND A$<>CHR$(27) THEN XA=0 ELSE XA=2:DAT$(0,0)=A$
174 NEXT XA
176 IF DAT$(0,0)=CHR$(27) THEN XD=2:COLOR 7,0:CLS:END ELSE XD=0
178 IF DAT$(0,0)="0" THEN TN=2:GOSUB 286
180 IF DAT$(0,0)="1" THEN TN=7:GOSUB 196
182 IF DAT$(0,0)="1" THEN GOSUB 254:GOSUB 428
184 IF DAT$(0,0)="2" THEN TN=9:GOSUB 196
186 IF DAT$(0,0)="2" THEN GOSUB 254:GOSUB 504
188 IF DAT$(0,0)="3" THEN TN=11:GOSUB 196
190 IF DAT$(0,0)="3" THEN GOSUB 254:GOSUB 504
192 NEXT XD
194 :
196 REM **** GATHER DATA FOR CALCULATION ****
198 CLS
200 FOR XA=1 TO TN
202 LOCATE 1,1
204 ON XA GOSUB 294, 306, 318, 330, 342, 354, 366, 378, 390, 402, 414
206 PRINT
208 PRINT "ENTRY RANGE IS "+DAT$(2,XA)+" TO "+DAT$(3,XA)+" "
210 LOCATE 8+XA,1,0
212 PRINT "ENTER "+DAT$(1,XA)+" "
214 AF$=""
216 LOCATE 8+XA,35,1
218 FOR XB=1 TO VAL(DAT$(6,XA))
220 FOR XC=1 TO 2
222 A$=INKEY$
224 IF A$>="a" AND A$<="z" THEN A$=CHR$(ASC(A$) AND 223)
226 IF (A$<"A" OR A$>"Z") AND (A$>"9" OR A$<"0") AND A$<>CHR$(13) AND A$<>"." AND A$<>CHR$(8) AND A$<>"/" AND A$<>" " AND A$<>CHR$(27) THEN XC=0 ELSE XC=2
228 NEXT XC
230 IF XB=VAL(DAT$(6,XA)) AND A$<>CHR$(8) AND A$<>CHR$(13) AND A$<>CHR$(27) THEN XB=XB-1:A$=RIGHT$(AF$,1):AF$=LEFT$(AF$, LEN(AF$)-1):PRINT CHR$(29)+" "+CHR$(29);
232 IF A$=CHR$(8) THEN XB=XB-1:IF LEN(AF$)>0 THEN XB=XB-1:AF$=LEFT$(AF$, LEN(AF$)-1):PRINT CHR$(29)+" "+CHR$(29);
234 IF A$<>CHR$(8) AND A$<>CHR$(13) AND A$<>CHR$(27) THEN IF (XA>1 AND ((A$>="0" AND A$<="9") OR A$=".")) OR (XA=1) THEN AF$=AF$+A$:PRINT A$; ELSE XB=XB-1
236 IF A$=CHR$(13) THEN XB=XB+(A$=CHR$(13)):IF AF$<>"" THEN DAT$(12,XA)=AF$:XB=VAL(DAT$(6,XA)):LOCATE 8+XA,1,1:PRINT " "
238 IF A$=CHR$(27) THEN XB=VAL(DAT$(6,XA)):XA=TN:DAT$(0,0)=A$
240 NEXT XB
242 IF XA>1 AND A$<>CHR$(27) THEN IF VAL(AF$)<VAL(DAT$(2,XA)) OR VAL(AF$)>VAL(DAT$(3,XA)) THEN XA=XA-1
244 IF XA=2 AND VAL(DAT$(12,2))<4 THEN XA=XA+1
246 IF XA=8 AND VAL(DAT$(12,8))>VAL(DAT$(12,6)) THEN XA=XA-1
248 NEXT XA
250 RETURN
252 :
254 REM **** OPEN FILE, THEN CALCULATE PAYMENTS ****
256 IF VAL(DAT$(12,2))>3 THEN OPEN (DAT$(4,INT(VAL(DAT$(12,2))+1))+DAT$(5,(VAL(DAT$(12,3))+1))) FOR OUTPUT AS #1 ELSE OPEN (DAT$(4,INT(VAL(DAT$(12,2))+1))) FOR OUTPUT AS #1
258 YR=VAL(DAT$(12,9))
260 PA=VAL(DAT$(12,4))
262 PB=VAL(DAT$(12,5))
264 PC=INT(VAL(DAT$(12,6)))
266 PD=INT(VAL(DAT$(12,7)))
268 PE=VAL(DAT$(12,8))
270 PI=PB/(PC*100)
272 PN=PC*PD
274 PO=INT(PA*(PI/(1#-(1#/((1#+PI)^PN))))*100+.5#)/100
276 IF DAT$(0,0)="3" AND VAL(DAT$(12,11))>0 THEN PP=VAL(DAT$(12,11)):PH=(INT((PP*PI+.005#)*100)/100):PO=PH+(INT((PA-PP)*(PI/(1#-(1#/((1#+PI)^PN))))*100+.5#)/100)
278 IF DAT$(0,0)="3" AND VAL(DAT$(12,10))>0 THEN PO=VAL(DAT$(12,10))
280 IF PO<(INT((PA*PI+.005#)*100)/100)+.01 THEN PO=(INT((PA*PI+.005#)*100)/100)+.01
282 RETURN
284 :
286 REM **** RESERVED SPACE FOR FUTURE ROUTINES ****
288 RETURN
290 :
292 REM **** HELP SCREENS AND INSTRUCTIONS ***
294 PRINT " 'NAME/DATE' IS THE NAME OF THE PERSON FOR WHOM THE AMORTIZATION"
296 PRINT " IS BEING PREPARED. YOU MAY ENTER ANY ALPHABETIC CHARACTERS AND"
298 PRINT " A DATE IF WANTED. THE MAXIMUM LENGTH IS 40 CHARACTERS. YOU "
300 PRINT " MAY USE CHARACTERS FROM A TO Z AND NUMBERS 0 TO 9 PLUS THE /. "
302 PRINT " AN EXAMPLE OF VALID INPUT WOULD BE 'MR. JOHN DOE 9/13/94'. "
304 RETURN
306 PRINT " 'OUTPUT DEVICE' CAN BE ANY ONE OF THE DEVICES LISTED. SOME "
308 PRINT " SPECIAL PURPOSE PROGRAMS SUPPORT ALTERNATE DEVICES WHICH CAN BE"
310 PRINT " USED IF OUTPUT CAN BE REDIRECTED FROM A STANDARD DOS DEVICE. "
312 PRINT " 0 = SCRN: 1 = LPT1: 2 = LPT2: 3 = LPT3: "
314 PRINT " 4 = COM1: 5 = COM2: 6 = COM3: 7 = COM4: "
316 RETURN
318 PRINT " 'OUTPUT BAUD RATE' CAN BE ANY OF THE VALUES LISTED. SELECT THE"
320 PRINT " CORRECT BAUD RATE FOR YOUR OUTPUT DEVICE. SOME DEVICES AND/OR "
322 PRINT " COMPUTERS WILL NOT SUPPORT THE HIGHER BAUD RATES. "
324 PRINT " 0 = 75 1 = 110 2 = 150 3 = 300 4 = 600 "
326 PRINT " 5 = 1200 6 = 1800 7 = 2400 8 = 4800 9 = 9600 "
328 RETURN
330 PRINT " 'AMOUNT TO FINANCE' IS THE DOLLAR AMOUNT YOU WANT TO FINANCE. "
332 PRINT " YOU MAY ENTER DOLLARS AND CENTS BUT MAY NOT USE THE $ SIGN. "
334 PRINT " ANY DOLLAR VALUE FROM 1 TO 9,999,999,999.00 IS VALID, HOWEVER, "
336 PRINT " THIS PROGRAM IS DESIGNED PRIMARILY FOR THE AVERAGE PERSON "
338 PRINT " WHO WANTS TO BORROW AT MOST A FEW HUNDRED THOUSAND DOLLARS. "
340 RETURN
342 PRINT " 'YEARLY INTEREST RATE' IS THE PERCENTAGE RATE TO BE CHARGED. "
344 PRINT " YOU MAY ENTER DECIMALS BUT NOT THE % SIGN. THIS PROGRAM WILL "
346 PRINT " DISPLAY 4 DECIMAL PLACES OF INTEREST BUT CAN CALCULATE WITH UP "
348 PRINT " TO 16 DECIMAL PLACES. MOST NORMAL RATES WILL BE ONLY 2 OR 3 "
350 PRINT " DECIMAL POINTS SUCH AS 8.25 PERCENT OR 6.125 PERCENT. "
352 RETURN
354 PRINT " 'PAYMENTS PER YEAR' IS THE NUMBER OF PAYMENTS TO BE MADE PER "
356 PRINT " YEAR. THIS PROGRAM WILL HANDLE FROM 1 TO 52 YEARLY PAYMENTS. "
358 PRINT " SOME COMMON VALUES ARE - YEARLY=1, BI-YEARLY=2, QUARTERLY=4, "
360 PRINT " MONTHLY=12, BI-WEEKLY=26, AND WEEKLY=52. MOST HOME MORTGAGES "
362 PRINT " IN THE UNITED STATES ARE CALCULATED ON 12 MONTHLY PAYMENTS. "
364 RETURN
366 PRINT " 'NUMBER OF YEARS' IS THE DURATION OF THE MORTGAGE IN YEARS. "
368 PRINT " THIS PROGRAM CAN HANDLE A RANGE OF 1 TO 35 YEARS. AFTER ABOUT "
370 PRINT " FORTY YEARS, PAYMENTS START GOING UP INSTEAD OF DOWN BECAUSE OF"
372 PRINT " ACCRUED INTEREST ON THE INTEREST. THE SHORTER YOU CAN KEEP THE"
374 PRINT " TERM OF THE LOAN, THE LESS INTEREST YOU WILL PAY. "
376 RETURN
378 PRINT " '# OF 1ST PAY PERIOD' IS NEEDED FOR AN AMORTIZATION SCHEDULE. "
380 PRINT " FOR EXAMPLE, IF 12 PAYMENTS ARE MADE PER YEAR (ONE PER MONTH) "
382 PRINT " AND THE FIRST PAYMENT IS MADE IN MAY, ENTER 5 SINCE MAY IS THE "
384 PRINT " FIFTH MONTH OF THE YEAR. THIS NUMBER CANT BE GREATER THAN THE "
386 PRINT " NUMBER OF PAYMENTS PER YEAR. THE RANGE IS 1 TO 52 PAYMENTS. "
388 RETURN
390 PRINT " 'YEAR PAYMENTS BEGIN' IS THE YEAR THE MORTGAGE BEGINS. YOU CAN"
392 PRINT " USE ANY YEAR YOU WANT SO LONG AS IT HAS 4 DIGITS AND IS AFTER "
394 PRINT " THE YEAR 1000 BUT BEFORE THE YEAR 9999. THIS ALLOWS YOU TO "
396 PRINT " CHECK EXISTING MORTGAGES (FOR EARLY PAYOFF FOR EXAMPLE) OR TO "
398 PRINT " PREPLAN A NEW MORTGAGE AT YOUR CONVENIENCE. "
400 RETURN
402 PRINT " 'FIXED PAYMENT AMOUNT' IS THE DOLLAR AMOUNT YOU WANT TO PAY PER"
404 PRINT " MONTH. IT CALCULATES EARLY OR LATE PAYOFF AMORTIZATIONS. THE "
406 PRINT " MINIMUM AMOUNT IS FIRST PAYMENT INTEREST DUE PLUS $.01. THE "
408 PRINT " MAXIMUM IS PRINCIPAL PLUS INTEREST DUE. IF YOU ENTER ZERO AND "
410 PRINT " HIT RETURN, THEN THE PROGRAM USES THE CALCULATED PAYMENT. "
412 RETURN
414 PRINT " 'BALLOON PAY AMOUNT' IS THE AMOUNT YOU WANT TO PAY IN A FINAL "
416 PRINT " PAYMENT. FOR EXAMPLE, ON A $50,000.00 MORTGAGE, YOU WANT FIXED"
418 PRINT " PAYMENTS OF $500.00 AND A FINAL PAYMENT OF $17,500.00. THE "
420 PRINT " AMORTIZATION WILL USE PAYMENTS AT $500.00 TO REACH $17,500.00. "
422 PRINT " YOU MAY ENTER ANY VALUE FROM $0.00 TO PRINCIPAL AMOUNT. "
424 RETURN
426 :
428 REM **** PAYMENT COMPARISON ROUTINE ****
430 CLS
432 PRINT "DON'T PANIC, (ESC) TO CANCEL OUTPUT"
434 LOCATE 1,1,0
436 PRINT #1,"PAYMENT COMPARISON PREPARED FOR ";DAT$(12,1)
438 IF VAL(DAT$(12,2))>3 THEN PRINT #1,CHR$(13)+CHR$(10)
440 PRINT #1,"BASED ON A";PD;"YEAR MORTGAGE WITH ";PC;" PAYMENTS PER YEAR"
442 IF VAL(DAT$(12,2))>3 THEN PRINT #1,CHR$(13)+CHR$(10)
444 PRINT #1," MORTGAGE LOAN AMOUNTS"
446 IF VAL(DAT$(12,2))>3 THEN PRINT #1,CHR$(13)+CHR$(10)
448 PRINT #1,"RATES ";
450 COLOR 0,7
452 FOR XA=0 TO 3
454 PRINT #1,USING "$$#,###,###,###.##";PA+(XA*2000);
456 NEXT XA
458 FOR XA=0 TO 19
460 IF VAL(DAT$(12,2))>3 THEN PRINT #1,CHR$(13)+CHR$(10) ELSE PRINT #1,
462 PI=(PB+(XA*.25))/(PC*100)
464 PRINT #1,USING "##.####";(PB+(XA*.25));
466 COLOR 15,0
468 FOR XB=0 TO 3
470 PO=INT((PA+(XB*2000))*(PI/(1#-(1#/((1#+PI)^PN))))*100+.5#)/100
472 PRINT #1,USING "$$#,###,###,###.##";PO;
474 NEXT XB
476 COLOR 0,7
478 NEXT XA
480 COLOR 15,0
482 LOCATE 2,1,1
484 IF VAL(DAT$(12,2))>3 THEN PRINT #1,CHR$(13)+CHR$(10) ELSE PRINT #1,
486 CLOSE #1
488 COLOR 26,0
490 PRINT "HIT ANY KEY TO CONTINUE ";
492 FOR XA=1 TO 2
494 XA=(INKEY$<>"")*-2
496 NEXT XA
498 COLOR 15,0
500 RETURN
502 :
504 REM **** AMORTIZATION ROUTINE ****
506 CLS
508 PRINT "DON'T PANIC, (ESC) TO CANCEL OUTPUT"
510 PRINT #1,"THIS AMORTIZATION PREPARED FOR ";DAT$(12,1)
512 IF VAL(DAT$(12,2))>3 THEN PRINT #1,CHR$(13)+CHR$(10)
514 PRINT #1,USING "&$$#,###,###,###.##&##&##&####&";"PAYMENT IS ";PO;" PAID ";PC;" TIMES YEARLY WITH ";PC-PE+1;" PAYMENTS IN ";YR;"."
516 IF VAL(DAT$(12,2))>3 THEN PRINT #1,CHR$(13)+CHR$(10)
518 PRINT #1,USING "&$$#,###,###,###.##&##.####&##&";"PRINCIPAL IS ";PA;" AT A RATE OF %";PB;" FOR ";PD;" YEARS."
520 IF VAL(DAT$(12,2))>3 THEN PRINT #1,CHR$(13)+CHR$(10)+CHR$(13)+CHR$(10) ELSE PRINT #1,
522 PU=0
524 PW=0
526 PY=0
528 PZ=0
530 PF=1
532 PG=PC
534 IF PE>1 THEN PD=PD+1:PF=PE
536 FOR XB=1 TO PD
538 PT=0
540 PV=0
542 PX=0
544 PRINT #1,STRING$(27, 45)+"YEAR OF PAYMENT(S) IS ";YR;STRING$(24, 45)
546 IF VAL(DAT$(12,2))>3 THEN PRINT #1,CHR$(13)+CHR$(10)
548 PRINT #1," NO. INTEREST PRINCIPAL PAYMENT BALANCE";
550 IF VAL(DAT$(12,2))>3 THEN PRINT #1,CHR$(13)+CHR$(10)
552 FOR XA=PF TO PG
554 PH=(INT((PA*PI+.005#)*100)/100)
556 PZ=PZ+1
558 IF PC<>12 THEN PRINT #1,USING "####";PZ;
560 IF PC=12 THEN PRINT #1,USING "&";DAT$(7,XA);
562 IF (XB=PD AND XA=PG) OR PO>PA+PH THEN PO=PA+PH:XB=PD:XA=PG
564 PJ=PO-PH
566 PT=PT+PH
568 PU=PU+PH
570 PV=PV+PJ
572 PW=PW+PJ
574 PX=PX+PO
576 PY=PY+PO
578 PA=PA-PJ
580 PRINT #1,USING "$$###,###,###,###.##";PH;
582 PRINT #1,USING "$$#,###,###,###.##";PJ;
584 PRINT #1,USING "$$###,###,###,###.##";PO;
586 PRINT #1,USING "$$#,###,###,###.##";PA;
588 IF VAL(DAT$(12,2))>3 THEN PRINT #1,CHR$(13)+CHR$(10)
590 A$=INKEY$
592 IF A$=CHR$(27) THEN XA=PG:XB=PD
594 NEXT XA
596 YR=YR + 1
598 PF=1
600 IF PE>1 AND XB=(PD-1) THEN PG=(PE-1)
602 IF VAL(DAT$(12,2))>3 THEN PRINT #1,CHR$(13)+CHR$(10) ELSE PRINT #1,
604 PRINT #1," ";
606 PRINT #1,USING "$$###,###,###,###.##";PT;
608 PRINT #1,USING "$$#,###,###,###.##";PV;
610 PRINT #1,USING "$$###,###,###,###.##";PX;
612 PRINT #1," YEAR TO DATE"
614 IF VAL(DAT$(12,2))>3 THEN PRINT #1,CHR$(13)+CHR$(10)+CHR$(13)+CHR$(10) ELSE PRINT #1,
616 PRINT #1," ";
618 PRINT #1,USING "$$###,###,###,###.##";PU;
620 PRINT #1,USING "$$#,###,###,###.##";PW;
622 PRINT #1,USING "$$###,###,###,###.##";PY;
624 PRINT #1," MORTGAGE TO DATE"
626 IF VAL(DAT$(12,2))>3 THEN PRINT #1,CHR$(13)+CHR$(10)+CHR$(13)+CHR$(10)
628 PRINT #1,
630 IF VAL(DAT$(12,2))<1 THEN PRINT "HIT A KEY (OTHER THAN ESC) TO CONTINUE";:FOR XC=1 TO 2:A$=INKEY$:XC=(A$<>"")*-2:NEXT XC:IF A$=CHR$(27) THEN XB=PD
632 NEXT XB
634 CLOSE #1
636 RETURN
638 :
640 REM **** VARIABLE DESCRIPTIONS ****
642 REM * PA=AMOUNT TO FINANCE PB=YEARLY INTEREST RATE
644 REM * PC=PAYMENTS PER YEAR PD=NUMBER OF YEARS
646 REM * PE=1ST PAYMENT MADE IN A YEAR PF=COUNTER OF PER YEAR INTEREST
648 REM * PG=COUNTER OF PER YEAR INTEREST PH=DOLLARS OF INTEREST PER PERIOD
650 REM * PI=INTEREST RATE PAID PER PERIOD PJ=PRINCIPAL DOLLARS PER PERIOD
652 REM * PN=TOTAL PAYMENTS TO MAKE PO=PAYMENT PER PERIOD ROUNDED UP
654 REM * PP=FINAL BALLOON PAYMENT AMOUNT PT=TOTAL INTEREST PAID PER YEAR
656 REM * PU=MORTGAGE TOTAL INTEREST PAID PV=TOTAL PRINCIPAL PAID PER YEAR
658 REM * PW=MORTGAGE TOTAL PRINCIPAL PAID PX=TOTAL OF PAYMENTS PER YEAR
660 REM * PY=MORTGAGE TOTAL OF PAYMENTS PZ=COUNTS NUMBER OF PAYMENTS MADE
662 REM * TN=NUMBER OF INPUT VARIABLES YR=YEAR PAYMENTS BEGIN
664 REM * A$=CHARACTER INPUT VARIABLE AF$=STRING INPUT VARIABLE
666 REM * XA, XB, XC, XD=FOR/NEXT VARIABLES XF AND E$=ERROR TRAPPING VARIABLES
668 REM * DAT$ ARRAY IS A 12X12 MATRIX WITH HORIZONTAL 1=INPUT FIELD NAMES
670 REM * 2=RANGE LOWER LIMIT, 3=RANGE UPPER LIMIT, 4=OUTPUT DEVICES
672 REM * 5=OUTPUT BAUD RATES, 6=CHARACTERS PER INPUT FIELD, 7=THE MONTHS
674 REM * 12=TRANSIENT DATA STORAGE, 8-11 ARE CURRENTLY UNUSED.
676 :
678 REM **** DATA FOR ARRAY ****
680 DATA " NAME/DATE = >", " OUTPUT DEVICE = >", " OUTPUT BAUD RATE = >", " AMOUNT TO FINANCE = >"
682 DATA " YEARLY INTEREST RATE = >", " PAYMENTS PER YEAR = >", " NUMBER OF YEARS = >", " # OF 1ST PAY PERIOD = >"
684 DATA " YEAR PAYMENTS BEGIN = >", " FIXED PAYMENT AMOUNT = >", " BALLOON PAY AMOUNT = >",
686 DATA "A-Z", "0", "0", "1", ".1", "1", "1", "1", "1000","0","0",
688 DATA "0-9", "7", "9", "9999999999.99", "35", "52", "35", "52", "9999", "9999999999.99","9999999999.99",
690 DATA "SCRN:", "LPT1:", "LPT2:", "LPT3:", "COM1:", "COM2:", "COM3:", "COM4:"
692 DATA ,,,," 75", "110", " 150", " 300", " 600", "1200", "1800", "2400", "4800", "9600",,
694 DATA "40", "2", "2", "14", "20", "3", "6", "3", "5", "14", "14",
696 DATA "JAN ", "FEB ", "MAR ", "APR ", "MAY ", "JUN ", "JUL ", "AUG ", "SEP ", "OCT ", "NOV ", "DEC "
698 :
700 REM **** ERROR TRAPPING ROUTINE ****
702 COLOR 4,0
704 PRINT "SYSTEM ERROR, PLEASE CORRECT, THEN HIT A KEY (OR ESC)."
706 COLOR 15,0
708 FOR XF=1 TO 2
710 E$=INKEY$
712 XF=(E$<>"")*-2
714 NEXT XF
716 CLS
718 IF E$<>CHR$(27) THEN RESUME ELSE DAT$(0,0)=CHR$(27):RESUME 176

Greatgraddage
Posts: 29
Joined: Fri Sep 17, 2004 1:40 pm

Post by Greatgraddage » Mon Jan 10, 2005 4:53 pm

Ah, basic. I wrote a Snake game in QBasic for DOS and started an RPG, just never got around to finishing the graphics engine. Microsoft has a language called Visual Basic, handy for quick windows GUI programs but pretty pants all in all.
Firefight... Those were the days.....

User avatar
sharon
Posts: 43
Joined: Wed Dec 22, 2004 9:48 pm
Location: leicester, uk
Contact:

Post by sharon » Mon Jan 10, 2005 11:40 pm

look what i found :lol: http://winape.emuunlim.com WinAPE32 - The Windows Amstrad Plus Emulator

I used to use gosub and return alot also, i only used goto when i didnt want the program to return to where it left from

so, is there anything that uses simuler to this for writing windows programs ?

i did try mvb once but didnt get to far with it :lol:
will my pc ever be fast enough?

Post Reply