Zack Saadioui
8/27/2024
1
2
bash
curl -fsSL https://ollama.com/install.sh | sh
1
2
3
4
5
6
yaml
/pet_app
├── main.py
├── pet.py
├── user.py
├── requirements.txt
1
pet.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
class VirtualPet: def __init__(self, name, species): self.name = name self.species = species self.hunger = 5 # 0 (not hungry) to 10 (very hungry) self.happiness = 5 # 0 (sad) to 10 (happy) def feed(self): if self.hunger < 10: self.hunger += 1 print(f'{self.name} is being fed!') else: print(f'{self.name} is not hungry.') def play(self): if self.happiness < 10: self.happiness += 1 print(f'{self.name} is playing!') else: print(f'{self.name} is already very happy!')
1
2
bash
ollama pull llama3.1
1
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>Virtual Pet</title>
</head>
<body>
<h1>Meet your Virtual Pet: Fluffy</h1>
<div id="pet-display">
<!-- Pet visuals here -->
</div>
<div id="controls">
<button onclick="feedPet()">Feed</button>
<button onclick="playPet()">Play</button>
</div>
<script src="script.js"></script>
</body>
</html>
1
script.js
1
2
3
4
5
6
dockerfile
FROM python:3.9
WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
CMD [ "python", "main.py" ]
1
2
3
bash
docker build -t virtual-pet .
docker run virtual-pet
Copyright © Arsturn 2024