Photo AI
Question 6
6. OCRBlocks is a game played on a 5 x 5 grid. Players take it in turns to place blocks on the board. The board is stored as a two-dimensional (2D) array with the id... show full transcript
Step 1
Step 2
Step 3
Step 4
Answer
Validation can be added by checking the values of r and c before accessing gamegrid. For instance:
if r < 0 or r >= 5 or c < 0 or c >= 5 then
return "ERROR: Invalid position"
endif
This ensures that only valid indices are used.
Step 5
Answer
Algorithm allowPlayerAToSelectPosition
repeat
ask player for position (r, c) of their block on the board
if checkblock(r, c) == "FREE" then
gamegrid[r,c] = "A"
else
print "Position is not free. Please choose another position."
endif
until checkblock(r, c) == "FREE"
endAlgorithm
Report Improved Results
Recommend to friends
Students Supported
Questions answered
CPU Architecture, Performance & Embedded Systems
Computer Science - AQA
Primary & Secondary Storage
Computer Science - AQA
Data Storage & Compression
Computer Science - AQA
Networks & Topologies
Computer Science - AQA
Wired & Wireless Networks, Protocols & Layers
Computer Science - AQA
Identifying & Preventing Threats to Computer Systems & Networks
Computer Science - AQA
Operating Systems & Utility Software
Computer Science - AQA
Ethical, Legal, Cultural & Environmental Impact
Computer Science - AQA
Computational Thinking, Searching & Sorting Algorithms
Computer Science - AQA
Designing, Creating & Refining Algorithms
Computer Science - AQA
Programming Fundamentals & Data Types
Computer Science - AQA
Additional Programming Techniques
Computer Science - AQA
Defensive Design & Testing
Computer Science - AQA
Boolean Logic Diagrams
Computer Science - AQA
Programming Languages & Integrated Development Environments (IDEs)
Computer Science - AQA
OCR Exam Reference Language
Computer Science - AQA