pvjc25/du8/README.md
2025-06-11 12:28:51 +02:00

49 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## Ovládanie
- Pohyb: `W`, `A`, `S`, `D`
- Potvrdenie ťahu: medzerník
## Ukončenie hry
Hra končí, keď:
- jeden hráč získa 3 znaky v rade (vodorovne, zvisle alebo diagonálne),
- všetky polia sú zaplnené (remíza).
## Štruktúra a funkcie
### `GameState` štruktúra hry:
- `board`: 2D pole pre hernú plochu
- `board_size`: veľkosť (2,3,4)
- `num_players`: počet hráčov (1,2,3)
- `symbols`: pole znakov hráčov (napr. 'X', 'O', 'a')
- `mode`: herný režim
- `current_player`: index aktuálneho hráča
- `moves_made`: počet ťahov
### Kľúčové funkcie:
- `init_game()`: Inicializácia hracieho stavu
- `draw_game()`: Vykreslenie stavu cez `world*`
- `handle_input()`: Interakcia s hráčom (ovládanie)
- `computer_move()`: Jednoduchá AI
- `check_winner()`: Detekcia výhry
## Použitie knižnice `world`
Použili sme nasledujúce funkcie z `world.h`:
- `world_init()` *
- `world_clear()` *
- `world_print()` *
- `world_read_key()` *
- `world_set_cursor()` *
- `world_end()` *
Všetky volania NCURSES boli spravené výhradne cez knižnicu `world`.
## Zdroje
- [Knižnica world](https://github.com/hladek/world)
- Vlastné znalosti