Programming by Example

 

A BB4W Compendium

freeman69@gmx.com

IDIC BBC_Owl2 M&P

IDIC

Infinite Diversity, Infinite Challenges

 

It isn't easy to create computing exercises that are challenging, while allowing for the limited knowledge of the new programmer.

 

This page is devoted to a concept whereby a 'Server' program presents a challenge. The 'Server' is communicated with, by the student's program, via a simple random access file. Everything takes place within the bounds of a multi-tasking desktop environment. The process is turn based, but allows for a diverse range of exercises.

 

The duties of the 'Server' program are to:

 

    Define the rules of the exercise/challenge

    Create the environment

    Communicate with the player program(s)

    Display the results of each turn/move

    Act as umpire/adjudicator

 

See this pdf for further details.

Challenge

 

1.   Grid Bug

 

2.   Proximity

 

3.   Hunters

 

4.   TwentyOne

 

5.   Padlock

Specifications

 

Download

 

Download

 

Download

 

Download

 

Download

Compiled program(s)

 

Vsn 1.3

 

Vsn 1.3

 

Vsn 1.0

 

Vsn 1.0

 

Vsn 1.0

GridBug

Players

 

     1

 

     1

 

     1

 

    1

 

     1

Rating

 

Easy?

 

Tricky

 

Medium

 

Easy-ish

 

Difficult

While player programs can be written in any language that supports file handling, simple player source code for BB4W, relevant to single-player challenges, is provided below:

 

     reply$=""

     REPEAT

       x=OPENIN("MsgFile.txt")

       IF x>0 THEN

         REM Has the 'Server' responded with a message?

         IF FNgetmessage(1)="0" THEN

           REM The user may read the message file in one or multiple sections 

           m$=FNgetmessage(N):CLOSE#x

 

           REM Player's programming solution goes here (replies into reply$)

           

           REM Update the message file with our reply

           PROCwrite(reply$)

         ELSE

           CLOSE#x

         ENDIF

       ENDIF

       WAIT 50:REM Wait 1/2 second

     UNTIL FALSE

     END

     

     REM Retrieve a portion of the message file

     DEF FNgetmessage(c)

     LOCAL a,c$

     FOR a=1 TO c:c$+=CHR$(BGET#x):NEXT

     =c$

     

     REM Replace the message record with our reply

     DEF PROCwrite(r$)

     LOCAL a

     r$="1"+r$

     x=OPENUP("MsgFile.txt")

     FOR a=1 TO LEN(r$):BPUT#x,ASC(MID$(r$,a,1)):NEXT

     CLOSE#x

     ENDPROC

Challenges

Messages TwentyOne Padlock

Click here for the 'Lost Robot 9261' programming competition (2015).