Ideas for interactive tasks

363 views
Skip to first unread message

Nikita Beloglazov

unread,
Aug 9, 2012, 11:21:45 AM8/9/12
to clo...@googlegroups.com
Hello
I'm going to organize little clojure course at my university this year. For this I want to implement set of tasks that hopefully will help to practise clojure.
Tasks will be animated so students can see how their solutions work. E.g. one of the tasks is to hit plane by missile: there is a plane that flies from left to the right with fixed speed. Player launches missile to hit the plane. Task is to write a function that takes coordinates of plane and player and returns angle for launching missile. Plane's and missile's speeds are constant and known. This task requires math and basic clojure knowledge (only perform math operations, use let, if, Math/* functions).
Another example is to implement a bot for snake. Bot is implemented as a function that takes snakes position (sequence of cells, each cell is vector of 2 values) and apple position (vector of 2 values). Function must return what direction to move. This task requires using of clojure seq functions.
Can somebody propose ideas for this kind of tasks? I'm particularly interested in tasks that require different fields of clojure, e.g. I don't know what to implement for learning atoms, refs and agends.

Examples of tasks (artillery and snake) can be found here: https://github.com/nbeloglazov/clojure-interactive-tasks. I use quil for animation. Animation is primitive in the tasks (I'm not particularly good at it).

Thank you,
Nikita Beloglazov

Jim - FooBar();

unread,
Aug 9, 2012, 11:23:42 AM8/9/12
to clo...@googlegroups.com
On 09/08/12 16:21, Nikita Beloglazov wrote:
> I'm going to organize little clojure course at my university this year.

this is amazing! seriously, bravo! what university is this?

Jim

Nikita Beloglazov

unread,
Aug 9, 2012, 11:28:54 AM8/9/12
to clo...@googlegroups.com
Thank you, Jim. This is Belarusian State University.



--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Nikita Beloglazov

unread,
Aug 13, 2012, 5:27:08 AM8/13/12
to clo...@googlegroups.com
Thanks for idea, Igor. Seems like some kind of simulation (looking at your example and clojure ants demo) can be a good example of concurrency.

Thank you,
Nikita

On Sun, Aug 12, 2012 at 2:01 PM, Igor Kupczyński <pusz...@gmail.com> wrote:
Hi,

For a java course at my university students had to write a railway simulator - the idea was more or less to write randomly generate a map with railways and regular roads. Some of the tracks where double (i.e. trains can go both directions at the same time) and the other just a single track (one train, one direction at a time). In the the single tracks there were special bays for trains to wait while a train in the opposite direction is running. There were passenger trains and cargo trains, but the former had a priority over the latter (when single tracks were considered). There were cars on the regular roads (all bidirectional and running at the same speed), the only challenge for cars was to stop when a road crossed a railway and there was a train running on that railway. The idea was of course not cause any collision. The graphics had to pretty simple, i.e. 2d bird perspective, rectangles representing trains and squares representing cars.

Of course this was quite a big end-of-semester assignment. Maybe it will give you some ideas.

Thanks,
Igor

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to

dmirylenka

unread,
Aug 13, 2012, 2:00:03 PM8/13/12
to clo...@googlegroups.com
Wow, too bad I already graduated :)

ФПМИ?


On Thursday, August 9, 2012 5:28:54 PM UTC+2, Nikita Beloglazov wrote:
Thank you, Jim. This is Belarusian State University.

On Thu, Aug 9, 2012 at 6:23 PM, Jim - FooBar(); <jimpi...@gmail.com> wrote:
On 09/08/12 16:21, Nikita Beloglazov wrote:
I'm going to organize little clojure course at my university this year.

this is amazing! seriously, bravo! what university is this?

Jim


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to

Nikita Beloglazov

unread,
Aug 13, 2012, 3:17:26 PM8/13/12
to clo...@googlegroups.com
Daniil, yes it is
Do you have some suggestions about tasks or teaching at the BSU in generally? :)

Nikita

dmirylenka

unread,
Aug 14, 2012, 8:45:13 AM8/14/12
to clo...@googlegroups.com
It's really great that you are going to teach Clojure at BSU.

I have no clue about teaching, but my impression is that back in my days, we didn't learn much about how to write good code.
Maybe things were different in 'informatics', but in 'applied mathematics', for instance, we only had exposure to imperative programming. If this is still the case, I think, your course could get students familiar with the concepts and benefits of FP (immutability, referential transparency, etc.). Then they could learn more specific things like persistent data structures, multimethods, macros, agents, etc.. I would probably try to emphasize the advantages of certain features of Clojure and FP in general, when it is appropriate to use them and how.

As for the interactive tasks, I think, it's a good idea, as they are fun.
My only note so far is that they seem to require quite some effort unrelated to learning Clojure, but it may be what you intended (would be nice seing your course program).
For instance, in 'artillery' task, the time it took to code up the solution was infinitesimal, compared to the time I spent building the model and recalling how to solve trigonometric and quadratic equations :). But seing the plain fall was rewarding...

One task I remember form my courses was to program a trolley that moves parts between the machines of a production line (Each machine has an input and output queue with limited capacities, and a distinct processing time). This can also be extended for concurrency task, if you introduce two trolleys, etc.
Another thought about concurrency - let them program the 'dining philosophers'.
In addition, the idea of writing game bots can be exploited further: e.g. what about a tetris bot?

I'm very excited about your intent to teach Clojure at BSU. I would be glad to stay in touch for further discussions.

Daniil

Nikita Beloglazov

unread,
Aug 15, 2012, 5:19:37 PM8/15/12
to clo...@googlegroups.com
It's really great that you are going to teach Clojure at BSU.

I have no clue about teaching, but my impression is that back in my days, we didn't learn much about how to write good code.
I have no experience either, but I think it's not appropriate that CS students know nothing about FP.
 
Maybe things were different in 'informatics', but in 'applied mathematics', for instance, we only had exposure to imperative programming.
No, things are still the same, we study java, c++, assembler.

I think, your course could get students familiar with the concepts and benefits of FP (immutability, referential transparency, etc.). Then they could learn more specific things like persistent data structures, multimethods, macros, agents, etc.. I would probably try to emphasize the advantages of certain features of Clojure and FP in general, when it is appropriate to use them and how.
Yes, it is the main goal of the course. I'm only afraid I don't understand them completely myself. I don't have real-life projects in clojure, just a few pet-projects. Here are the topics I want to cover:
1. Introduction, install and setup clojure, lein.
2. Basics (def, defn, let, if, numbers, strings)
3. Collections (immutability, types of collections, functions for manipulating collections)
4. Concurrency (atoms, refs, agents)
5. Study implementation of some persistent datastructure (e.g. PersistentVector).
6. Macros (I used it very few times, so don't have examples to show).
7. Multimethods (same situation as with macros)
8. Datatatypes and protocols (even worse)
9. Little of Lambda Calculus (implement numbers, true/false, pairs, recursion).
10. Play with some clojure projects (e.g. overtone).
I'll have about 3 months, so it's approximately 1 week (1 lesson) for a topic. I want students to read next lesson topic before the lesson and first half of the lesson discuss it and the second to solve tasks (and solve tasks during a week). I'm not sure it will work but I hope :)

As for the interactive tasks, I think, it's a good idea, as they are fun.
My only note so far is that they seem to require quite some effort unrelated to learning Clojure, but it may be what you intended (would be nice seing your course program).
For instance, in 'artillery' task, the time it took to code up the solution was infinitesimal, compared to the time I spent building the model and recalling how to solve trigonometric and quadratic equations :). But seing the plain fall was rewarding...
Yes, it is harder than I expected, but we also a math faculty so we must be able to solve such tasks :)
 

One task I remember form my courses was to program a trolley that moves parts between the machines of a production line (Each machine has an input and output queue with limited capacities, and a distinct processing time). This can also be extended for concurrency task, if you introduce two trolleys, etc.
Could you explain how to model it in clojure? Or how to start modelling.
 
Another thought about concurrency - let them program the 'dining philosophers'.
In addition, the idea of writing game bots can be exploited further: e.g. what about a tetris bot?
Yes, why not? :) It will be pretty advanced task (from algorithmical point of view).
Need to invent more games :)

I'm very excited about your intent to teach Clojure at BSU. I would be glad to stay in touch for further discussions.

Daniil

Ideally I want students to develop some projects in clojure (game or web project or something else). But I don't know whether they like this idea.

Thank you for you reply!

Nikita

 

dmirylenka

unread,
Aug 16, 2012, 4:53:18 PM8/16/12
to clo...@googlegroups.com
As for the trolley, this is how I see it:

The state of the system is defined by:
1. the (current) number of parts the machines have in their input and output queues
2. the (current) number of parts in the trolley (may be limited by 1)
3. whether the machine is currently processing a part can also be included into state.
These pieces of state can be modelled as refs.
Machines and trolley will update some of these refs simultaneously, in transaction, subject to some consistency rules, for instance:
The machine can't start processing a part if its output queue is full, the trolley can't move a part to a machine whose input queue is full, etc.
Transition of parts between the trolley and the machines happens in transaction (which is most important, when there are >1 trolleys).

Then there also will be some logic, however simple, in how the trolley moves. For instance, it can just pass sequentially between the machines and check if it can move some parts from a given machine to the following one.

Daniil

Zmitro Lapcjonak

unread,
Sep 11, 2012, 8:30:31 AM9/11/12
to Clojure

On Aug 9, 6:21 pm, Nikita Beloglazov <nikelandj...@gmail.com> wrote:
> I'm going to organize little clojure course at my university this year. For
> this I want to implement set of tasks that hopefully will help to practise
> clojure.

Some tasks you may find at 4clojure:
https://www.4clojure.com/problems
Sort by "topic" and select "games, graph, data-analysis"

"Project Euler" has some interesting problems that you
may use to teach Clojure and train math theory also.


> Thank you,

Thank you and good luck!

--
Zmitro Lapcionak

Murtaza Husain

unread,
Sep 12, 2012, 1:33:04 AM9/12/12
to clo...@googlegroups.com

This is really interesting. I am wondering if the idea could be broadened to not just teach CS, but also maths, physics and chemistry. 

A curriculum in which programming is used as a tool to explore the different sciences. An integrated curriculum to teach the different sciences. 

Please keep us posted on your progress.

Murtaza Husain

unread,
Sep 12, 2012, 1:43:15 AM9/12/12
to clo...@googlegroups.com

Thinking aloud, clojure could be used to create a DSL using which the students can experiment with concepts from different sciences, and see the results / effects in a graphical manner !!  

Nikita Beloglazov

unread,
Sep 12, 2012, 4:22:18 PM9/12/12
to clo...@googlegroups.com
Zmitro: I'll definitely use 4clojure in teaching, but I'm looking for more interactive tasks so I can use graphics/sound/charts/something else to visualize them.

Murtaza: It's a great idea, but I'm experienced enough to take such task :)

Thank you,
Nikita

--
Reply all
Reply to author
Forward
0 new messages