Format fix 2006/meyer/README.md
This commit is contained in:
1 parent
d0b357e4c5
commit
1cb018146d
1 file changed
+43
-29
+43
-29
@@ -1,7 +1,7 @@
|
|||||||
# Best Game
|
# Best Game
|
||||||
|
|
||||||
Raphael Meyer
|
Raphael Meyer
|
||||||
US
|
US
|
||||||
|
|
||||||
## To build:
|
## To build:
|
||||||
|
|
||||||
@@ -34,41 +34,46 @@ more text to fulfil the program's requirements.
|
|||||||
|
|
||||||
This entry turns a newspaper solitaire puzzle into a competition
|
This entry turns a newspaper solitaire puzzle into a competition
|
||||||
with the computer to be the last one moving. The object of this
|
with the computer to be the last one moving. The object of this
|
||||||
source code is to determine the object of this source code! :-)
|
[source code](meyer.c) is to determine the object of this [source
|
||||||
|
code](meyer.c)! :-)
|
||||||
|
|
||||||
## Author's remarks:
|
## Author's remarks:
|
||||||
|
|
||||||
I wanted submit a fully object-oriented entry to show that
|
I wanted submit a fully object-oriented entry to show that
|
||||||
object-orientated code:
|
object-orientated code:
|
||||||
|
|
||||||
1. is ridiculously bloated
|
1. is ridiculously bloated.
|
||||||
2. is unreadable
|
2. is unreadable.
|
||||||
3. isn't WYWIWID (what you write is what it does) anymore
|
3. isn't '`WYWIWID`' ('what you write is what it does') anymore.
|
||||||
|
|
||||||
But I just totally failed. No, I didn't fail in showing any of
|
But I just totally failed. No, I didn't fail in showing any of
|
||||||
the points above. Before I even had the chance to prove any of
|
the points above. Before I even had the chance to prove any of
|
||||||
these claims, (1) already brought me to my knees. The code got
|
these claims, (1) already brought me to my knees. The code got
|
||||||
so much bloated up, that I missed the size limit by a few hundred
|
so bloated up, that I missed the size limit by a few hundred
|
||||||
bytes. Therefore, I broke the only rule in this contest, I think
|
bytes. Therefore, I broke the only rule in this contest, I think
|
||||||
you shouldn't break in any case: Rule Nr 2, The size of ...
|
you shouldn't break in any case: Rule Nr 2, The size of ...
|
||||||
|
|
||||||
The degree of claim (2) actually depends on the compiler. As I
|
The degree of claim (2) actually depends on the compiler. As I
|
||||||
_manually_ compiled it from [a generic object-oriented programming
|
_manually_ translated it from a generic object-oriented programming
|
||||||
language] to C, it didn't just end up unreadable, but awfully
|
language to C, it didn't just end up unreadable, but awfully
|
||||||
messed up, i.e. obfuscated.
|
messed up, i.e. obfuscated.
|
||||||
|
|
||||||
As it is already (pre)compiled to C, you could also call it an object-
|
As it is already (pre)translated to C, you could also call it an object-
|
||||||
disoriented program.
|
disoriented program.
|
||||||
|
|
||||||
Comparing this program to a potential object-oriented implementation,
|
Comparing this program to a potential object-oriented implementation,
|
||||||
it is obvious, that object-oriented code isn't WYWIWID (what
|
it is obvious, that object-oriented code isn't '`WYWIWID`' ('what
|
||||||
you write is what it does). It may be tempting to think that
|
you write is what it does'). It may be tempting to think that
|
||||||
|
|
||||||
|
```
|
||||||
Object o;
|
Object o;
|
||||||
|
```
|
||||||
|
|
||||||
might do something similar as
|
might do something similar as
|
||||||
|
|
||||||
|
```c
|
||||||
struct not_an_object o;
|
struct not_an_object o;
|
||||||
|
```
|
||||||
|
|
||||||
But this program reveals that it doesn't. Even worse, this program only
|
But this program reveals that it doesn't. Even worse, this program only
|
||||||
reveals the tip of the iceberg, what kind of black magic is involved in
|
reveals the tip of the iceberg, what kind of black magic is involved in
|
||||||
@@ -77,43 +82,52 @@ a simple declaration of an object.
|
|||||||
A few things you can explore about object-orientation in this program
|
A few things you can explore about object-orientation in this program
|
||||||
include:
|
include:
|
||||||
|
|
||||||
- constructors (invoked by the new operator)
|
- constructors (invoked by the new operator).
|
||||||
- new operators (every class gets its own new operator at compile time)
|
- new operators (every class gets its own new operator at compile time).
|
||||||
- virtual method tables
|
- virtual method tables (all the virtual method tables have been combined to a
|
||||||
(all the virtual method tables have been combined to a single vtable)
|
single [vtable](https://en.wikipedia.org/wiki/Virtual_method_table)).
|
||||||
- runtime method binding
|
- runtime method binding.
|
||||||
- inheritance and polymorphism
|
-
|
||||||
|
[inheritance](https://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming))
|
||||||
|
and
|
||||||
|
[polymorphism](https://en.wikipedia.org/wiki/Polymorphism_(computer_science)).
|
||||||
|
|
||||||
It is left as an exercise to the reader to find a corresponding
|
It is left as an exercise to the reader to find a corresponding
|
||||||
implementation in a popular object-oriented programming language.
|
implementation in a popular object-oriented programming language.
|
||||||
|
|
||||||
### Starting the game
|
### Starting the game
|
||||||
|
|
||||||
./meyer [SEED]
|
```sh
|
||||||
|
./meyer [SEED]
|
||||||
|
```
|
||||||
|
|
||||||
### Gameplay
|
### Gameplay
|
||||||
|
|
||||||
It is a sudoku based game. The goal of the game is to be able
|
It is a [sudoku](https://en.wikipedia.org/wiki/Sudoku) based game. The goal of
|
||||||
to do the last valid 'move'.
|
the game is to be able to do the last valid 'move'.
|
||||||
|
|
||||||
On your turn you have to set a free cell to a value between 1 to 9 without
|
On your turn you have to set a free cell to a value between 1 to 9 without
|
||||||
breaking the following rule. Any number must be unique in its:
|
breaking the following rule. Any number must be unique in its:
|
||||||
|
|
||||||
1. row
|
1. row
|
||||||
2. column
|
2. column
|
||||||
3. 3x3 block.
|
3. 3x3 block.
|
||||||
|
|
||||||
Expected input for your move:
|
Expected input for your move:
|
||||||
|
|
||||||
row column number
|
```
|
||||||
|
row column number
|
||||||
|
```
|
||||||
|
|
||||||
where
|
where
|
||||||
|
|
||||||
row: [a-i]
|
```
|
||||||
column: [0-8]
|
row: [a-i]
|
||||||
number: [1-9].
|
column: [0-8]
|
||||||
|
number: [1-9].
|
||||||
|
```
|
||||||
|
|
||||||
The game can be aborted with 'q'.
|
The game can be aborted with `q`.
|
||||||
|
|
||||||
The one who can do the last move wins the game.
|
The one who can do the last move wins the game.
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user