[Tutor] Proper SQLite cursor handling?

Alan Gauld alan.gauld at yahoo.co.uk
Tue Jul 6 05:06:37 EDT 2021


On 06/07/2021 01:20, boB Stepp wrote:

> Each one of these solitaire games would have its own collection of
> hands played over time and look like:
> 
> boBSolitair
> =========
> hand_num | date_played | time_recorded | hand_score
> ==========================================
> 1                | 2021-07-04  | 1342                | -5
> 2                | 2021-07-04  | 1356                | 43
> 3                | 2021-07-05  |  0704               | -26
> 4                ...
> 
> Likewise "boBSolitair2" and "AlanSolitair1" would have their own hands
> played tables.
This is the bit swe are saying is suspect.
Rather than a hands table per game type just make game
type a field of a single hands table.

> So each "game" is a combination of a particular type of solitaire
> played with a certain strategy applied.  

I'm not sure how you plan on creating/recording "strategies".
That sounds like a set of rules or heuristics that are typically
very difficult to codify as data. I'd expect those to be stored as
Python code within your game class(es?)

So you'd have a top level abstract Game class, then subclasses
for each variant (boBSolitair1, AlanSolitair1, etc) that
overrides the strategy containing method(s) as appropriate.

> record of ALL of the hands played using that type of solitaire with a
> particular strategy used in the game play.  

The bit I'm not sure of is does this mean that each game type can have
multiple strategies? And each hand may have a different strategy?

So the object model becomes (I need really UML for this!):
Warning ASCII art coming up! Monospace font needed...

+++++++++++++++++++
Hand
 |
Game<-boBSolitair1
 |
Strategy
+++++++++++++++++++=

> Later I will compare all
> solitaire games played of the same kind of solitaire to determine the
> effectiveness of the different strategies applied.
> 
> Does this help make things clearer?

Yes, but introduces the whole new issue of what exactly
a Strategy looks like and how it might be stored? Is
it just a function/method/algorithm? Or is it a set
of data/parameters? Or a mixture of both?

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list