On Saturday, May 27, 2017 at 4:00:09 PM UTC+2, A Mauer-Oats wrote:
> Does anyone use array data with the Universe teachpack?
> 
> I thought it would be interesting to work with 2D data in an "advanced 
> introductory" class. At least to the extent of being able to model classic 
> board games like Battleship and Checkers.
> 
> This time we used math/array, but arrays are basically mutable in nature and 
> that doesn't seem to work very well with way the universe is set up. My 
> students ended up writing a lot of code like (begin (array-set! board ...) 
> board) without really understanding it. Some copied arrays far too much and 
> performance suffered, but I think that is a secondary concern.
> 
> Is there a 2d data structure with functional updates that would be more 
> suitable to this situation?
> 
> I am aware of the possibility of abandoning big-bang for gui-lib, but I think 
> that has its own minuses - it felt like I would need to teach too much about 
> classes for it to work.
> 
> Any suggestions or tales of relevant experience would be welcome. (Even 
> "don't do that!" notes from people with more experience. :)
> 
> Andrew Mauer-Oats
> CPS/Whitney Young Magnet High School

You could use a list of values of some sort suitable to the game at hand to 
represent the board, and rely on operations on lists in a purely functional 
manner. For boards of relatively small size and without lots of dynamics 
performance shouldn't be an issue.

In the MOOC 'How to Code' (known before as 'Systematic Program Design') you can 
find examples of this kind of representation. Take a look, for instance, at 
this sudoku solver:

https://www.youtube.com/watch?v=cDaEykxaR6M

Though this solver doesn't include a "world" program, I think it would be easy 
to add that functionality.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to